Author Topic: Yet Another 3D Viewer  (Read 10906 times)

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Yet Another 3D Viewer
« Reply #45 on: April 25, 2014, 03:06:52 AM »
And every day I come up with a better use for the spacebar than the one I've assigned to it.

Well this is getting off topic a bit, but talking about overloading keys with special uses,  I use the Win Spacebar keystroke combination to move and resize my active Windows program between four predefined sizes and layouts.

I found this necessary because I typically use two monitors, running the second monitor from a laptop.  But if I take my laptop on the road and I don't have it hooked to the second monitor, many of my programs will open off screen.  So I hit Win Space bar and it round robbins the active program between the laptop screen and second screen using some of my favorite layouts.  I do this trick with AutoHotKey.

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Yet Another 3D Viewer
« Reply #46 on: April 25, 2014, 03:16:55 AM »
Sam,  I like the gifs.  Excellent on-demand approach.   The concept of creating frames when you snap the picture and having some transition math between the two view settings between the last picture and the current picture is obviously how the original DesignCAD animation works.  Though I find this vddsnap approach much more friendly and hence a big improvement in terms of control and interactive "scene making".
« Last Edit: April 25, 2014, 03:23:33 AM by prl »

samdavo

  • Hero Member
  • *****
  • Posts: 2588
  • the trick is knowin...^ > v < - which way's up?
Re: Yet Another 3D Viewer
« Reply #47 on: April 25, 2014, 03:34:37 AM »
prl
thanks
what I like about this is that you can have an animation combined with a walkthrough - i.e. there is no reason that the vertical blinds couldn't be waving around in the breeze, and casting waving shadows ( just for example) whilst the lighting and observer moves - or more generally, you could run dempsey's pushapart of the structural components , followed by push-back-together again.  etc etc.  (sky's the limit yet again).
cheers
sam 

bdeck

  • Hero Member
  • *****
  • Posts: 896
Re: Yet Another 3D Viewer
« Reply #48 on: April 25, 2014, 06:16:20 PM »
Here's a final version of vdd.

Found a flag variable (redo) out of place which caused the last version to ignore the first keystroke. Fixed.

If MS Win visual effects settings include fade out on closed windows, the SaveBmp function will save faster than DC can clear the save menu off the screen.   (Set wait=1 to require an extra keystroke to give window time to cleanup before saving image, or reconfigure windows)

Thanks Sam, Prl, etal for comments and ideas.

Next is an add-on project to make Sam's walk through a bit easier  vgg.d3m (view go go).

Regards

Edited 5/3/2014  to set sys(1174)=0 to avoid problem with saveas command
Edited 5/3/2017  to replace variable u with k_u
« Last Edit: May 03, 2017, 02:30:07 AM by bdeck »

bdeck

  • Hero Member
  • *****
  • Posts: 896
Re: Yet Another 3D Viewer
« Reply #49 on: October 24, 2017, 07:19:43 PM »
It's been a while since I've done anything to this macro. Had bigger plans, but first things first.

Here's an update to vdd that adds 2 useful functions to the Help Menu:

P  ...    toggles the polar limit of rotation.  ( when set, viewer cannot move past the north and south poles using the up/down arrows )

V  ...    redefines vertical axis to X or Z by creating a custom workplane Xup or Zup.

Workplane name is now the third entry in the status bar while the macro is running. (Yup is the default workplane)

After executing the Vx or Vz command, one needs to execute the X command to create a new view center. Haven't tried it with reversed coordinate systems, but I'm guessing it will be OK.  ( Might need to reverse the sign of one of the points in the Workplane command. )

( The far right panel of the status bar is non functional during the macro, and I was unable to hide it using sys$(200)="111110". Maybe someone here has an idea where I went wrong. )

Regards
bd

Edited to version 09f  on 01/17/17 to     
    1)  redraw cursor after R command (shadecycle:)
    2)  add "k_cr" as an optional default input to V command (vaxis:)
« Last Edit: January 17, 2018, 02:07:03 PM by bdeck »

samdavo

  • Hero Member
  • *****
  • Posts: 2588
  • the trick is knowin...^ > v < - which way's up?
