Jump to content
  • Advertisement
Sign in to follow this  
luke88

Small Question (Mesh Positions)

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

If load several meshes into a world, each with there own matrix (which have been set there position using D3DXMatrixTranslation), how would I recall their position co-ordinates? (If that makes sense). I basically just want to find out the x, y and z of a mesh.

Share this post


Link to post
Share on other sites
Advertisement
You can't. You would have to associate a mesh permanently with a matrix, i believe, in your own way.

ace

Share this post


Link to post
Share on other sites
Ow, damn't. DirectX Retained Mode was so much simpler and straight forward. I wish they never dropped it. Oh well.

I think I've found a way to do it anyway (with my own code).

Thanks for the info.

Share this post


Link to post
Share on other sites
Although Ace is usually right I think he misunderstood the question. Otherwise I have. But if you have the matrix of each mesh you can retrieve the position from it: it is the vector on the bottom row of the matrix. The position vector V = (M41, M42, M43).

Greetz,

Illco

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Illco is right. Just complementing:

If the mesh initial position is not at the origin (0,0,0), do:

Mesh initial position = (pox,poy,poz)

Mesh current position = (M41,M42,M43)+(pox,poy,poz)


Note: I suppose that no scale transformation is applied to the meshes.

Share this post


Link to post
Share on other sites
Just another aside to throw into the mix... what's been said will work fine for the original question, but it won't necessarily "scale" when you implement more complex transformations (e.g. rotation and scaling).

If you combine rotation/scaling yet still only extract the M41/M42/M43 elements you'll only get the translation part of the transformation. You'd need to actually translate a coordinate (or decompose the matrix) using D3DX functions to get the full set of original values.

hth
Jack

Share this post


Link to post
Share on other sites
Or, you could wrap it all in a class:

class object
{
ID3DXMesh mesh;
D3DXMATRIX mat;
D3DXVECTOR3 position;
D3DXVECTOR3 rotation;
D3DXVECTOR3 scaling;
// pos/rot/scale accessors
// some kind of function to update the matrix based on the PRS
// some kind of function to set the mat and draw the mesh
}


Who needs D3DRM when you can make your own? ;)

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!