[Closed] Get/Move Perspective cameras position?
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…