Hi guys,
I'm currently wondering how I could do this little trick. Converting the rotations of the perspective camera in a vector (giving me the direction of the camera).
I'm so dumb in maths that I can't figure it out. :poly136:
I already know how to get the camera values and how to play with vectors in Mel, but doing this conversion is the step where I block.
Replies
If so, in mel you can get this as follows:
[php]
// Get the worldspace transform of the "persp" camera (returns an array of 16 values)
float $TM[] = `xform -q -ws -matrix "persp"`;
// From that transform matrix the components of the Z rotation vector will be indexes 8, 9 and 10
float $vecZ[] = {$TM[8], $TM[9], $TM[10]};
// Since cameras in Maya face -Z you will want the inverse of that vector
float $camForwardVec[] = {-$vecZ[0], -$vecZ[1], -$vecZ[2]};
[/php]
Obviously that's written rather verbosely for clarity. You could inverse the values on the second line at the same time you grab them out of the matrix.
Hopefully that's of some use.
I have solved myself the problem by an other way :
Of course this solution only works if I use the persp camera. Your method will works with everything ! Thanks again !