#### Archived

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

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

## 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 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]

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
17
5. 5

• 9
• 12
• 9
• 33
• 13
• ### Forum Statistics

• Total Topics
632593
• Total Posts
3007269

×