mesh mirroring..

Started by
17 comments, last by vxten 20 years, 6 months ago
HMM,
i would go with the camera, you''re doing something strange if that doesn''t work.

make the camera a lookat one, like this (managed):

Matrix matLookAt = Matrix.LookAtLH( new Vector3( cameraX, cameraY, cameraZ ), new Vector3( 0 , 0, 0 ), new Vector3( 0.0f, 1.0f, 0.0f ) );

then set the view matrix to that:

_device.Transform.View = matView;

you probably already knew that but you really should be able to achieve that result by moving the camera..
Advertisement
ahh i dont understand how to get it to look at. I do this, but im fixed to an area. i think i have to edit the main World matrix?

D3DXMatrixTranslation(&m_matTranslation, -m_XPos, -m_YPos, -m_ZPos);

D3DXMatrixMultiply(&m_matWorld, &m_matTranslation, &m_matRotation);
nonono,
the world matrix is the one you edit to translate/rotate/scale a set of vertices before you render them.

the view matrix is the one you change to make the camera move.

i think there is a d3dx function for creating a look-at matrix. i''m using managed so i don''t know exactly where it is.
I used this like you said from the start. It still shows whats in the pic link above

D3DXMATRIX matView;
D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 0.0f, 0.0f,-100.0f ),
&D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),
&D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );
m_pD3DDevice->SetTransform( D3DTS_VIEW, &matView );
quote:Original post by Nik02
Rotate the actual vertices by locking the vertex buffer and transforming each vertex individually.


i know how to transform the vertex individually but i dont know how to rotate them
I think the problem here is that you want your camera to look straight down from above your plane. The trick is then to position your camera above the object :
D3DXVECTOR3 vFromPt = D3DXVECTOR3( 0.0f, 100.0f, 0.0f );
and make it look at the origin :
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
and now make your up vector for your camera along the z-axis :
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
Now plug these values into your D3DX function to generate your view matrix :
D3DXMATRIX matView;
D3DXMatrixLookAtLH( &matView, &vFromPt, &vLookatPt, &vUpVec );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
Of course you can tweak these values to get the look you want - you had the right idea, just needed to change the up vector.
Crow.
OMG CROW THANKS SO MUCH I SPENT THE ENTIRE DAY TRYING TI FIGURE THIS OUT AND NO ONE COULD THINK OF THIS BUT U!!
No problem.
Maybe if you explained your problem better, people would understand you better, and be able to help you.

And this is not called "Mesh mirroring", its called "Mesh rotating".


--
You're Welcome,
Rick Wong
- sitting in his chair doing the most time-consuming thing..

[edited by - Pipo DeClown on October 24, 2003 10:38:14 AM]

This topic is closed to new replies.

Advertisement