Jump to content
  • Advertisement

Archived

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

kieren_j

Normals

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

Hi, just a quick question - when loading 3d files into D3DVERTEX structures, how can I work out the normals? thx !

Share this post


Link to post
Share on other sites
Advertisement
Some fileformats (e.g. 3DS) contain the normals so no extra processing is needed. For those that don''t, you''ll have to compute the normals yourself.

A normal to a triangle is computed by taking the crossproduct of two of its edges and then normalizing it.

If you want smooth shading you''ll need to do some averaging of normals of neighboring triangles. For this you''ll will need to know which triangles that are connected to each other. The connections are found by searching for triangles that share vertices.

Share this post


Link to post
Share on other sites
If you want to calculate the normal for a single triangle, you can do it as follows:

Normal = Normalize(CrossProduct(V1 - V0, V2 - V0))

This might help, then again, it might not

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!