# Position a mesh (*.x) in world coordinate system

## Recommended Posts

Hello, I am abled to load a *.x mesh and to render it. Until now the mesh was always placed in the root of the world coordinate system. (is this right?) What do I have to do if I want to place a mesh i.e. at the position [10,0,10]? Simply call d3dDevice->setTransform() and translate the world coordniate system? Thank you for your help, Best regards Erik

##### Share on other sites
I'm a little ignorant about DX (I've only used OpenGL for the past 5 or so years. Not big into rendering). But device->SetTransform(TransformType,Matrix); looks like it should do the trick.

I'd imagine setting the appropriate transform before rendering each mesh would do the trick.

##### Share on other sites
Okay, thats great.
Maybe any DX crack can confirm this.

##### Share on other sites
dashurc is correct, you want to set a world transform for the device using the SetTransform method. To create a world transform, you can use the D3DXMatrix* functions to create matrices that you can combine (through multiplication) to make a single tranformation matrix for that mesh. For example the D3DXMatrixTranslation function will re-position the mesh to the coordinates you specify, and the D3DXMatrixRotationY will rotate the mesh about the Y-axis. So you could do something like this (in D3D9 with C++):

D3DXMATRIXA16 matTranslation, matRotation, matWorld;D3DXMatrixRotationY( &matRotation, D3DX_PI/2.0f );D3DXMatrixTranslation( &matTranslation, 10, 0, 10 );matWorld = matRotation * matTranslation;d3dDevice->SetTransform( D3DTS_WORLDMATRIX, &matWorld );

Doing this will rotate the matrix first by 90 degrees, and then move it so it's centered about the point (10,0,10). The order in which these two transforms happen depend on the order of multiplication, so if you switched those two they would happen in the reverse order (and you would not get the same result).

##### Share on other sites
Okay, thank you both very much, again one step further ;)

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627680
• Total Posts
2978609

• 13
• 12
• 10
• 12
• 22