Rotate normals without "reuseing" vertices

Started by
5 comments, last by b34r 18 years, 8 months ago
Hey, Is there a way to rotate/recalculate normals without vertex input? Greetings, Michael L.
Advertisement
Could you be a bit more detailed in what you want to do?

Do you want to calculate the Normals of a model, without looking at the individual vertices?
I already have the normals of that model.

Now i want to change/rotate the normals as like the model itself has been rotated without having to use all vertex matrix data again to accomplish this.
What 3D API are you using? OpenGL, DirectX?

Well, under OpenGL (and I guess DX3D too, why would it be diferent), once you define the model, it's vertices, it's normals, texture coordinates, vertex colors, etc, if you rotate the model, the vertex normals rotate with it, so there is no need to run the normals through a rotation/transformation matrix.

But, if you are coding your own renderer, or using a software based one, then perhaps you do need to pass the normals through the matrix...

Another advice I can give you is that the quality of the responses you get here on the forums is proportional to the way you ask your questions, so please try to explain what you're trying to accomplish in as much detail as possible, if you want better responses...
Transforming vectors is different from rotating vertices.
I assume here that you already have a 4x4 transformation matrix (containing the rotation you want). To use that matrix to rotate a (normal-)vector, you'll first have to calculate it's inverse. From the inverse matrix you calculate the transposed matrix. You can rotate vectors by multiplying them with that transposed matrix.

Tom
Thx,

I think I really have to use the vertex matrix.
Quote:Original post by dimebolt
Transforming vectors is different from rotating vertices.
I assume here that you already have a 4x4 transformation matrix (containing the rotation you want). To use that matrix to rotate a (normal-)vector, you'll first have to calculate it's inverse. From the inverse matrix you calculate the transposed matrix. You can rotate vectors by multiplying them with that transposed matrix.

Tom


Agreed. And, if you know you have no scaling you can skip the 'inverse + transpose 3x3' part and directly apply the upper 3x3 rotation matrix of your 4x4 model matrix.

If you have scaling, you can simply scale the upper 3x3 rotation matrix by the inverse scale of your model but this can get (moderatly) nasty if you work in a hierarchy.
Praise the alternative.

This topic is closed to new replies.

Advertisement