ok cool,

You're going to need to check if the cursor coordinates are in degrees or radians. (if it's not either then please post what game it is or what they are set to when you look up, look down, look straight and a few others)

Also you may need to check what coordinate system is being used.

Most games I've seen have X - right, Z - forward, Y - up

Y Z

| /

|/_ _ X

O - The players position

P - Position to look at

// get the relative coordinates

float dx = P.x - O.x;

float dy = P.y - O.y;

float dz = P.z - O.z;

// the length of the vector

float m = sqrt(dx*dx + dy*dy + dz*dz);

if(m < 0.000001) // if this is true then the position you want to look at is too close to you

return; // be careful not to divide by zero...

// normalise the vector

dx = dx / m;

dy = dy / m;

dz = dz / m;

if(fabs(dz) > 0.9999999) { // special case

if(dz < 0) {

// look down

// just set the mouseY to be down degress (-90) radians (-PI/2)

} else {

// look up

// just set the mouseY to be down degress (90) radians (PI/2)

}

return;

}

. /|

a/ |dz

/__|

dx

float a = sqrt(1 - dy*dy);

float mouseX = acos(dx/a);

. /|

1/ |dy

/__|

a

float mouseY = asin(dy);

// some games also have strange things where they add/minus an extra 90 degrees to the mouseX

// if the game is in radians you should be able to just set mouseX and mouseY now

// if the game is in degrees just convert it to degrees by

mouseX *= 180.0f / PI;

mouseY *= 180.0f / PI;

// now set them

Not sure if this explains it very well but it may help you figure out what you need