Surface/Vertice Normals and Scene Placement

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? Blink

Argh... brain block. Someone slap me please.
Quote this message in a reply
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."
Quote this message in a reply
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.)

Ahh, thanks for freeing me of that worry. Grin

Today is not a healthy-brain day for me. Rasp
Quote this message in a reply
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  texture no square surface kendric 7 8,329 Mar 20, 2009 05:26 PM
Last Post: kendric
  surface rendering from data points mc1961 6 8,390 Nov 15, 2007 03:37 PM
Last Post: TomorrowPlusX
  Trouble turning an SDL surface into an OpenGL texture Joseph Duchesne 4 8,015 May 22, 2007 05:14 PM
Last Post: Joseph Duchesne
  glNormal - Surface/Vertex normals Jones 19 20,101 Jul 18, 2006 12:45 PM
Last Post: imikedaman
  Getting surface x & y coords? Jones 4 5,109 May 7, 2006 04:29 PM
Last Post: Jones