I know i need the view, projection and world matrix for the calculations. So i managed to get those. But what next? How can i calculate the 3d position of an object to a 2d screen position?

This is how i get the matrices:

[size="2"]D3DXVECTOR3 vector_2d, vector_3d(0,0,0);[/size] [size="2"]D3DXMATRIX view_matrix, proj_matrix, world_matrix;[/size] [size="2"]D3DVIEWPORT9 d3dvp;[/size] [size="2"]dev->GetTransform( D3DTS_VIEW, &view_matrix );[/size] [size="2"]dev->GetTransform( D3DTS_PROJECTION, &proj_matrix );[/size] [size="2"]dev->GetTransform( D3DTS_WORLD, &world_matrix );[/size] [size="2"]dev->GetViewport( &d3dvp );[/size] [size="2"]D3DXVec3Project( &vector_2d, &vector_3d, &d3dvp, &proj_matrix, &view_matrix, &world_matrix );[/size] [size="2"]D3DXVec3Unproject( &vector_3d, &vector_2d, &d3dvp, &proj_matrix, &view_matrix, &world_matrix );[/size] [size="2"][/size]