#### Archived

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

# Computing normals...

This topic is 6589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 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 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 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 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

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013612
×