Original Post
I have a problem about D3DXMATRIX structure.It's simple i know but i can't fix the problem :) DirectX 9.0 and C plus plus. I can open .x mesh's and also i can move around it with my camera class(FPS). Also i can open a BSP map and move in it.But i can't work them together. This is what i do for walking around BSP map. // This is global D3DXMATRIX m_mView; If i do it for moveing in BSP map my mesh fix to my camera position. I mean if my mesh in the beginning(before BSP map) is in (a, b, c) in the world matrix, after the code above it set's to my camera position like x+a, y+b, z+c.It's comming with me around the map. I want to fix my mesh's on to the map not to my camera position. This is what i do for render mesh. Please help me.I really need it :)
D3DXVec3Normalize( &vLookatPt, &vLookatPt );
D3DXVec3Cross( &m_vRight, &vUpVec, &vLookatPt );
D3DXVec3Normalize( &m_vRight, &m_vRight );
D3DXVec3Cross( &vUpVec, &vLookatPt, &m_vRight );
D3DXVec3Normalize( &vUpVec, &vUpVec );
m_mView._11 = m_vRight.x;
m_mView._12 = vUpVec.x;
m_mView._13 = vLookatPt.x;
m_mView._14 = 0.0f;
m_mView._21 = m_vRight.y;
m_mView._22 = vUpVec.y;
m_mView._23 = vLookatPt.y;
m_mView._24 = 0.0f;
m_mView._31 = m_vRight.z;
m_mView._32 = vUpVec.z;
m_mView._33 = vLookatPt.z;
m_mView._34 = 0.0f;
m_mView._41 = -D3DXVec3Dot( &m_vEye, &m_vRight );
m_mView._42 = -D3DXVec3Dot( &m_vEye, &vUpVec );
m_mView._43 = -D3DXVec3Dot( &m_vEye, &vLookatPt );
m_mView._44 = 1.0f;
pd3dDevice->SetTransform( D3DTS_VIEW, &m_mView );
// Update the view matrix
D3DXMatrixLookAtLH( &m_mView, &m_vEye, &vLookatPt, &vUpVec );
D3DXMatrixInverse( &m_mCameraWorld, NULL, &m_mView );
D3DXMATRIXA16 mView;
D3DXMATRIXA16 mProj;
D3DXMATRIXA16 mWorldView;
D3DXMATRIXA16 mWorldViewProjection;
// Render the scene
if( SUCCEEDED( pd3dDevice->BeginScene() ) )
{
// Get the projection & view matrix from the camera class
mWorldView = *g_Camera.GetWorldMatrix();
mProj = *g_Camera.GetProjMatrix();
mView = *g_Camera.GetViewMatrix();
// BSP map
g_Camera.MapRender();
if( g_bUseHWNPatches )
{
float fNumSegs;
fNumSegs = (float)g_dwNumSegs;
pd3dDevice->SetNPatchMode( fNumSegs );
}
mWorldViewProjection = g_mCenterWorld * mView * mProj;
// Update the effect's variables. Instead of using strings, it would
// be more efficient to cache a handle to the parameter by calling
// ID3DXEffect::GetParameterByName
V( g_pEffect->SetMatrix( "g_mWorldViewProjection", &mWorldViewProjection ) );
V( g_pEffect->SetMatrix( "g_mWorld", &mWorldView ) );
D3DXMatrixTranslation( &g_mCenterWorld, -0, 0, 1 );
UINT cPasses;
V( g_pEffect->Begin( &cPasses, 0 ) );
for( UINT p = 0; p < cPasses; ++p )
{
V( g_pEffect->BeginPass( p ) );
// set and draw each of the materials in the mesh
for( UINT i = 0; i < g_dwNumMaterials; i++ )
{
V( g_pEffect->SetVector( "g_vDiffuse", (D3DXVECTOR4*)&g_pMaterials.MatD3D.Diffuse ) );
if( g_ppTextures[nObjectnum] )
{
V( g_pEffect->SetTexture( "g_txScene", g_ppTextures ) );
}
else
{
V( g_pEffect->SetTexture( "g_txScene", g_pDefaultTex ) );
}
V( g_pEffect->CommitChanges() );
g_pMeshEnhanced->DrawSubset( i );
}
V( g_pEffect->EndPass() );
}
V( g_pEffect->End() );
if( g_bUseHWNPatches )
{
pd3dDevice->SetNPatchMode( 0 );
}