LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ModelViewMatrix property of 3D picture control

Can someone explain how this property works? What are the values of the elements of the array? I would like to control the view of a 3D scene in the picture control programmatically, and this seems like a candidate to let me do it. I can manually configure my scene, and then save the output of this property. Later, if I apply the saved value back to the property, it will correctly reposition my scene, but it somehow messes up the manual control of the scene. Rotation seems to work, but it is as if the centerpoint of the rotation is somewhere way off screen (in spherical control). Zooming no longer works, and panning is doing something really odd.

 

My end goal is to smoothly rotate and translate the camera to the desired location (fly in to look at a specific target).

 

1) Is ModelViewMatrix a good way to go about doing this?

2) What's going on with the camera controls?

 

btw, I'm using LabVIEW 2010.

 

Thanks,

Chris

0 Kudos
Message 1 of 7
(3,372 Views)

Chris,

The ModelView Matrix property reads or writes a matrix that contains the translation, rotation, and scale values for the 3D scene that appears in the scene window.

Here is a table of characteristics:

Data type
Permissions Write In Edit Only
Available in Run-Time Engine Yes
Available in Real-Time Operating System No
Settable when the VI is running Yes
Loads the front panel into memory No
Need to authenticate before use No
Loads the block diagram into memory No
Remote access disallowed No
Must wait until user interface is idle No
Available with control VIs No
Available with global VIs No
Available with strict type definitions No
Available with polymorphic VIs No

 

Are you having trouble finding the position of the camera? You can use the ModelView Matrix property node to find it. The 3D picture controls in LabVIEW are based on OpenGL API.  In the OpenGL API, the camera's location is always at coordinates 0,0,0 in the eye-space. In order to find the camera location in the object space, you need to turn the eye-space coordinates into a vector, [0 0 0 1], and multiply it by the inverse of the ModelView Matrix. First you need to place the ModelView Matrix property node on your block diagram.  Inverse the matrix using the 'Inverse Matrix' function.  After this you should multiply by a constant matrix of [0 0 0 1] using the 'A x B' function.

 

Could you post your code?

Jordan

Message 2 of 7
(3,362 Views)

Thanks, this was helpful. I didn't end up using the ModelViewMatrix for anything other than determining the current camera location using the technique you suggested. Instead, I'm using the Setup Camera method on the SceneGraphDisplay. I noticed this was used in the solar system example. It seems like it would be a good idea to have a property on this that returns the current camera position (as well as the target and up direction).

 

This means that I didn't experiment with writing to the modelviewmatrix anymore, so I don't know if that goofyness I experienced earlier is still there, but it is moot now.

 

Thanks,

Chris

0 Kudos
Message 3 of 7
(3,355 Views)

I zipped up the example I was experimenting with. This includes a stripped down version of the solar system example. I buillt an action engine that allows me to move the camera smoothly. There are three actions that need to be called: 1) Init -- this sets up the initial state of the camera, 2) Configure Move -- this sets the end location of the camera and the time you'd like it to take to get there, 3) Execute Move -- normally, this does nothing, but after a Configure Move it will execute the move (this should be called frequently to nicely animate the move).

 

This makes a smooth move from the current location to a final destination. After doing this, I realized that it wouldn't be too hard to execute a sequence of moves smoothly, but that is another exercise. Also, this sets the target and up direction in the init case, but these are not updated at all during the move. That isn't usually a problem, but it wouldn't be too hard to make it smootly change targets instead of, or in addition to moving the camera.

 

any feedback would be appreciated.

Chris

 

Screenshot.png

Message 4 of 7
(3,352 Views)

So now I'm working on incorporating a change of camera target. Again, while it is easy enough to set the target, I don't see any obvious way to retrieve this information. I can see the ModelView Matrix changing as the target is changed, but the relationship is not obvious to me. How can I calculate the camera target from the ModelView Matrix?

 

Thanks,

Chris

0 Kudos
Message 5 of 7
(3,289 Views)

Hi Chris,

 

I want to clarify what you're hoping to achieve by changing the camera target.  I'm assuming you want to follow a different sphere in the window, but I want to verify whether you're wanting to dynamically acquire the location and follow a sphere or dead reckon to a point in space?  I think that we may be able to acquire the position of the sphere using a method node with the Transformation>Get Translation method.  Then we should be able to feed that into the Move Camera subvi to update the target dynamically, I'd think.

 

Keep us posted!

 

Regards,

 

-Dave C

Applications Engineer
National Instruments
0 Kudos
Message 6 of 7
(3,274 Views)

I was able to get my project working. Unfortunately, I don't have feedback on the camera target exactly, but I am effectively moving the target open loop. I have to keep track of where I told it to be. I would prefer to be able to read the camera target (like I can with camera position), but I see that the target is just one point on a line drawn from the camera to the target. There are actually an infinite number of targets that could be used to direct the camera along the same path.

 

As a result, the easiest way to do it is to disable manual rotation of the scene, but that is okay in my application. I found an example demonstrating how to extract the direction vector from the modelviewmatrix, and I can create an arbitrary point along a direction vector, so there is some feedback, it's just not ideal.

 

This probably sounds very confusing. Here is a summary of my application. I have a 3D model of a system with multiple components. I am making a slick gui that allows the operator to select a component, and I bring that component front-and-center in the scene. I didn't want to have parts snapping around the screen though, so I seemlessly move the camera from one location to another within the model. Originally, I worked on moving the camera. Now, I have incorporated smooth changes of the camera target and up direction. The end result is a pretty slick animiation of flying around the model with dynamically updated components.

 

The solar system model was just for demonstration purposes. I actually don't have any moving objects in my application, so I'm not trying to track something that is moving. If I was doing that, Get Transformation called in a loop would probably be an appropriate way to get a new target and update the camera target. Smoothly moving the camera to something that is moving would be a little more complicated. 

 

Thanks,

Chris

Message 7 of 7
(3,265 Views)