## Surface/Vertice Normals and Scene Placement

Jones
Unregistered

Post: #1
I was just working on some Terrain generation code, and was about to start writing in some code to calculate surface/vertice normals. I was just reviewing some of the stuff I know about normals in my head when a little voice inside of me said...

"The vectors are based around the origin... objects move!"

Oh. It's true, objects move around the origin, as does the origin itself (in a sense).

So I said to myself... well, for my MD2s it's not so bad. I'll just use the precalc'd ones for for now, but what If I wanted to load a map or terrain and position it somewhere *other* than the origin? What if it had to *gasp* move?

Would I have to recalculate the surface normals every time the surface/meshes moved?

Or am I thinking about this wrong? Wait a minute... does the position of the object in question even matter?

Argh... brain block. Someone slap me please.
Moderator
Posts: 529
Joined: 2003.03
Post: #2
Normals would only change if the mesh rotated or was scaled unevenly (more on one axis than the others.)

"Yes, well, that's the sort of blinkered, Philistine pig-ignorance I've come to expect from you non-creative garbage."
Jones
Unregistered

Post: #3
Leisure Suit Lurie Wrote:Normals would only change if the mesh rotated or was scaled unevenly (more on one axis than the others.)

Today is not a healthy-brain day for me.
Member
Posts: 63
Joined: 2005.12
Post: #4
To elaborate a bit, normals are invariant under translation (as LSL indicated), and for other transforms (such as rotation and scaling) can be transformed by applying the inverse transpose of the original matrix. For pure rotation the inverse transpose is the same as the original matrix, which simplifies things somewhat. Also, depending on what type of transform you need to apply, and how often, there are shortcuts you can take to speed things up a bit.

Depending on what you need the transformed normals for, it also may be that they needn't be transformed at all. For example, lighting calculations can be performed in local model space, eliminating the need for transformation of the model's geometry.