getting camera transform? SOLVED

   5743   2   0
User Avatar
Member
976 posts
Joined: 4月 2017
Offline
Hi!

I found a cool vex script to get the matrix of a camera but I can't get it to work.

http://andy.moonbase.net/archives/1397 [andy.moonbase.net]

vector @cdir;
vector @raydir;
 
matrix camMatrix = optransform(chs("camera")); 
//get a matrix with the camera's transforms.
 
@cdir = cracktransform(0, 0, 0, {0,0,0}, camMatrix);
//extract out the camera position as a vector
 
@raydir = normalize(@P-@cdir);
//get a vector to project pointo from camera

…In the “Camera” channel, I placed “/obj/Cam_01” and set my wrangle to detail but I'm not getting any values. Am I missing something?

-Olivier
Edited by olivierth - 2020年8月18日 19:24:51

Attachments:
Houdini_get_Cam_tranform.JPG (101.1 KB)

User Avatar
Member
976 posts
Joined: 4月 2017
Offline
Ok, not sure what I did wrong but I fixed it. I had changed the name of a vector to make it more friendly and it broke something. I copy/pasted the script without edits and it now works.

-Olivier
User Avatar
Member
4 posts
Joined: 3月 2012
Offline
I'm glad it helped I'm pretty sure there's a more direct or cleaner way to get the camera position, if anyone knows a better trick let us know, in the meantime at least this gets the job done, cheers. - AM
  • Quick Links