Jump to content
• ### What is your GameDev Story?

• Advertisement

# Small Question (Mesh Positions)

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

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

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

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

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

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

##### Share on other sites

• Advertisement
• Advertisement
• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• ### Popular Now

• 13
• 9
• 9
• 15
• 14
• Advertisement
• ### Forum Statistics

• Total Topics
634070
• Total Posts
3015330
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!