# Face normals: recalculate each time or rotate?

This topic is 5035 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Currently I take the triangle, rotate it, then calculate the face normal from the resulting points. Would it be more sensible calculate the face normals for every triangle as I load the model, then rotate the normal..? I ask only because I've noticed that Milkshape exports these normals - so people must use them for something, and the only reason I can think is as a faster way to calculate the normals when culling triangles and lighting a model (I'm only using flat shaded texture-mapped triangles at the moment).

##### Share on other sites
You can just multiply the rotation matrix with the normals to get the rotated normal. I believe recalculating normals everytime is alot more expensive.

##### Share on other sites
..."just multiply the rotation matrix"...

The what? I have three functions:

point3D rotatePointAboutAxisX(point3D p, double a) { }
point3D rotatePointAboutAxisY(point3D p, double a) { }
point3D rotatePointAboutAxisZ(point3D p, double a) { }

... that make use of sine and cosine to spin the points about the origin. What's a rotation matrix?

##### Share on other sites
there is loads of articles on gdnet on matrix math, if you are serious about 3D programming i suggest you read them and understand them. they are very helpful in many situations.

##### Share on other sites
Well a rotation matrix contains the required information to transform any point. Well Math is not my strong point but what you are using is Euler Angles and im sure you can easily find out how to convert your angles into a rotation matrix.

By calculating your rotation matrix once, you can use it to calculate your new normals.

Also are you using OpenGL/DX? If you are, you need not recalculate the normals for lighting. This is because when you apply the rotation using these api's, the modelview matrix takes into account the rotation when it transforms/lights your triangles.

##### Share on other sites
First of all, what API are you using? Is this OpenGL, Direct3D, or some 3D code you're writing yourself?

Elaborate a bit more so we can help.

##### Share on other sites
Quote:
 Original post by GamerSgYou can just multiply the rotation matrix with the normals to get the rotated normal. I believe recalculating normals everytime is alot more expensive.

Hug?

MxV (9 muls) is faster than U^V (3 muls) ? I'm pretty sure it is not the case :)

Quote:
 Original post by benryves..."just multiply the rotation matrix"...The what?

It seems you need more informations about linear algebra and matrices (+ another reference). Matrices offer you a way to represent linear transformations such as rotations, scaling, translations. There is a small introduction to rotation matrices in the DX SDK help. Diana Gruber write this little piece of informations (it will need some math background). Seumas McNally gave this to gamedev.net.

Regards,

##### Share on other sites
Quote:
 Original post by ProzakFirst of all, what API are you using? Is this OpenGL, Direct3D, or some 3D code you're writing yourself?Elaborate a bit more so we can help.

Sorry! I'm doing everything myself in software (filling/texturing triangles, rotating points, transforming to screen coordinates, loading models, lighting &c) in C++ and SDL.

A model from DOOM3 exported from Milkshape3D by a script (~4000 triangles, ~25fps [ouch])

The angles I rotate by are the bog standard 0-to-2pi variety (radians). I'll hunt some stuff on matrix maths (not heard of it before, which explains my confusion a little). Unfortunately, I've done everything without a reference so far, so my code is probably a little unconventional. I'm just messing around with it a bit, as I like this sort of thing. [wink]

##### Share on other sites
Quote:
 Original post by Emmanuel DelogetMxV (9 muls) is faster than U^V (3 muls) ? I'm pretty sure it is not the case :)

If you're talking about the cross product when using ^ (which is what you use to recalculate normals) then that generally requires six multiplies and three subtractions, not three muls. It also requires normalisation, though you need that with the matrix multiply as well if you allow non uniform scaling.

To the OP, you really should learn more linear algebra, it is a very elegenat way to represent changes of coordinate systems and transformations when it comes to 3d graphics. For example, you can do both the projection, the viewport transform, the camera transform and the object to world transform all at once by performing a single Matrix*vector multiply.

##### Share on other sites
Quote:
 Original post by GameCatTo the OP, you really should learn more linear algebra, it is a very elegenat way to represent changes of coordinate systems and transformations when it comes to 3d graphics.

Problem.
I cannot "learn" maths. I have a real mental block when it comes to it. I can add, subtract, multiply and divide and push the required buttons on a calculator - but don't ask me to do anything more advanced!

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 12
• 10
• 13
• 104
• 11
• ### Forum Statistics

• Total Topics
632982
• Total Posts
3009689
• ### Who's Online (See full list)

There are no registered users currently online

×