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


How to make DirectX calculate your normals ?

Recommended Posts

Somewhere in the DirectX SDK help it says 'For normals, you can either directly supply them to Direct3D or have Direct3D calculate them for you.' But this doesn't seem possible when you are drawing just a triangle list or triangle strip using a custom FVF. All samples use something like this:
  function GetTriangleNormal(vVertex1:PD3DXVECTOR3 ; vVertex2:PD3DXVECTOR3 ;  vVertex3:PD3DXVECTOR3) : TD3DXVECTOR3;

	D3DXVec3Subtract(v1,vVertex2^, vVertex1^);
	D3DXVec3Subtract(v2,vVertex3^, vVertex1^);

	D3DXVec3Cross(vNormal, v1, v2);

	D3DXVec3Normalize(vNormal, vNormal);

	result := vNormal;
Isn't there a D3D or D3DX function somewhere that takes 3 points and gives you the face normal of that triangle in one function ? That's so common, it must be simpler than this ... [edited by - Fidelio_ on August 31, 2002 7:33:51 AM]

Share this post

Link to post
Share on other sites