1872
« on: August 30, 2007, 11:39:02 AM »
Well, I would do it like this:
%cursorpos = position of mouse cursor
%cursorX = getWord(%cursorpos,0);
%cursorY = getWord(%cursorpos,1);
%resolution = current screen resolution
%resolutionX = getWord(%resolution,0);
%resolutionY = getWord(%resolution,1);
%camerapos = %client.Camera.position
%cameraX = getWord(%camerapos,0);
%cameraY = getWord(%camerapos,1);
if(%cursorX < %resolutionX / 2)
{
%x = %cameraX - (%resolutionX / 2 - %cursorX) / 15;
}
else if(%cursorX > %resolutionX / 2)
{
%x = %cameraX + (%cursorX - %resolutionX / 2 ) / 15;
}
else
{
%x = %cameraX;
}
if(%cursorY < %resolutionY / 2)
{
%z = %cameraY - (%resolutionY / 2 - %cursorY) / 15;
}
else if(%cursorY> %resolutionX / 2)
{
%z = %cameraY + (%cursorY - %resolutionY / 2 ) / 15;
}
else
{
%z = %cameraY;
}
Then you need some way to scale the z value (e.g. zoom). Obviously the x and y values in the code above would need to be swapped based on rotation of the client's camera. Also, I'm not sure how well this would work if the client's camera was not rotated on the z axis at 0,90,180, or 270 degrees.
You might be able to make modifications using the forward vector, but I don't know for sure. I'm at work right now, I'll have to check when I get home.