# 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.

## 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 on other sites
You can't. You would have to associate a mesh permanently with a matrix, i believe, in your own way.

ace

##### 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 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 on other sites
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 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 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? ;)

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633298
• Total Posts
3011260
• ### Who's Online (See full list)

There are no registered users currently online

×