PDA

View Full Version : camera aim vector?


apoc519
01-21-2006, 09:47 AM
quick question. How would I grab a cameras aim vector? I tried normalizing its rotation but that just doesnt seem to be working for me. Is there a more straight forward way?

My current expression looks like this. Although I'm pretty sure im way off base


//get cameras rotation
vector $camRot = <<persp.rotateX, persp.rotateY, persp.rotateZ>>;

//add rotation values
float $camRotTotal = abs($camRot.x) + abs($camRot.y) + abs($camRot.z);

//divide each axis by the total
vector $camAimNormalized = <<
$camRot.x / $camRotTotal,
$camRot.y / $camRotTotal,
$camRot.z / $camRotTotal>>;

Bryan Y
01-21-2006, 04:09 PM
Without answering your question directly, let me at least point out that the correct way to normalize a vector is this (if that is what you intended):

magnitude = sqrt( x * x + y * y + z * z );

x /= magnitude;
y /= magnitude;
z /= magnitude;

CGTalk Moderation
01-21-2006, 04:09 PM
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.