Archived

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

Saandman

Matrices and positions..

Recommended Posts

Gah! My mesh will not show up the way I want it to. The whole viewport seems tilted; this is clearly the case when rotating the mesh around any axis. It''s not straight Where could I have done wrong? /Sandman

Share this post


Link to post
Share on other sites
more info + code would be nice.

also, check your view matrix. be sure it isnt bent out of shape.

and your projection matrix. if you have it set wrong it can cause some... strange... effects.

Brett Lynnes
cheez_keeper@hotmail.com

Share this post


Link to post
Share on other sites
The strange thing is, if I render a quadrilateral using vertex buffers etc with _the same_ view- and projection matrix setup, it''s all fine!

// projection matrix
D3DXMatrixPerspectiveFovLH(&ProjMatrix, D3D_PI / 4.0f, (float)wndWidth / (float) wndHeight, 1.0f, 1000.0f);

// view matrix
D3DXMatrixLookAtLH(&ViewMatrix, &D3DXVECTOR3(100.0f, 50.0f, -150.0f), &D3DXVECTOR3(0.0f, 50.0f, 0.0f), &D3DXVECTOR3(0.0f, 1.0f, 0.0f));

I rotate the mesh around the x-axis. (World space). What about the view space transformations? Or the correct name for it..

/Sandman

Share this post


Link to post
Share on other sites
Assuming the matrices below get sent straight to SetTransform() with D3DTS_PROJECTION and D3DTS_VIEW respectively and no extra manipulation happens, then what you''ve posted looks fine.

Since a single quad works ok, some other things to check would be:

- that the cause isn''t really what you''re setting for the D3DTS_WORLD matrix. Maybe there''s a bug in all of the world matrices. Try forcing them to identity before rendering to test.

- if you''re using vertex shaders, check that what you''re transforming by the correct matrices (i.e. NOT by transposed matrices - you only need a single transpose to get the data in the right format).

- how are you rotating around the axes?

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Hi thanks for the response,

I'm in the middle of writing a DX8 wrapper so I used some home-cooked matrix functions BUT! they work as they shall and even though I rewrote a large portion of the code with pure DX function calls, testing and logging; it still screws.

Hmm the Y axis is the only one functioning correctly when rotating..

How I'm rotating? Well in my render func, I simply:

// simply put
// i.e:
D3DXMATRIX matRotZ;
D3DXMatrixRotationZ(&matRotZ, timeGetTime() / 1000.0f);
D3DXMatrixIdentity(&matWorld);
D3DXMatrixMultiply(&matWorld, &matWorld, &matRotZ);
g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld);

Does this seem correct?

[EDIT] What about rotating using the view matrix?? [/EDIT]

/Sandman

[edited by - Saandman on October 19, 2002 5:09:06 PM]

Share this post


Link to post
Share on other sites