Vertice Normals

Started by
1 comment, last by coder240 22 years, 10 months ago
I''ve currently got a bunch of triangles in a triangle list that are created by my application in order to build a small landscape. Is there any quick and easy helper function that I can use to get the plane normal or do I have to do it myself? Anyone know any decent sample code I could look at? Thanks! ~coder239
Advertisement
There''s no helper functions that I know of for finding the normal to a plane, but it''s very easy, really. Just take three points on the plane, X1, X2 and X3. The normal is:

  normal = (X2 - X1) x (X3 - X1)  


(where "x" denotes the cross product)

If you''re looking for a vertex normal, then you can just average the normals for each face attached to the vertex. It''s quite simple, and the only case where it doesn''t work is if the faces are of different sizes (IIRC), which is unlikely (or fairly negligable) in a landscape engine that uses a heightfield for the terrain.

War Worlds - A 3D Real-Time Strategy game in development.
Cheers! That was the method I orginally used (which I stole from the maths text book) only I thought it was really iffy. Clearly not!

War Worlds looks pretty cool too. Good luck with that. Perhaps you might take a look at www.vbdomain.co.uk

At the time of writing it''s due for an update but I''m in exam hell at the moment so coding has gone out the window!

This topic is closed to new replies.

Advertisement