Re: Yet Another 3D Viewer
« Reply #50 on: November 07, 2017, 02:51:32 AM »
Well done again bdeck - I must dust off my DCAD program and give it a go.  (PS I've been retired for a year or two) ... :)  Cheers

bdeck

  • Hero Member
  • *****
  • Posts: 896
Re: Yet Another 3D Viewer
« Reply #51 on: November 09, 2017, 09:12:45 AM »
Hi Sam,

Now let me get this straight.
You appear to be suggesting that retirement can affect one's use of DC.
Somehow that just does't seem right.

Good to hear from you.
BD

Dr PR

  • Hero Member
  • *****
  • Posts: 5611
Re: Yet Another 3D Viewer
« Reply #52 on: November 09, 2017, 10:41:37 AM »
BD,

My thoughts exactly! Don't we retire so we will have more time to play with DesignCAD?

Good to hear from you again Sam.

Phil
DesignCAD user since 1987

Rob S

  • Hero Member
  • *****
  • Posts: 4535
    • Construction Estimating Program for General Contractors
Re: Yet Another 3D Viewer
« Reply #53 on: November 09, 2017, 12:41:11 PM »
That depends

Some retire, and given absence of work related requirements have no idea what to draw...

Some retire and draw a ship...

Some draw home renovations, and risk their entire marriage trying to carry them out..

Some go golfing..

Point being, its a bit like jumping overboard on a foggy night, thus unable to see over the edge.

ps not sure how this relates to the subject line - maybe it does.
User since Pro-design

bdeck

  • Hero Member
  • *****
  • Posts: 896
Re: Yet Another 3D Viewer
« Reply #54 on: August 17, 2018, 01:46:20 PM »
Until Lar mentioned the rear "cutting plane" recently in a feature request post  http://forum.designcadcommunity.com/index.php?topic=7113.0, I had not looked at this rear limit in any depth.  I agree with Lar that this is a software issue that should be fixed.

Before launching into a macro to allow virtual walks through a 3D model, I figured it was imperative to get control of DC's front and rear limiting planes without waiting for a cure from IMSI. 

I've been working on a new version of the vdd macro that allows the user to modify the distance to a front virtual slice plan (dvirt) either directly, using the Slice Plane Distance (SPD) parameter, or relatively by means of  a virtual Slice Plane Distance Factor (SPDF).  (my terminology)

While the DC front slice plane is fixed at 0.50 of the distance beween the view center and the viewer, the SPDF can be adjusted to essentially any floating point value higher than zero.

The rear slice plane location, however, is adversely affected by reductions in SPDF, such that, if the viewer is close to an object, the small SPDF necessary to view the front of the object causes the rear slice plane to wipe out a large part of the rear of the view.

Fortunately, while all rendering modes in DC views must contend with a front view slice plane, it appears that the rear slice plane exists only in OpenGL(hardware) shading, and not in OpenGL wireframe views or in GDI shading.

So when using the new version, one  can manipulate a  view in extremely close quarters using a hardware rendering mode,  then  hit  <F8> <ENTER>  to create a GDI rendering free of a front or rear slice plane, then hit the "s" key  to save the rendering as an image file.

Three attached files show different renderings of identical views of a 1400-foot long girder, made up of 100-foot cubes. The viewer is only 470 feet (d=470.847) from a view center that is 400 feet from the near end of the girder.

View A  is a Flat OpenGL rendering using DC's default Slice Plane Distance Factor of 0.5. Much of the front and rear ends of the girder are outside the view limits, and are sliced away.

View B is a Flat OpenGL rendering of the same view, but where the virtual Slice Plane Distance Factor has been adjusted from .5 0 to 0.125, so that the virtual distance from the viewer to the front slice plane is now 59 feet (dvirt=58.856), even though the viewer is still 471 feet from the view center. The entire front end of the girder is visible, but the rear slice plane has hidden much more of the rear end of the girder.

View C is a Wireframe OpenGL rendering of the same view, where all settings other than rendering mode remain identical to those in view B. Wireframe mode, has no apparent rear slice plane, so the entire rear end of the girder is now visible. 

View D is a Flat GDI rendering, otherwise having settings identical to those in View B. Where in View B the rear 1100 feet of girder were missing from the OpenGL rendering, the GDI rendering of View D shows the entire length of the girder.

Within the macro, SPD or SPDF may be adjusted incrementally up and down with "/" and "\" key presses, where the increments are a fractional power of 2 or its inverse. Alternatively, either value may be entered directly with numeric keys.

Of course, in the present instance, one could manually create a similar view by setting a new view center about 70 feet from the near end of the girder. Using a macro allows the user to move the viewer radially and tangentially from an initial position, adjusting the Slice Plane Distance when necessary, without ever touching the mouse, except to set a new view center.

Let me know if there is any interest. If so, I'll try to get the macro in condition to post. 
« Last Edit: August 17, 2018, 02:18:40 PM by bdeck »

Lar

  • Hero Member
  • *****
  • Posts: 2815
Re: Yet Another 3D Viewer
« Reply #55 on: August 18, 2018, 05:45:16 PM »
You know you have my vote, bd. Anything that can help is very welcomed.


Attached is an example of dcad's rear cutting plane problem and the solution that I came up with, very effective but not a little work...

In the colored image (my working screen) you would notice that there is nothing behind the yellow (kitchen) cabinets at the left. This is what dcad decided should be cut away. In the black and white image (final sheet image) you would see the rest of the kitchen fully restored. This was achieved by making a "Save As 2D" of the kitchen, at the same view settings as the image, and placing the vector-entities at the image-plane, in front of the rest of the 3d model, then saving the final image. Not extremely easy to do but a lot easier than it sounds using with the tools I have at my disposal.


Lar

Dr PR

  • Hero Member
  • *****
  • Posts: 5611
Re: Yet Another 3D Viewer
« Reply #56 on: August 18, 2018, 10:45:07 PM »
bd,

I am interested also. One of my long term goals is to create walk-throughs of the ship model I have been working on for some time now. Because DesignCAD's display routines are so screwed up and extremely difficult to use I have always thought I would have to get another program.

Phil
DesignCAD user since 1987

bdeck

  • Hero Member
  • *****
  • Posts: 896
Re: Yet Another 3D Viewer
« Reply #57 on: August 20, 2018, 12:21:52 AM »
Phil, Lar:

Will post.

Lar,

A clever solution. Looks good.

I wonder how the kitchen would look if, after composing the view in OpenGL, you had used GDI hidden line mode to render it.

GDI's hidden line mode looks a bit rough on my laptop, compared to hardware hidden line mode. So I'm guessing that, as difficult as it might be,  your rendering method might be near perfection.

Too bad DC insists on changing zoom scale in some, as yet, unfathomable scheme whenever it changes view distance. (or slice plane distance). Currently the macro compensates approximately for this "feature". If one could divine the exact correlation, your method might succumb to automation as well. This would be a perfect application for a zoom factor sys() function, as requested by a poster here http://forum.designcadcommunity.com/index.php?topic=18.msg27#msg27 some 12years ago.  ;)

At least the macro now has finer zoom and distance control, so that it might make your image fitting task a bit easier.
   
Regards,
bd

PS: After trying Lar's method, I see that much of this post is not germane.
« Last Edit: August 20, 2018, 09:36:11 AM by bdeck »

bdeck

  • Hero Member
  • *****
  • Posts: 896
Re: Yet Another 3D Viewer
« Reply #58 on: August 20, 2018, 07:53:30 AM »
Hi Lar,

I tried your method and was surprised to discover that, when saving an OpenGL hidden line rendering as a DC 2D file (by typing s2 in the vdd macro), the rear cutting plane disappears, so that the 2D file shows the entire rendering (provided the front cutting plane is out of the way).

I had imagined that you were piecing together front and back vector files.

The attached image shows a vector file superimposed on a saved image of the shaded girder, in the manner I believe you described. Neither the vector nor the image required scaling when fitting them together, although fitting a precise vector to a lossy image is always a challenge, especially when fitting lines against dark colors.   

Still a pain, as you say, but not the pain I had imagined.
Thanks for the info,
bd

PS:  DC's "Display Geometry on Top of Images" view option needs some serious attention. 
« Last Edit: August 20, 2018, 09:06:10 AM by bdeck »

Lar

  • Hero Member
  • *****
  • Posts: 2815
Re: Yet Another 3D Viewer
« Reply #59 on: August 20, 2018, 09:39:14 AM »
BD,


Yes, SaveAs2D is not affected by the front or rear cutting planes. In fact, this is why my trick worked. My image is a "composite" of the vector entities from the SaveAs2D and the 3D model. The needed lines are extracted from the SaveAs2D file, then alighed in the model, anywhere between the 2 cutting planes. The final hidden line OpenGL image was saved at a height 4000 pixels (bigger side) to minimize jaggies. As you can see from my 2nd image above, the placing of the lines in the model has to be done with surgical precision so the final  saved image appears seamless (there are a few defects I left, for "artistic effect"  8) ). Dcad doesn't come packaged with the ability to surgically align vectors in a 3d model so a saved image appears seamless, but without dcad's built-in capabilities this surgery would not be possible. It's a case of "Dcad taketh away, Dcad giveth" - the cutting planes taketh away parts of the rendering, dcad's otherwise awesome workflow (basiccad, view settings manipulations, 3 selection handles, etc), allows an out-of-the-box thinker to come up with a usable solution.


 But it was a 2-generational problem/solution... I invented the LarCam a few years ago to solve the problem of reliably replicating any viewing angle, something Paper Space fell far short on. With the LarCam I can save any number of images of different settings and place the resulting 'referenced' images in a sheet file, outside of the still cumbersome paper space. If (more like "when") changes are made to the model I just select all the affected LarCams and run a macro that re-renders and re-saves those views. Just opening the sheet file updates all the changes. Unfortunately, this was the perfect scenario for those awful cutting planes to show their ugly faces. Fortunately, the presence of the LarCams provided the "shoulders" for the SaveAs2D solution to work on.


Funny thing is, if dcad's SaveAs2D files were as clean as dcad's OpenGL hidden line images then I would use the SaveAs2D instead of images, since jaggies would not be a concern.

Oh, I tried saving GDI images, but the hidden line was horrible, like I was in "noclip" mode (a game cheat code that allows you to pass through walls, where being in certain locations in the model would allow a view into many different rooms at once, a very weird experience), and the shaded GDI (I only tried Phong) was horribly bland.


Lar
ps: your composite image above makes a nice optical illusion: "Which is longer, the girder on the left or the girder on the right?", when in fact they are both exactly the same.
« Last Edit: August 20, 2018, 10:44:07 AM by Lar »