|
代码如下
//载入x文件
..........................
D3DXMATRIX V;
TheCamera.getViewMatrix(&V);
D3DXMatrixScaling(&V,0.001,0.001,0.001);//切换x文件的大小
ID3DXMesh* LD = 0;
D3DXVECTOR3 LDPosition(0.0f, 0.0f, 0.0f);
D3DMATERIAL9 LDMtrl = d3d::YELLOW_MTRL;
static float radius = 50.0f;
if( ::GetAsyncKeyState(VK_LEFT) & 0x8000f )
LDPosition.x -= 3000.0f * timeDelta;
if( ::GetAsyncKeyState(VK_RIGHT) & 0x8000f )
LDPosition.x += 3000.0f * timeDelta;
if( ::GetAsyncKeyState(VK_UP) & 0x8000f )
radius -= 2.0f * timeDelta;
if( ::GetAsyncKeyState(VK_DOWN) & 0x8000f )
radius += 2.0f * timeDelta;
static float angle = (3.0f * D3DX_PI) / 2.0f;
if( ::GetAsyncKeyState('A') & 0x8000f )
angle -= 0.5f * timeDelta;
if( ::GetAsyncKeyState('S') & 0x8000f )
angle += 0.5f * timeDelta;
D3DXVECTOR3 position( cosf(angle) * radius * 50, 1500.0f, sinf(angle) * radius * 50 ); D3DXVECTOR3 target(250.0f, 250.0f, 250.0f);
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
D3DXMatrixLookAtLH(&V, &position, &target, &up);
D3DXMATRIX World = V;
Device->SetTransform(D3DTS_VIEW, &World);
//
// Render
//
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
Device->BeginScene();
for(int i = 0; i < Mtrls.size(); i++)
{
Device->SetMaterial( &Mtrls );
Device->SetTexture(0, Textures);
Mesh->DrawSubset(i);
}
D3DXMATRIX mat1;
D3DXMATRIX curMatrix1;
D3DXMatrixTranslation(&mat1,0.1,0,0);
D3DXMatrixMultiply(&curMatrix1,&World,&mat1);
Device->SetTransform( D3DTS_WORLD, &curMatrix1 );
for(int i = 0; i < Mtrls_Ladle.size(); i++)
{
Device->SetMaterial( &Mtrls_Ladle );
Device->SetTexture(0, Textures_Ladle);
Mesh_Ladle->DrawSubset(i);
}
d3d: rawBasicScene(Device, 1.0f);
Device->EndScene();
Device-> resent(0, 0, 0, 0);
....................................
新手,请多多指教。 |
|