Jump to content
  • Advertisement
Sign in to follow this  
jujumbura

how do I use D3DX math functions return value?

This topic is 4706 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

Good afternoon folks. There's this little remark that accompanies most of the D3DX math functions I use, and I have a question about it. It goes something like... "The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXMatrixRotationQuaternion function can be used as a parameter for another function. " Ok, that sounds great. So I translate my world transformation matrix by a matrix I produce right from the function. But then what the heck do I use for the pOut parameter in the quat function? If I pass in NULL, will it just it just disregard pOut for result placement, and return the proper result? In other words, what can I stick in as a meaningless value that won't make it blow up? Thanks, Mike

Share this post


Link to post
Share on other sites
Advertisement
Well you could create a matrix and pass its address as the pOut parameter and have it fill the matrix that way or you can simpley assign the matrix a value by making it equal to the function call. The function will return the resultant matrix.

So

D3DXMATRIX myMatrix;

D3DXMatrixMultiply( &myMatrix, &anotherMatrix,&anotherMatrix );

OR:

myMatrix = D3DXMatrixMultiply( NULL, &anotherMatrix, &anotherMatrix );

What the SDK is also saying is that because the matrix math functions also return their result you can use the function as a parameter to another function.
Like this:

D3DXMatrixMultiply( &myMatrix, &anotherMatrix, D3DXMatrixMultiply(&anotherMatrix, &anotherMatrix) );

Thats the way it works pretty much.

Hope that helps.

ace

Share this post


Link to post
Share on other sites
Right, I understand what they meant by using the function as a parameter to another function. That's exactly what I'd like to do; currently I just make a temp matrix ( as in your first example ) for storing the result.

I just wanted to make sure that passing in NULL for pOut isn't going to give me access violations. I mean I'd ASSUME that they check the input and wouldn't dereference NULL, but I just wanted to be sure.

Thanks =)
Mike

Share this post


Link to post
Share on other sites
Actually, you cannot pass NULL in for pOut. The return value of the function is simply the pointer which you passed in as pOut. This is so you can do things like:

D3DXVec3Transform(D3DXVec3Normalize(&n, &v), &m)

xyzzy

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!