View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Normals

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

9 replies to this topic

### #1Anonymous Poster_Anonymous Poster_*  Guests

Posted 31 August 1999 - 10:00 PM

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

### #2Khawk  Senior Staff

Posted 10 August 1999 - 02:36 PM

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).]

### #3Anonymous Poster_Anonymous Poster_*  Guests

Posted 10 August 1999 - 04:25 PM

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)

### #4Khawk  Senior Staff

Posted 10 August 1999 - 04:47 PM

Thank you for the correction.

Khawk

### #5Anonymous Poster_Anonymous Poster_*  Guests

Posted 27 August 1999 - 07:51 AM

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.

### #6Anonymous Poster_Anonymous Poster_*  Guests

Posted 31 August 1999 - 07:24 PM

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?

### #7Anonymous Poster_Anonymous Poster_*  Guests

Posted 31 August 1999 - 07:26 PM

Oops I meant "all faces that connect to that vertex".

### #8CodeDemon  Members

Posted 31 August 1999 - 08:59 PM

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.

### #9INVERSED  Members

Posted 31 August 1999 - 09:02 PM

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

### #10Sengir  Members

Posted 31 August 1999 - 10:00 PM

if you change the direction of vertex definition the direction of the normal is changed, too.

Sengir

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.