PDA

View Full Version : Get/Move Perspective cameras position?


thatoneguy
02-03-2008, 02:18 AM
Is there a way move the current perspective viewport through a script? Is the perspective view actually a hidden target camera that can be accessed like the root scene node or a group's parent gizmo?

Bobo
02-03-2008, 07:17 AM
Is there a way move the current perspective viewport through a script? Is the perspective view actually a hidden target camera that can be accessed like the root scene node or a group's parent gizmo?

Nope, a perspective viewport is not a camera, but it has a transform matrix and FOV value, so you can manipulate these as of it were a camera. See viewport.GetTM() and viewport.setTM() methods for getting and setting the matrix. The TM is equivalent to 'inverse $Camera01.transform', so you can set a viewport to match an existing camera by setting the TM to the inverse of the .transform of the camera, then set the FOV, too.

For example:
aCamera = $Camera01
viewport.setTM (inverse aCamera.transform)
viewport.setFOV aCamera.fov

You can of course transform the view as you want using matrix operations. The viewer's position could be acquired by using (inverse (viewport.getTM())).row4 and so on...

CGTalk Moderation
02-03-2008, 07:17 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.