Sign in to follow this  
Anddos

2D to 3D cordinates

Recommended Posts

Anddos    588
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this