Applying camera and layer matrices
Applying camera and layer matrices
- Subject: Applying camera and layer matrices
- From: "Bret Battey" <email@hidden>
- Date: Sat, 2 Jan 2010 14:35:09 -0000
- Thread-topic: Applying camera and layer matrices
Title: Applying camera and layer matrices
I'm trying to implement a plugin which uses OpenGL to draw in 3D space. I would like to be able to maneuver a camera in that 3D space, and I would like to use Motion's camera controls to do so. I assumed it would be fairly straightforward to use Fx3DAPI to achieve this, but I'm only getting partway there.
Assumption: in Motion, I use the plugin 2D mode rather than 3D, since I'm really using it as a viewport into a 3D scene, and it is the 3D scene, not the viewport, that I want to manipulate with the camera controls.
>From comments already made to this list, I think I understand that:
* in 2D mode, the camera will be positioned at a z position of 0
* if using gluPerspective, I have to derive the camera field of view from focalLengthAtTime using
180/PI * 2 * atan( 36 / (2*cameraFocalLength))
>From here, I am partway to a solution, simply via:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(cameraFieldOfView, inWidth/inHeight, 0.0001, 10000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMultMatrixd(cameraMatrixData) ;
glTranslated (0, 0, -((inWidth+inHeight)/2)); // move model an appropriate distance from the camera
But this seems to only be effectively supporting camera rotation. Other types of camera motion either do nothing or cause strange clipping-plane activations.
And it begs the question of what to do (if anything) with the Layer Matrix Data. If I multiply in the layer matrix at any point after the move to the modelview, it causes very strange behaviors which clearly aren't in the correct direction. I've also tried (desperately) applying the inverse of the layer matrix.
Sorry if I'm missing something obvious, here.
Of course, the answer may be that I am foolish to try to use the Motion camera controls for this and really should put my own camera controls in the plugin... (?)
Thanks,
-=Bret Battey
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden