The code style is defferent from Introduction to 3d game programming with directx 9
And I want to transform an X file model as usual...
But Failed...This is my Code:
void XFileDemo::drawScene(){
// Clear the backbuffer and depth buffer.
HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffeeeeee, 1.0f, 0));
HR(gd3dDevice->BeginScene());
HR(mFX->SetValue(mhLight, &mLight, sizeof(DirLight)));
HR(mFX->SetMatrix(mhWVP, &(mWorld*mView*mProj)));
D3DXMATRIX worldInvTrans;
D3DXMatrixInverse(&worldInvTrans, 0, &mWorld);
D3DXMatrixTranspose(&worldInvTrans, &worldInvTrans);
HR(mFX->SetMatrix(mhWorldInvTrans, &worldInvTrans));
HR(mFX->SetMatrix(mhWorld, &mWorld));
HR(mFX->SetTechnique(mhTech));
UINT numPasses = 0;
HR(mFX->Begin(&numPasses, 0));
HR(mFX->BeginPass(0));
D3DXMATRIX F; // I add code here
D3DXMatrixTranslation(&F,100.0f,100.0f,100.0f); // but it doesn't work
gd3dDevice->SetTransform(D3DTS_WORLD,&F); // The x model's position doesn't change
for(int j = 0; j < mMtrl.size(); ++j)
{
HR(mFX->SetValue(mhMtrl, &mMtrl[j], sizeof(Mtrl))); // If there is a texture, then use.
if(mTex[j] != 0)
{
HR(mFX->SetTexture(mhTex, mTex[j]));
}
// But if not, then set a pure white texture. When the texture color
// is multiplied by the color from lighting, it is like multiplying by
// 1 and won't change the color from lighting.
else
{
HR(mFX->SetTexture(mhTex, mWhiteTex));
}
HR(mFX->CommitChanges());
HR(mMesh->DrawSubset(j));
}
HR(mFX->EndPass());
HR(mFX->End());
mGfxStats->display();
HR(gd3dDevice->EndScene());
// Present the backbuffer.
HR(gd3dDevice->Present(0, 0, 0, 0));}
Any help will be appreciated!!!Thanks!