LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3D Picture Control Orthographic View zoom - Camera Set up?

Solved!
Go to solution

I am trying to display two 3D picture controls.  One displays some objects in 3D (Auto Projection: Perspective, Camera Controller: Spherical).  This 3D image works great and I am having no problems with it.  The other Picture Contol is meant to simulate a 2D image of the 3D object, essentially a Plan View.  To do this I made a 3D picture control with a Orthographic view.  I set the camera to view from above (z-axis) and set the target to be positive y-axis. 

I have attached an example vi (labview 2013 SP1) that creates some simple 3D objects and displays them in Perspective and Orthographic using the same Camera Position.  On initial start, the Orthographic image is zoomed in heavily. If I manually zoom it (Hold Shift button and mouse up or down), then the Orthographic image will set itself to the correct Camera position.  This is essentially the solution to my problem, but I can't assume the user will have the ability to manually zoom the image.  So I need to set it programmatically.

If you manual adjust the view on either screen (rotate and zoom), then click the Set Camera button, both images will give a plan view, but only the Perspective Image will be at the correct camera zoom or distance.  The Orthographic stays at the last zoom distance.

Is there any way to set the Camera distance for Orthographic projection programmatically?   I have tried starting with the 3D picture control as perspective, set the camera distance and then changing it to orthographic, but this still results in a zoomed orthographic image.  From the reading I have done, I think I am trying to the impossible.  Does any one have another suggestion to get the same result.  I have previously used the 2D picture functions to generate the image but found that method inefficient. 

And suggestions would be great.

Thanks

Relec

Message 1 of 6
(5,423 Views)
Solution
Accepted by topic author Relec

Hi Relec,

thank you (and Kudos) for that inspiring demo!

Took me while to work it out, but I might have found something that could help us with the orthographic projection.

Sometime back someone posted a way to collect the current Camera data. Sorry I lost the source. But here is my version as a Get3DCameraPosition.vi using the ModelViewMatrix.

Unfortunatly this doesn't return the current Target and so a bit of guessing in the right Direction is necessary.

I'm impressed you found a way to make the Shift-Drag Zoom-movement possible on the orthographic window.

It seems a whole thread at http://forums.ni.com/t5/LabVIEW/3D-Picture-Control-Doesn-t-Zoom-in-Orthographic-Mode/td-p/1544460/p... wasn't able to find that out.

In the meantime I've found a way using the ProjectionMatrix to create a zoom-effect which I build into your demo using the mouse wheel.

All in all I've tried to translate camera movements from the perspective window in the ortho - assuming this is what you were after?!

Again the missing target information doesn't make it quite right.

Regs

  Jannis

Download All
Message 2 of 6
(5,081 Views)

Thanks Jannis.

The Set Projection and Zoom features are exactly what I needed.  Your timing is perfect too.  It was a 9 month project that goes out the door on Friday.  I can now remove the shaming "While holding Shift, Left click the mouse and slide down on Cursor to zoom out."  comment in the middle of the GUI.  Thanks for the Open GL Projection link, I will try to digest that and setting the projections when I have a little more time.

Cheers

Relec.

0 Kudos
Message 3 of 6
(5,034 Views)

🙂

 

btw, the original post about the Camera Position is from https://lavag.org/topic/12560-3d-camera-orientation/

and for the quick readers, the suggested reading about the ProjectionMatrix is at http://www.songho.ca/opengl/gl_projectionmatrix.html

 

Jannis

0 Kudos
Message 4 of 6
(5,020 Views)

Thanks, Jannis, for posting that VI for finding the camera position from the model matrix, I've been looking for that for a while!  From the VI, I understand that the "direction" output is not the same as the Target position we might set for the camera, but it appears when playing with this, that the "Up" vector is also not the same as the Up direction we might set the camera to.  Or, at least I've had it output a different up vector than what I set the camera to.  Do you know if there's a way to obtain the correct Up direction?

0 Kudos
Message 5 of 6
(4,589 Views)

Hello ace88,

not quite sure I understand your problem.

As you are aware, the ModelViewMatrix works with unity vectors. So my demo Vi also exports the unity vector for the Up Direction.

If you supply the LV "Setup Camera"-method with a non unity vector, Open GL will automatically adjust that and of course return the normed vector in the same direction.

Now, why would you want to manually set the Up Direction? My goal usually is to analyze the current scene as displayed, memorize the position and to a later point in time restore the saved view. This seems to work fine with a modified version of the above Vi. I have included a "Target" output.

If you desire to create a "fly through" of your scene, I suggest you continuously record the camera position using the Get3DCameraPosition.vi while mouse controlling through your scene. Later use the stored data to supply  the "Setup Camera"-method.

Message 6 of 6
(4,575 Views)