Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

lifebane

Using a vertex normal to rotate a mesh

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

Howdy all! I''ve a character mesh with 16 frames(meshes) of walk animation and a single sword mesh translated to a vertex on the character meshes hand. I''d like to rotate the sword mesh based on the normal of the hand vertex I''ve attached to so that the sword always stays in the grip of the character meshes hand as its arms swing. So far, I''ve tried the following, but it doesn''t seem to rotate right. It''s attached to the hand, but the rotation is way off. double distX=pow( pVert->x - pVert->nx, 2.0f ); double distY=pow( pVert->y - pVert->ny, 2.0f ); double distZ=pow( pVert->z - pVert->nz, 2.0f ); double distance=sqrt( distX + distY + distZ ); handRotation.x=(float)asin( (pVert->x - pVert->nx)/distance ); handRotation.y=(float)asin( (pVert->y - pVert->ny)/distance ); handRotation.z=(float)asin( (pVert->z - pVert->nz)/distance ); Any ideas? Thanks! LB

Share this post


Link to post
Share on other sites
Advertisement
Here's the solution I came up with, including source code.
http://www.gamedev.net/community/forums/topic.asp?topic_id=120132

Jack Harmon


[edited by - Lifebane on October 23, 2002 6:02:59 PM]

Share this post


Link to post
Share on other sites

  • 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!