y-axis rotation of camera match object

Started by
2 comments, last by nlo 18 years, 10 months ago
I am trying to get the y-axis rotation of the camera to correspond with the rotation of an object; the object is aligned with the camera on its front vector does anyone have any suggestions/help on how to do this; so it rotates correctly? I have a y-axis based rotation I use for the camera; its stored as a float, but that doesn't seem to help. I tried setting that to the rotation of the object and it kinda would spin fast as I turned right and slow back down if I turned left. [Edited by - DevLiquidKnight on June 17, 2005 10:17:12 PM]
Advertisement
If I understood correctly, what you are trying to do is:
object.rotation.y = camera.rotation.y + PI;
No, that didn't work basically im trying to make the camera itself be a 3rd person camera view.
according to Game Programming Gems 2, there is an article about "Mario 64", a 3rd person control.

u need 3 direction vectors, camera's front vec, right vec & input's dir vec, 1st an alternative normalized camera front vec :
vDir.x=cam->front.x;vDir.y=0;vDir.z=cam->front.z;normalize(vDir,vDir);

2nd, an alternative normalized camera right vec :
vRight.x=cam->right.x;vRight.y=0;vRight.z=cam->right.z;normalize(vRight,vRight);


then the input dir vec, assume up(y)=1, down(y)=-1, left(x)=-1, right(x)=1. Normalize it also.

so the final Direction Vector for character is :
final.x=(input.x * vRight.x) + (input.y * vDir.x);final.y=0;final.z=(input.x * vRight.z) + (input.y * vDir.z);normalize(final,final);


then if u need the Y-radius of the final vector, do the following:
radius=-atan(final.z/final.x);if (final.x>0.0f)  radius-=D3D_HALFPI;else  radius+=D3D_HALFPI;

This topic is closed to new replies.

Advertisement