10-22-2013 02:29 PM
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
Solved! Go to Solution.
10-22-2013 02:44 PM
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.)
10-22-2013 04:18 PM
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.
10-22-2013 04:48 PM
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,
11-01-2013 12:01 PM
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.
11-01-2013 01:04 PM
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,
11-01-2013 04:29 PM
Tom,
I used the trick of rotating the object and then auto-focussing, and it works! Thanks a lot!
11-01-2013 04:40 PM
Glad to help!
3D scene controls are always fun to work with - or maybe that's just me.
Regards,