PSlayer
PSlayer

Reputation: 61

How to get the Camera direction vector?

I need to know the direction that a giving camera is looking at but i can't find a way to get it.Is there a way to get some kind of vector that tells which direction the camera is pointing to(just like there is an up vector telling the camera's up direction)?

Upvotes: 0

Views: 1488

Answers (2)

theodox
theodox

Reputation: 12208

You can also get the camera's worldMatrix using xform. The 3rd row of the camera matrix is the reverse of the camera vector

camera_z = cmds.xform("persp", q=True,m=True, ws=True)[8:11]
forward = [i * -1 for i in camera_z]

Upvotes: 2

Ari Gold
Ari Gold

Reputation: 1548

camera is looking on

centerOfInterest = cmds.camera(cameraShape, q=True, centerOfInterest=True)

camera world up vector

worldUp = cmds.camera(cameraShape, q=True, worldUp=True)

check the camera docu

Upvotes: 0

Related Questions