New camera controls - Should have been checked in with previous changes.

This commit is contained in:
Shamus Young 2009-05-07 14:35:02 +00:00
parent 3f8f9bb1f0
commit 624cca9826
2 changed files with 26 additions and 26 deletions

View File

@ -51,18 +51,17 @@ static GLvector position;
static GLvector auto_angle;
static GLvector auto_position;
static float distance;
static float movement;
static bool moving;
static GLvector movement;
static bool cam_auto;
static float tracker;
static unsigned last_update;
static int camera_behavior;
static unsigned last_move;
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
static GLvector flycam_position (unsigned t)
{
@ -198,7 +197,6 @@ void CameraNextBehavior ()
}
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
@ -206,7 +204,6 @@ void CameraNextBehavior ()
void CameraYaw (float delta)
{
moving = true;
angle.y -= delta;
}
@ -218,7 +215,6 @@ void CameraYaw (float delta)
void CameraPitch (float delta)
{
moving = true;
angle.x -= delta;
}
@ -232,7 +228,6 @@ void CameraPan (float delta)
float move_x, move_y;
moving = true;
move_x = (float)sin (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
move_y = (float)cos (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
position.x -= move_y * delta;
@ -249,7 +244,6 @@ void CameraForward (float delta)
float move_x, move_y;
moving = true;
move_y = (float)sin (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
move_x = (float)cos (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
position.x -= move_y * delta;
@ -257,33 +251,40 @@ void CameraForward (float delta)
}
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
void CameraSelectionPitch (float delta)
void CameraVertical (float val)
{
movement.y += val;
last_move = GetTickCount ();
}
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
void CameraSelectionZoom (float delta)
void CameraLateral (float val)
{
movement.x += val;
last_move = GetTickCount ();
}
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
void CameraSelectionYaw (float delta)
void CameraMedial (float val)
{
movement.z += val;
last_move = GetTickCount ();
}
/*-----------------------------------------------------------------------------
@ -370,22 +371,21 @@ void CameraInit (void)
void CameraUpdate (void)
{
#if SCREENSAVER
cam_auto = true;
#endif
CameraPan (movement.x);
CameraForward (movement.z);
position.y += movement.y / 10.0f;
if (GetTickCount () - last_move > 1000)
movement *= 0.9f;
else
movement *= 0.99f;
if (SCREENSAVER)
cam_auto = true;
if (cam_auto)
do_auto_cam ();
if (moving)
movement *= 1.1f;
else
movement = 0.0f;
movement = CLAMP (movement, 0.01f, 1.0f);
if (angle.y < 0.0f)
angle.y = 360.0f - (float)fmod (fabs (angle.y), 360.0f);
angle.y = (float)fmod (angle.y, 360.0f);
angle.x = CLAMP (angle.x, -MAX_PITCH, MAX_PITCH);
moving = false;
}

View File

@ -16,9 +16,9 @@ void CameraUpdate (void);
void CameraTerm (void);
void CameraForward (float delta);
void CameraSelectionPitch (float delta_y);
void CameraSelectionYaw (float delta_x);
void CameraSelectionZoom (float delta_y);
void CameraPan (float delta_x);
void CameraPitch (float delta_y);
void CameraYaw (float delta_x);
void CameraVertical (float val);
void CameraLateral (float val);
void CameraMedial (float val);