directx9学習(複数モデル表示)
- モデル表示位置指定
VOID SetupMatrices(float x)
{
// Set up world matrix
D3DXMATRIXA16 matWorld;
D3DXMatrixIdentity(&matWorld);
D3DXMatrixTranslation(&matWorld, x, 0.0f, 0.0f);
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
- 複数モデル表示(Render関数内)
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
float x[] = { -300, 0, 300};
for (int j= 0; j < 3; j++) {
// Setup the world, view, and projection matrices
SetupMatrices(x[j]);
SetupLights();// Meshes are divided into subsets, one for each material. Render them in
// a loop
for( DWORD i=0; iSetMaterial( &g_pMeshMaterials[i] );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );
// Draw the mesh subset
g_pMesh->DrawSubset( i );
}
}// End the scene
g_pd3dDevice->EndScene();
- 結果