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

Using a vertex normal to rotate a mesh

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