• FEATURED

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.

# surface normal problem

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.

6 replies to this topic

### #1neoGriff  Members

Posted 02 March 2000 - 11:48 AM

I have a problem in my 3d engine that I was wondering if someone could help me with. I can create the normal to a polygon and store it with the rest of the points. This way I can transform it along with the points. The problem is when I rotate and translate the polygons, the normal is not a unit mormal anymore with respect to the origin. I''m not sure how everyone else can get this lighting thing to work and I can''t. I would be grateful for some help. Thanks. Mike Griffin griff14@hotmail.com

### #2alexmoura  Members

Posted 03 March 2000 - 02:34 AM

Mmmm, I'm no expert, but I think you'll have to store it as two points and subtract them to get the normal(If you scale the objects, you'll have to normalize the normal ).
The way you're doing it, any transforming except rotation you do will distort it (I think)(therefore I am.)

Edited by - alexmoura on 3/3/00 8:43:09 AM

### #3ThomasAtwood  Members

Posted 03 March 2000 - 02:59 AM

That is correct. Any transformation applied to a normal except rotations will require you to re-normalize.

### #4Spellbound  Members

Posted 03 March 2000 - 04:18 AM

When transforming normals the first thing you should do is to crop the fourth column and fourth row of the transformation matrix, yielding a 3 by 3 matrix. This matrix must then be inverted and then transposed before transforming the normal.

However with rotation the inversion and transposing is not necessary as they cancel each other (This has to do with the fact that the rotation matrix is orthogonal and the inversion is the same as the transposing).

With uniform scaling you don''t have to perform the inversion and transposing either, instead only a division by the scalefactor is needed.

For other non orthogonal transformations you must compute the transposed inversion of the transformation matrix, otherwise the normal will be wrong.

See "NormalTransformation.pdf" for the mathematics.

As a side note, you don''t have to do any re-normalization of the normals yourself as both OpenGL and D3D has options that can do this for you, which is usually faster than what you can do yourself.

### #5neoGriff  Members

Posted 03 March 2000 - 10:08 AM

I''m not using either API, because I always program my own system before using an API so that I understand the theory behind it. Otherwise it is worthless.

Anyway, what does everyone think is the best way to do transformations on polygons (i.e. Rotate object and translate according to world axes, or to rotate and then translate the object according to the new transformed axes as in how an airplane can pitch up and then travel in the new path). I''m trying to do it the second way, but as you''ve seen from my previous post, I can''t get the lighting to work correctly that way.

Mike Griffin
griff14@hotmail.com

### #6Spellbound  Members

Posted 03 March 2000 - 11:25 AM

I think it is good that you''re making your own routines instead of using DX or OpenGL I learned that way myself.

If you''re only using rotation and translation it is really simple to transform the normals. Just omit the translation part of the transformmatrix (the forth row or column depending on how you are multiplying the vectors with the matrices).

The way I transform my objects, and most other people too I suspect, is to first rotate the objects and then translate according to world axes. That way the translation is just the addition of the objects positions in world coordinates.

### #7neoGriff  Members

Posted 03 March 2000 - 11:55 AM

Thanks Spellbound!

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.