Jump to content
  • Advertisement
Sign in to follow this  
Belnazaar

Rotation problem (adjusting position)

This topic is 3430 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

The engine i am using forced me to have arms of player character separated from the body. So arm has some relative position from the origin point(0 0 0, i wouldn't be asking this if I could somehow change it) as you can see in this picture: http://img210.imageshack.us/my.php?image=36986427.jpg So i rotate the arm by 90 degrees on Y axis (rotation is done by Quaternions), and i get my arm in this position: http://img220.imageshack.us/my.php?image=16362906.jpg Then i adjust its position so it would be on its previous: http://img218.imageshack.us/my.php?image=40872131.jpg Then i set the Y rotation to 270 degrees and i set the X position offset to be negative: http://img151.imageshack.us/my.php?image=27940479.jpg I'm bad at this kind of math so could someone help me how to write formula for adjusting position according to the object rotation? Please i'm in really need of this.

Share this post


Link to post
Share on other sites
Advertisement
I have a couple of functions below that I think will serve your purpose.

They work out the relative X and Z positions at a given angle and distance to a 3D co-ordinate with respect to the Y-axis.

You just add the result to the current position of your character.


Functions:

float In_Game_Objects::circleObjectX(int distance, float angle)
{
return distance * sin(angleY + angle); //angleY is planes
//(characters)current y angle
}

float In_Game_Objects::circleObjectZ(int distance, float angle)
{
return distance * cos(angleY + angle);
}



How I use them:

camera1.posX = plane1.posX + plane1.circleObjectX(20, 0.0f);
camera1.posZ = plane1.posZ + plane1.circleObjectZ(20, 0.0f);

How you may use them:

rightArmX = character.posX + character.circleObjectX(5, 90.0f);
rightArmZ = character.posZ + character.circleObjectZ(5, 90.0f);

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!