Archived

This topic is now archived and is closed to further replies.

reillyhead

Making the world coord system like MAX...

Recommended Posts

hi, the world coord system as MAX has it is the standard way to for engineering applications, ie right handed system with the Z axis pointing up. does anybody know how to acheive this through the setting the D3D transforms (ie view, proj). I can get a right handed coord system working, but I would rather not have to pre transform all the geometry so that Z is up. cheers. Marc

Share this post


Link to post
Share on other sites
in my first game, i set the up in the view matrix to 0 x, 0 y, 1 z. that made it the same as max, but it was a bad idea. either rotate the models in max to the dx orientation or get the panda .x file exporter, which makes it the right angle

Share this post


Link to post
Share on other sites
Use D3DXMatrixPerspectiveFovRH to create your projection matrix and D3DXMatrixLookAtRH to create your view matrix. Then call:
IDirect3DDevice8::SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );


My site

Share this post


Link to post
Share on other sites
thanks guys, but:

it not really a question of importing max models etc. i want my world space to have this orientation

FanatasyGuy:
that''s what i''m doing now (not sure about the cull mode though) and it makes the world right handed, but the y axis is up, not the z.

for example. when i set a red line to go along the x axis (1,0,0), green along the y (0,1,0) and blue along the z (0,0,1)
the green and red lines are in the plane that makes the ''ground'' and the blue line points up. (and X cross Y = Z)

Share this post


Link to post
Share on other sites
Read the SDK docs, it''s right there in the first ''page'' of Using Direct3D -> Vertex Data -> 3-D Coordinate Systems.

Microsoft® Direct3D® uses a left-handed coordinate system. If you are porting an application that is based on a right-handed coordinate system, you must make two changes to the data passed to Direct3D.

Flip the order of triangle vertices so that the system traverses them clockwise from the front. In other words, if the vertices are v0, v1, v2, pass them to Direct3D as v0, v2, v1.

Use the view matrix to scale world space by –1 in the z-direction. To do this, flip the sign of the _31, _32, _33, and _34 member of the D3DMATRIX structure that you use for your view matrix.

To obtain what amounts to a right-handed world, use the D3DXMatrixPerspectiveRH and D3DXMatrixOrthoRH functions to define the projection transform. However, be careful to use the corresponding D3DXMatrixLookAtRH function, reverse the backface-culling order, and lay out the cube maps accordingly.


_____________________________________________
Come join us on IRC in #directxdev @ irc.afternet.org

Share this post


Link to post
Share on other sites