Archived

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

lifebane

Using a vertex normal to rotate a mesh

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.
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