LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

opengl rotation relative to the camera

I have been working with the OpenGL Functions in LabVIEW 8.2.  I figured out how to manipulate the model view matrix to move the camera around, and rotate it, but I can't seem to be able to work out how to perform translation and rotations of the camera relative to the camera's current position.  I can only seem to do this relative to the world coordinates.  I want to be able to explore a 3D image of a magnetic field that I have mapped, like in one of those first person video games, or flight simulators, but since all the camera motions are relative the the world coordinates, it gets confusing trying to control the camera.  I'm sure this is just a question of matrix manipulation, but I can't seem to figure out the math.  Has anyone solved this problem yet?

Thanks,
Jo-Jo
0 Kudos
Message 1 of 2
(2,978 Views)

"Jo-Jo" <x@no.email> wrote in message news:1168852207314-463638@exchange.ni.com...
I have been working with the OpenGL Functions in LabVIEW 8.2.&nbsp; I figured out how to manipulate the model view matrix to move the camera around, and rotate it, but I can't seem to be able to work out how to perform translation and rotations of the camera relative to the camera's current position.&nbsp; I can only seem to do this relative to the world coordinates.&nbsp; I want to be able to explore a 3D image of a magnetic field that I have mapped, like in one of those first person video games, or flight simulators, but since all the camera motions are relative the the world coordinates, it gets confusing trying to control the camera.&nbsp; I'm sure this is just a question of matrix manipulation, but I can't seem to figure out the math.&nbsp; Has anyone solved this problem yet? Thanks,Jo-Jo



I only looked at the OpenGL functions in LabVIEW breefly, but I used OpenGL a lot. Most of this should apply to LV as well.


In video games, they use quaternion to do the math. An easier alternative is to use euler angles, but they cause problems when you rotate over more then two angles. See http://en.wikipedia.org/wiki/Quaternion . It's not easy stuff, but the problem isn't easy.


Easiest would be to place the field object around (0,0,0). If it's a box with size (2,2,2), you put the object in a box from (-1,-1,-1) to (1,1,1). Then the calculation of the camera position will be easier, because you only have to worry about the angle of the camera.


If you only want to rotate around one axe, it's a lot easier. I always use the complex math functions, to set an angle and length, and then convert it to Re and Im to get two coordinates (the third is fixed). You can also include a third coordinate, if you normalise the resulting vector (devide by the length sqrt(x*x+y*y+z*z).


Regards,


Wiebe.


0 Kudos
Message 2 of 2
(2,977 Views)