Jump to content
  • Advertisement
Sign in to follow this  
Anddos

which space to pick in (D3D)

This topic is 2915 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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;
obj.box.xform(toWorld, 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.
else
{
HR(mFX->SetTexture(mhTex, mWhiteTex));
}

HR(mFX->CommitChanges());
HR(obj.mesh->DrawSubset(j));
}
}
}



drawObject(mCastle, mCastleWorld);

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!