• Advertisement
Sign in to follow this  

Rotating a mesh with normals

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

Suppose I have created a mesh with normals. When I rotate the mesh using the world transformation : rotationMatrix = rotate 5deg around y axis . SetTransform(WORLD, rotationMatrix); Are the normals are rotated as well ? if not how can I update the normals as well ? thx.

Share this post


Link to post
Share on other sites
Advertisement
mesh normals are inside the vertex declaration, so (almost) every operation performed on a vertex, modifies also the relative normal.

Of course this is not true if you're using a shader, but in your case, using the SetTransform function will rotate normals as well.

Anyway you can always try placing a light somewhere over your mesh and start rotating the mesh... if the illumination is correct, you've done it ^__^'

Share this post


Link to post
Share on other sites
just be careful when scaling the mesh though, as the normals will shrink along with it, and the mesh will appear to be lit brighter. There is some line of code (cant remember what exactly) that will prevent your normals from scaling.

Share this post


Link to post
Share on other sites
If your mesh is transformed by a matrix M, then your normals need to be transformed by the inverse transpose matrix of M. Otherwise, for instance when M contains scaling along one direction, your normals will not be perpendicular to the surface anymore.

See at the images here:
http://www.gignews.com/realtime020100.htm

Share this post


Link to post
Share on other sites
If you're using the fixed-function SetTransform() method then it'll handle it for you. The only gotcha is if your world transform has a scaling component - in which case D3DRS_NORMALIZENORMALS = TRUE should sort you out.

If you're using a vertex shader then follow nmi's advice.

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement