Drawing coordinates system axes in corner of screen
void CDEMView::DrawSomeBox()
{
D3DXMATRIX matObjectWorld;
D3DXMatrixIdentity (&matObjectWorld);
D3DXMATRIX matView;
D3DXMatrixIdentity (&matView);
D3DXMATRIX matProjection;
D3DXMatrixIdentity (&matProjection);
_device->GetTransform(D3DTS_VIEW, &matView);
_device->GetTransform(D3DTS_PROJECTION, &matProjection);
D3DVIEWPORT9 viewport;
_device->GetViewport(&viewport);
D3DXVECTOR3* p_centerPoint = BoxCenterVector;
D3DXVECTOR3 projectPoint;
D3DXVec3Project(&projectPoint, p_centerPoint ,&viewport, &matProjection, &matView, &matObjectWorld);
D3DXVECTOR3 screenPoint;
screenPoint.x = 0.1*viewport.Width;
screenPoint.y = 0.9*viewport.Height;
screenPoint.z = projectPoint.z;
D3DXVECTOR3 worldPoint;
D3DXVec3Unproject( &worldPoint, &screenPoint, &viewport, &matProjection, &matView, &matObjectWorld );
float transX, transY, transZ;
transX = worldPoint.x;
transY = worldPoint.y;
transZ = worldPoint.z;
ID3DXMesh* _SomeBox;
float boxSize = 2.0f;
D3DXCreateBox(_device,boxSize,boxSize,boxSize,&_SomeBox,NULL);
D3DMATERIAL9 mat;
mat.Diffuse.r = 255;
mat.Diffuse.g = 0;
mat.Diffuse.b = 0;
mat.Diffuse.a = 0.5;
_device->SetMaterial(&mat);
_device->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
D3DXMatrixTranslation(&matObjectWorld, transX, transY, transZ);
_device->SetTransform(D3DTS_WORLD, &matObjectWorld);
_SomeBox->DrawSubset(0);
_SomeBox->Release();
debug1 = transX;
debug2 = transY;
debug3 = transZ;
debug4 = boxSize;
manole = 0;
}
No comments:
Post a Comment