Sign in to follow this  

which space to pick in (D3D)

Recommended Posts

If the model is not set to the Identity , what space do i pick in ?

this is its translation and rendering

// Build castle's world matrix.
D3DXMatrixRotationY(&Ry, D3DX_PI);
D3DXMatrixTranslation(&T, 8.0f, 35.0f, -80.0f);
mCastleWorld = Ry*T;

void PropsDemo::drawObject(Object3D& obj, const D3DXMATRIX& toWorld)
// Transform AABB into the world space.

AABB box;, box);

// Only draw if AABB is visible.
if( gCamera->isVisible( box ) )
HR(mFX->SetMatrix(mhWVP, &(toWorld*gCamera->viewProj())));

D3DXMatrixInverse(&worldInvTrans, 0, &toWorld); //objectspace
D3DXMatrixTranspose(&worldInvTrans, &worldInvTrans);
HR(mFX->SetMatrix(mhWorldInvTrans, &worldInvTrans));
HR(mFX->SetMatrix(mhWorld, &toWorld));

for(UINT j = 0; j < obj.mtrls.size(); ++j)
HR(mFX->SetValue(mhMtrl, &obj.mtrls[j], sizeof(Mtrl)));

// If there is a texture, then use.
if(obj.textures[j] != 0)
HR(mFX->SetTexture(mhTex, obj.textures[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.
HR(mFX->SetTexture(mhTex, mWhiteTex));


drawObject(mCastle, mCastleWorld);

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this