• Advertisement
Sign in to follow this  

2D to 3D cordinates

This topic is 2900 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

I am making a simple program that when you click a point on the screen that will be point 1 for the line when you second click again then the second point is the end of the line and then push these 2 points in a vector and renders, trouble is i am not sure if my 2d to 3d cords is working right.
POINT point;
D3DVIEWPORT9 v9;
GetCursorPos(&point);
D3DXMATRIX Proj,World;
D3DXVECTOR3 Src((float)point.x,(float)point.y,0.0f);
D3DXVECTOR3 VecOut;
D3DXMatrixIdentity(&World);
device->GetTransform(D3DTS_PROJECTION,&Proj);
device->GetTransform(D3DTS_VIEW,&View);
device->GetTransform(D3DTS_WORLD,&World);
device->GetViewport(&v9);
D3DXVec3Project(&VecOut,&Src,&v9,&Proj,&View,&World);
char OutBuffer[64];
sprintf(OutBuffer,"%f %f\n",VecOut.x,VecOut.y);
SetWindowText(FindWindow("Direct3D9App",NULL),OutBuffer);

Share this post


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

  • Advertisement