Sign in to follow this  
erik rostock

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


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this