Jump to content
  • Advertisement

Archived

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

ramses

Computing normals...

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

I have some maths notions like vectorial product(v^v'') to have an orthogonal vector, but how can i apply that to normal calculation... (i only loaded models with pre-calculated normals and i want to go one step ahead) THx for any help/links Ramses Da Funky pharao

Share this post


Link to post
Share on other sites
Advertisement
Take the cross (vector) product of two vectors in your plane, then normalise it to get the plane normal.

nx = y1.z2 - z1.y2
ny = z1.x2 - x1.z2
nz = x1.y2 - y1.x2

Then divide each of nx,ny,nz by sqrt(nx^2 + ny^2 + nz^2)

Share this post


Link to post
Share on other sites
)
Sorry for not having explained myself better
i know how to calculate the cross product,
but how should i build my vectors from my vertex list?
(i''d like to have per-vertex normals)

Share this post


Link to post
Share on other sites
Say you want the normal of a triangle. You know all three points on the triange.

Points are A,B and C (clockwise)

Vector1 (x1,y1,z1) is C-B
Vector2 (x2,y2,z2) is A-B

Calculate all the normals for each polygon, then the normal for a vertex is the average of all the normals of the polygons connected to that vertex.

Share this post


Link to post
Share on other sites
We do about the same thing, but we keep track of the vertex normal for all three vertices of a face. This allows us to use smoothing groups, where two connected faces will shade quite differently, if they do not belong to the same smoothing group. i.e. two faces have a common vertex, but do not have the same vertex normal for that vertex.

I seem to recall a discussion some time ago on vertex normals. Didn't that discussion bring into the average of the vertex normals the different sizes of the faces?

Edited by - Antknei on December 1, 2000 11:03:11 AM

Share this post


Link to post
Share on other sites
Thanks guys, my models look much better now
Since i''m only at the begining of my loader, i''ll use one normal per vertex. but keeping somewhere normals for vertex for each face might be useful in a near future...
Thx
Ramses

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!