Jump to content
  • Advertisement
Sign in to follow this  
DevLiquidKnight

y-axis rotation of camera match object

This topic is 4721 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
If I understood correctly, what you are trying to do is:
object.rotation.y = camera.rotation.y + PI;

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!