Jump to content
  • Advertisement

Archived

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

stefu

D3DXTransformNormal/Coord

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

What do they do? These don''t give the same result: (Matrix is similar to D3DXMATRIX)
  
Vector3 Vector3TransformCoord(const Vector3& v,const Matrix& m)
{
	return Vector3(
		v.x * m._11 + v.y * m._21 + v.z * m._31 + m._41,
		v.x * m._12 + v.y * m._22 + v.z * m._32 + m._42,
		v.x * m._13 + v.y * m._23 + v.z * m._33 + m._43 );
	
}
Vector3 Vector3TransformNormal(const Vector3& v,const Matrix& m)
{
	return Vector3(
		v.x * m._11 + v.y * m._21 + v.z * m._31,
		v.x * m._12 + v.y * m._22 + v.z * m._32,
		v.x * m._13 + v.y * m._23 + v.z * m._33 );
}
  
Thanks for help.

Share this post


Link to post
Share on other sites
Advertisement
The first one, TransformCoord, transforms the vertex INCLUDING the translation that is stored in _41, _42, _43.

The latter on, TransformNormal, does not consider the translation what makes sense since just the direction of a normal is required.

Share this post


Link to post
Share on other sites
Oops, I was not clear enough. Of course these two give different result.

But the point is that I don''t get the same result when using my Vector3TransformCoord/Normal instead of corresponding D3DX ones.

Why???

Share this post


Link to post
Share on other sites
From what I see of your code it should be the same. But you use your own classes and many other things can be wrong with it. DX returns the (mathematically correct but mostly useless) D3DXVECTOR4 when multiplying a vector with a 4x4 matrix which can directly be casted to D3DXVECTOR3.

Your solution will be slower than the DX one since you create a new Vector3 object (this will call the constructor and hence allocate space for your complete Vector class etc), so why not make use of the tested DX library. If you dont you anyway have some overhead with converting your vectors/matrices to the DX ones as they are needed for DX commands that you will use.

On the other hand you learn alot more if you build your own classes, this experience is worth the additional costs since it raises your market value

- thomas

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!