need help with D3D mouse picking... - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

need help with D3D mouse picking...

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

this is its translation and rendering

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

[code]
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));
}
}
}
[/code]

[code]
drawObject(mCastle, mCastleWorld);
[/code]
They hacked my password. Slap me!
Sign In or Register to comment.