Archived

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

Normals

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

Recommended Posts

Normals are computed as the cross product between two vectors. So...

given two vectors u = (u_x, u_y, u_z)
and v = (v_x, v_y, v_z)

u x v = n <-- the normal vector

n_x = (u_y * v_z) - (u_z * v_y)
n_y = (u_x * v_z) - (u_z * v_x)
n_z = (u_x * v_y) - (u_y * v_x)

where n = (n_x, n_y, n_z)

There's the equation. Hopefully I got that right.

Khawk

-----
I edited the post since some of it was missing because the board thought I was doing html.

[This message has been edited by Khawk (edited August 10, 1999).]

Share on other sites
The cross product equation posted is incorrect. It should read:

N.x = (U.y * V.z) - (U.z * V.y)
N.y = (U.z * V.x) - (U.x * V.z)
N.z = (U.x * V.y) - (U.y * V.x)

Share on other sites
Thank you for the correction.

Khawk

Share on other sites
The bloke above was not wrong, both equations are correct depending upon the orientation of your world.

The second answer given is the "proper maths" way to do it, but the first answer given is actually the most widely used in graphics programming.

Fool.

Share on other sites
That's easy for finding face normals, but what about vertex normals? I guess you could do like a weighted average of the face normals for all faces that connect to that normal, but damn that would be a p.i.t.a. Is there an easy way?

Share on other sites
Oops I meant "all faces that connect to that vertex".

Share on other sites
Unfortunately, that is the only way. However, if you precompute these at startup or whatever, and then translate them using the inverse matrix method - it shouldn't be a problem.

Share on other sites
If you're doing face normals for polygons, does it matter wether they are clockwise or CCW?

Share on other sites
Does anybody have any good algorithms or formulas or anything for calculating normals?

I was using the Microsoft writtine function CalculateNormals() which comes with the XFile example on the SDK CD. It's good, but not good enough.

Anyone else have any better ideas?

Thanks.

-Snowman

Share on other sites
if you change the direction of vertex definition the direction of the normal is changed, too.

Sengir

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 13
• 19
• 14
• 9
• Forum Statistics

• Total Topics
632940
• Total Posts
3009328
• Who's Online (See full list)

There are no registered users currently online

×

Important Information

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!