Archived

This topic is now archived and is closed to further replies.

Joseph_Ku

How to use this function - D3DXVec3TransformNormal???

Recommended Posts

Joseph_Ku    122
Hi~Guys~ I have a problem of using the D3DX funtion - D3DXVec3TransformNormal. This funtion could transforms the 3-D vector normal by the given matrix. Because I don''t have enough knowledge of this operation, I don''t know how to set the given matrix. Could anyone tell me the knowledge of this operation or where to find relational information about it??? Thanks!!!

Share this post


Link to post
Share on other sites
Nik02    4348
Read up on rotation transformation in the sdk, and play with the D3DXMatrix* functions to make matrices.
When you understand the basic transformations, i suggest that you write your own, small matrix math library (for the sake of learning).

-Nik

Share this post


Link to post
Share on other sites
S1CA    1418
Yup, I agree with Nik02 - it''s advisable to learn the maths and graphics theory separately to the API.

Normals are different than vertex positions in that they always have their origin at 0,0,0 (i.e. they don''t have a position) and they shouldn''t be scaled or skewed.

For this reason, when transforming normals:

1. You shouldn''t apply any translation.
2. You shouldn''t apply any scales or skews.

If your matrix *doesn''t* have any scales or skews, then you can simply transform the normal by the top left 3x3 portion of the matrix.

If your matrix *does* have any scales or skews then you should use the inverse transpose of the top left 3x3 portion of the matrix (i.e. invert it then transpose it)

For a full mathematical breakdown of why the inverse transpose is used, and other properties of normal transformation, check out Ken Turkowski''s classic "Properties of Surface-Normal Transformations" paper at: http://www.worldserver.com/turk/computergraphics/NormalTransformations.pdf

--
Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites