LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3D Picture View Orientation

Solved!
Go to solution

I'm trying to program buttons to give me the top, right, and front view of a 3D picture, similar to the XY, XZ, and YZ plot options for 3D surface. I think the idea is to manipulate the ModelViewMatrix property of the 3D picture. However it seems that doing so disables the pan and zoom options, even though I'm only manipulating the rotation part of the matrix. Does anyone have any idea why this is happening? Or if there is a better way to get these views, please let me know.

 

Thanks

 

3DPictureProjection.JPG

0 Kudos
Message 1 of 8
(4,754 Views)

Hello SoheyIV,

 

In the past I've used the Setup Camera method to position the view in a scene as needed:

 

Setup Camera Method

http://zone.ni.com/reference/en-XX/help/371361K-01/lvprop/scenewindow_setup_camera/

 

You'll also need to redraw the image once that's been set, but it looks like you're already doing that.

 

Tip- it doesn't appear that you currently have any timing control in your loop; I'd strongly recommend that you introduce a wait function to limit the refreshes to a reasonable rate (10-100 Hz, depending on what your refresh requirements are.)

Tom L.
0 Kudos
Message 2 of 8
(4,751 Views)

Thank you 0utlaw. I used the Setup Camera method to change the view, and it works. However, the obtained view is really focussed on a small portion of the model. Is there any way to create a view similar to the one created by autofocus, but showing a different orientation? I think it should be doable using the inputs for the Setup Camera but I'm not sure.

 

Setup Camera.JPG

0 Kudos
Message 3 of 8
(4,738 Views)

Hi SoheyIV,

 

To make the view "larger", you just need to move the camera further away from the target.  It looks like you're currently located at [0,-1,0] and pointed at the origin - try [0,-2,0] or [0,-10,0].  Think of the camera location as a point from which you are viewing the scene.  A simple way to modify the apparent zoom level is to move the camera closer to or further away from the target.

 

Regards,

Tom L.
Message 4 of 8
(4,731 Views)

But is there any way to calculate the camera position to make everything fit in the 3D picture (zoom to fit)? Autofocus method somehow does this, but always sets the view to (-x,+y,-z) view. 

0 Kudos
Message 5 of 8
(4,689 Views)
Solution
Accepted by topic author SoheylV

Hello Sohey,

 

I imagine you could calculate this- you'd need to know the size of the Front Panel control and the dimensions of the object(s) in the scene.  I believe the default view port has a 90 degree field of view, so it should be fairly straightforward to calculate the camera distance required to capture all of the objects in the scene.  It gets messier fast if things are moving around, though- are these dynamic or static objects?  Are there multiple objects in the scene?  If you're just attempting to view a single object located at the origin, it may actually be easier to rotate the object and use the auto-focus rather than trying to calculate the camera position required.

 

Regards,

Tom L.
Message 6 of 8
(4,679 Views)

Tom,

 

I used the trick of rotating the object and then auto-focussing, and it works! Thanks a lot!

Message 7 of 8
(4,670 Views)

Glad to help!  

 

3D scene controls are always fun to work with - or maybe that's just me.

 

Regards, 

Tom L.
0 Kudos
Message 8 of 8
(4,666 Views)