Thanks vlau,
I tried your code but it didn't quite work for me.
Here's what I've hacked together so far:
Code:
var worldCenter;
function main
{
level_load ("cam.wmb");
wait(2);
vec_set(worldCenter,vector(-205, 0, 42));
mouse_mode = 1;
while(1)
{
if(mouse_middle == 1) // Orbit with middle mouse
{
camera.pan += mouse_force.x * 20 * time_step; // mouse movement changes PAN
camera.tilt += mouse_force.y * 20 * time_step; // mouse movement changes TILT
}
if(mouse_right == 1) // Pan with right mouse
{
worldCenter.x -= mouse_force.y * 40 * time_step;
worldCenter.y += mouse_force.x * 40 * time_step;
camera.x = worldCenter.x;
camera.y = worldCenter.y;
}
if(mickey.z != 0) // zoom with mouse wheel
{
vec_diff(temp,target.x,camera.x);
vec_scale(temp,((mickey.z * 1)/480));
vec_add(camera.x,temp);
worldCenter.x = camera.x;
worldCenter.y = camera.y;
worldCenter.z = camera.z;
}
mouse_pos.x = mouse_cursor.x; // update mouse position.
mouse_pos.y = mouse_cursor.y; // update mouse position.
wait(1);
}
}
This works pretty good, except that the pan directions are all screwed up
after a camera rotation.
Here are my goals again:
After pressing the middle mouse button, the camera should freely rotate around
the current center of the screen (focal point), following the mouse movements.
The zoom wheel should zoom in and out towards that center.
After pressing the right mouse button, the camera and the center of the screen
(or the focal point) should pan in x and y, following the mouse movements.
This is a great 3rd person camera movement and I would really like to get some
help in figuring out on how to code this.
Thanks!