mirror of https://github.com/skeeto/pixelcity.git
New camera controls - Should have been checked in with previous changes.
This commit is contained in:
parent
3f8f9bb1f0
commit
624cca9826
46
Camera.cpp
46
Camera.cpp
|
@ -51,18 +51,17 @@ static GLvector position;
|
||||||
static GLvector auto_angle;
|
static GLvector auto_angle;
|
||||||
static GLvector auto_position;
|
static GLvector auto_position;
|
||||||
static float distance;
|
static float distance;
|
||||||
static float movement;
|
static GLvector movement;
|
||||||
static bool moving;
|
|
||||||
static bool cam_auto;
|
static bool cam_auto;
|
||||||
static float tracker;
|
static float tracker;
|
||||||
static unsigned last_update;
|
static unsigned last_update;
|
||||||
static int camera_behavior;
|
static int camera_behavior;
|
||||||
|
static unsigned last_move;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
static GLvector flycam_position (unsigned t)
|
static GLvector flycam_position (unsigned t)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -198,7 +197,6 @@ void CameraNextBehavior ()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
@ -206,7 +204,6 @@ void CameraNextBehavior ()
|
||||||
void CameraYaw (float delta)
|
void CameraYaw (float delta)
|
||||||
{
|
{
|
||||||
|
|
||||||
moving = true;
|
|
||||||
angle.y -= delta;
|
angle.y -= delta;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -218,7 +215,6 @@ void CameraYaw (float delta)
|
||||||
void CameraPitch (float delta)
|
void CameraPitch (float delta)
|
||||||
{
|
{
|
||||||
|
|
||||||
moving = true;
|
|
||||||
angle.x -= delta;
|
angle.x -= delta;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -232,7 +228,6 @@ void CameraPan (float delta)
|
||||||
|
|
||||||
float move_x, move_y;
|
float move_x, move_y;
|
||||||
|
|
||||||
moving = true;
|
|
||||||
move_x = (float)sin (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
|
move_x = (float)sin (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
|
||||||
move_y = (float)cos (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
|
move_y = (float)cos (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
|
||||||
position.x -= move_y * delta;
|
position.x -= move_y * delta;
|
||||||
|
@ -249,7 +244,6 @@ void CameraForward (float delta)
|
||||||
|
|
||||||
float move_x, move_y;
|
float move_x, move_y;
|
||||||
|
|
||||||
moving = true;
|
|
||||||
move_y = (float)sin (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
|
move_y = (float)sin (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
|
||||||
move_x = (float)cos (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
|
move_x = (float)cos (-angle.y * DEGREES_TO_RADIANS) / 10.0f;
|
||||||
position.x -= move_y * delta;
|
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)
|
void CameraUpdate (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if SCREENSAVER
|
CameraPan (movement.x);
|
||||||
cam_auto = true;
|
CameraForward (movement.z);
|
||||||
#endif
|
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)
|
if (cam_auto)
|
||||||
do_auto_cam ();
|
do_auto_cam ();
|
||||||
if (moving)
|
|
||||||
movement *= 1.1f;
|
|
||||||
else
|
|
||||||
movement = 0.0f;
|
|
||||||
movement = CLAMP (movement, 0.01f, 1.0f);
|
|
||||||
|
|
||||||
if (angle.y < 0.0f)
|
if (angle.y < 0.0f)
|
||||||
angle.y = 360.0f - (float)fmod (fabs (angle.y), 360.0f);
|
angle.y = 360.0f - (float)fmod (fabs (angle.y), 360.0f);
|
||||||
angle.y = (float)fmod (angle.y, 360.0f);
|
angle.y = (float)fmod (angle.y, 360.0f);
|
||||||
angle.x = CLAMP (angle.x, -MAX_PITCH, MAX_PITCH);
|
angle.x = CLAMP (angle.x, -MAX_PITCH, MAX_PITCH);
|
||||||
moving = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
Camera.h
6
Camera.h
|
@ -16,9 +16,9 @@ void CameraUpdate (void);
|
||||||
void CameraTerm (void);
|
void CameraTerm (void);
|
||||||
|
|
||||||
void CameraForward (float delta);
|
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 CameraPan (float delta_x);
|
||||||
void CameraPitch (float delta_y);
|
void CameraPitch (float delta_y);
|
||||||
void CameraYaw (float delta_x);
|
void CameraYaw (float delta_x);
|
||||||
|
void CameraVertical (float val);
|
||||||
|
void CameraLateral (float val);
|
||||||
|
void CameraMedial (float val);
|
Loading…
Reference in New Issue