Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rotating Face Normals


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.

  • You cannot reply to this topic
3 replies to this topic

#1 thekiwimaddog   Members   -  Reputation: 155

Like
0Likes
Like

Posted 17 November 2012 - 06:03 AM

Hi everyone I wonder if anyone has any insight into this.

Is rotating a Face Normal any different to rotating a Vertex? I don't seem to be getting the correct results when applying a matrix transform to a face normal. I've tried using D3DXVec3TransformNormal instead of D3DXVec3TransformCoord but the documentation is says:

If you transforming a normal by a non-affine matrix, the matrix you pass to this function should be the transpose of the inverse of the matrix you would use to transform a coord


I'm not sure what that means exactly and if it will help with rotating a Face Normal.
Basically My Code is:
D3DXMATRIX matRotX, matRotY, matRotZ, matRotTotal;
D3DXMatrixRotationX( &matRotX, pMeshCoords->Rotation.x );
D3DXMatrixRotationY( &matRotY,  pMeshCoords->Rotation.y );
D3DXMatrixRotationZ( &matRotZ,  pMeshCoords->Rotation.z );

matRotAll = matRotX * matRotY * matRotZ;

D3DXVec3TransformNormal( &RotFaceNormal, &FaceNormal, &matRotAll );


Thanks in advance for any info anyone has!
David

Sponsor:

#2 thekiwimaddog   Members   -  Reputation: 155

Like
0Likes
Like

Posted 17 November 2012 - 08:04 AM

OK, I've tried the following:
D3DXMATRIX matRotX, matRotY, matRotZ, matRotTotal;
D3DXMatrixRotationX( &matRotX, pMeshCoords->Rotation.x );
D3DXMatrixRotationY( &matRotY,  pMeshCoords->Rotation.y );
D3DXMatrixRotationZ( &matRotZ,  pMeshCoords->Rotation.z );

matRotAll = matRotX * matRotY * matRotZ;

D3DXMatrixInverse( &matRotAll, NULL, &matRotAll );
D3DXMatrixTranspose( &matRotAll, &matRotAll );

D3DXVec3TransformNormal( &RotFaceNormal, &FaceNormal, &matRotAll );

This hasn't helped.
Am I going about this the wrong way?

Thanks
David

Edited by thekiwimaddog, 17 November 2012 - 08:06 AM.


#3 C0lumbo   Crossbones+   -  Reputation: 2165

Like
2Likes
Like

Posted 17 November 2012 - 10:03 AM

The matrix you're using looks like it's a pure rotation matrix with no scaling factor, so the "If you transforming a normal by a non-affine matrix, the matrix you pass to this function should be the transpose of the inverse of the matrix you would use to transform a coord" quote you're worrying about is irrelevant (the transpose of the inverse of your matrix should be the original matrix).

The other thing to worry about when transforming normals, is that you obviously don't want to apply the translation part of the matrix, but again in your case, your pure rotation matrix shouldn't be causing a problem, and the D3DXVec3TransformNormal function takes care of that for you anyway, so that's not the problem.

Unfortunately I don't know what's going wrong for you that you're getting incorrect results. Are you confident you're concatenating your xyz rotations in the order you need to be for you usage case?

#4 thekiwimaddog   Members   -  Reputation: 155

Like
0Likes
Like

Posted 17 November 2012 - 02:44 PM

Thanks, the problems was with my reflection code. Thanks for your help anyways!

David




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.



PARTNERS