Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

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


Sign up now

Normals

4: Adsense

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.


  • You cannot reply to this topic
9 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

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


#2 Khawk   Senior Staff   

2505
Like
Likes
Like

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


#3 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

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)


#4 Khawk   Senior Staff   

2505
Like
Likes
Like

Posted 10 August 1999 - 04:47 PM

Thank you for the correction.

Khawk


#5 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

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.


#6 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

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?

#7 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

Posted 31 August 1999 - 07:26 PM

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

#8 CodeDemon   Members   

363
Like
Likes
Like

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.

#9 INVERSED   Members   

172
Like
Likes
Like

Posted 31 August 1999 - 09:02 PM

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

#10 Sengir   Members   

122
Like
Likes
Like

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.