Sign in to follow this  
sharathm

Snooket Game Help!!!

Recommended Posts

I have setup my screen with the following information for the view and projection matrices. ------------------------------------------------------------------------- D3DXVECTOR3 position(0.0f, 0.0f, -5.0f); D3DXVECTOR3 target(0.0f, 0.0f, 0.0f); D3DXVECTOR3 up(0.0f, 1.0f, 0.0f); D3DXMatrixLookAtLH(&V, &position, &target, &up); D3DXMatrixPerspectiveFovLH( &proj, D3DX_PI/2, // 90 - degree (float)WINDOW_WIDTH / (float)WINDOW_HEIGHT, 1.0f, 7.0f); ------------------------------------------------------------------------- I have used the following formula to convert a mouse point to its corresponding view space co-ordinates. -------------------------------------------- #define WINDOW_WIDTH 800 #define WINDOW_HEIGHT 600 struct Point { Type x; Type y; }; Point<float> p; Point<int> s; p.x=(((2.0f*s.x)/WINDOW_WIDTH)-1.0f)/proj(0,0); p.y=(((-2.0f*s.y)/WINDOW_HEIGHT)+1.0f)/proj(1,1); --------------------------------------------- The problem is that the value computed is not accurate. At point (400,300) of mouse it accurately shows (0,0) as the view space co-ordinate but i have drawn a sphere at (0,0,0) and it doesnt align with this. The sphere seems to be a little above this point. I am unable to convert my mouse co-ordinate to a view space 3D co-ordinate. The basic idea here is that i need to pick a location on the screen so that i can set the direction vector of the cue-ball to that direction. But i am unable to do tat... Is there any way to get a vector from the current location of the cue-ball to the point that i clicked?? Any sort of help in this matter is appreciated...

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