Jump to content
  • Advertisement


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


Using a vertex normal to rotate a mesh

This topic is 5718 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
Here's the solution I came up with, including source code.

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.

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

Sign me up!