Skip to main content
GameDev.net gamedev.net
🔒 Locked

Computing normals...

Started by ramses Dec 1, 2000 at 9:21 AM 4 replies 300+ views
Original Post
ramses
ramses
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
"I write messages on money. It's my own form of social protest. A letter printed on paper that no one will destroy. passed indiscriminately across race, class and gender lines and written in the blood that keeps the beast alive. A quiet little hijacking on the way to the check-out counter. And a federal crime." Zack de la Rocha in Renegades.
TwoFlower
TwoFlower
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)
ramses
ramses
)
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)
"I write messages on money. It's my own form of social protest. A letter printed on paper that no one will destroy. passed indiscriminately across race, class and gender lines and written in the blood that keeps the beast alive. A quiet little hijacking on the way to the check-out counter. And a federal crime." Zack de la Rocha in Renegades.
TwoFlower
TwoFlower
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.
Antknei
Antknei
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
ramses
ramses
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
"I write messages on money. It's my own form of social protest. A letter printed on paper that no one will destroy. passed indiscriminately across race, class and gender lines and written in the blood that keeps the beast alive. A quiet little hijacking on the way to the check-out counter. And a federal crime." Zack de la Rocha in Renegades.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.