Transforming object world space matrix to a position in world space

Posted by Fredrik Boston Westman on Game Development See other posts from Game Development or by Fredrik Boston Westman
Published on 2013-06-29T23:15:01Z Indexed on 2013/06/30 4:29 UTC
Read the original article Hit count: 517

Im trying to make a function for picking objects with a bounding sphere however I have run in to a problem.

First I check against my my bounding sphere, then if it checks out then I test against the vertexes. I have already tested my vertex picking method and it work fine, however when I check first with my bounding sphere method it dosnt register anything. My conclusion is that when im transform my sphere position in to the position of the object in world space, the transformation goes wrong ( I base this on the fact the the x coordinate always becomes 1, even tho i translate non of my meshes along the x-axis to 1). So my question is:

What is the proper way to transform a objects world space matrix to a position vector ?

This is how i do it now:

First i set my position vector to 0.

XMVECTOR meshPos = XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);

Then I trannsform it with my object space matrix, and then add the offset to the center of the mesh.

meshPos = XMVector3TransformCoord(meshPos, meshWorld) + centerOffset;

© Game Development or respective owner

Related posts about directx11

Related posts about coordinates