naev 0.12.5
camera.c File Reference

Handles the camera. More...

#include "camera.h"
#include "background.h"
#include "conf.h"
#include "gui.h"
#include "nebula.h"
#include "ntracing.h"
#include "pause.h"
#include "player.h"
#include "sound.h"
#include "space.h"
Include dependency graph for camera.c:

Go to the source code of this file.

Macros

#define CAMERA_DIR   ( M_PI / 2. )

Functions

static void cam_updateFly (double x, double y, double dt)
 Updates the camera flying to a position.
static void cam_updatePilot (Pilot *follow, double dt)
 Updates a camera following a pilot.
static void cam_updatePilotZoom (const Pilot *follow, const Pilot *target, double dt)
 Updates the camera zoom.
static void cam_updateManualZoom (double dt)
 Updates the manual zoom target.
void cam_zoomOverride (int enable)
 Overrides the zoom system.
void cam_setZoom (double zoom)
 Sets the camera zoom.
void cam_setZoomTarget (double zoom, double speed)
 Sets the camera zoom target.
double cam_getZoom (void)
 Gets the camera zoom.
double cam_getZoomTarget (void)
 Gets the camera zoom.
void cam_getPos (double *x, double *y)
 Gets the camera position.
void cam_getDPos (double *dx, double *dy)
 Gets the camera position differential (change in last frame).
void cam_getVel (double *vx, double *vy)
 Gets the camera velocity.
void cam_vel (double vx, double vy)
 Sets the camera velocity.
void cam_setTargetPilot (unsigned int follow, int soft_over)
 Sets the target to follow.
void cam_setTargetPos (double x, double y, int soft_over)
 Sets the camera target to a position.
int cam_getTarget (void)
 Returns the camera's current target.
void cam_update (double dt)
 Updates the camera.

Variables

static unsigned int camera_followpilot = 0
static int zoom_override = 0
static double camera_Z = 1.
static double camera_X = 0.
static double camera_Y = 0.
static double camera_DX
static double camera_DY
static double camera_VX = 0.
static double camera_VY = 0.
static double old_X = 0.
static double old_Y = 0.
static double target_Z = 0.
static double target_X = 0.
static double target_Y = 0.
static int camera_fly = 0
static double camera_flyspeed = 0.
static double camera_zoomspeed = 0.

Detailed Description

Handles the camera.

Definition in file camera.c.

Macro Definition Documentation

◆ CAMERA_DIR

#define CAMERA_DIR   ( M_PI / 2. )

Definition at line 26 of file camera.c.

Function Documentation

◆ cam_getDPos()

void cam_getDPos ( double * dx,
double * dy )

Gets the camera position differential (change in last frame).

Definition at line 131 of file camera.c.

◆ cam_getPos()

void cam_getPos ( double * x,
double * y )

Gets the camera position.

Parameters
[out]xX position to get.
[out]yY position to get.

Definition at line 122 of file camera.c.

◆ cam_getTarget()

int cam_getTarget ( void )

Returns the camera's current target.

Returns
0 if focused on position, else returns pilot ID.

Definition at line 222 of file camera.c.

◆ cam_getVel()

void cam_getVel ( double * vx,
double * vy )

Gets the camera velocity.

Definition at line 140 of file camera.c.

◆ cam_getZoom()

double cam_getZoom ( void )

Gets the camera zoom.

Returns
The camera's zoom.

Definition at line 101 of file camera.c.

◆ cam_getZoomTarget()

double cam_getZoomTarget ( void )

Gets the camera zoom.

Returns
The camera's zoom.

Definition at line 111 of file camera.c.

◆ cam_setTargetPilot()

void cam_setTargetPilot ( unsigned int follow,
int soft_over )

Sets the target to follow.

Definition at line 158 of file camera.c.

◆ cam_setTargetPos()

void cam_setTargetPos ( double x,
double y,
int soft_over )

Sets the camera target to a position.

Definition at line 194 of file camera.c.

◆ cam_setZoom()

void cam_setZoom ( double zoom)

Sets the camera zoom.

This is the zoom used in game coordinates.

Parameters
zoomZoom to set to.

Definition at line 77 of file camera.c.

◆ cam_setZoomTarget()

void cam_setZoomTarget ( double zoom,
double speed )

Sets the camera zoom target.

This should be used in conjunction with manual zoom.

Parameters
zoomZoom to try to set camera to.
speedSpeed of change to use.

Definition at line 90 of file camera.c.

◆ cam_update()

void cam_update ( double dt)

Updates the camera.

Parameters
dtCurrent delta tick.

Definition at line 232 of file camera.c.

◆ cam_updateFly()

void cam_updateFly ( double x,
double y,
double dt )
static

Updates the camera flying to a position.

Definition at line 299 of file camera.c.

◆ cam_updateManualZoom()

void cam_updateManualZoom ( double dt)
static

Updates the manual zoom target.

Speed up if needed.

Definition at line 409 of file camera.c.

◆ cam_updatePilot()

void cam_updatePilot ( Pilot * follow,
double dt )
static

Updates a camera following a pilot.

Definition at line 329 of file camera.c.

◆ cam_updatePilotZoom()

void cam_updatePilotZoom ( const Pilot * follow,
const Pilot * target,
double dt )
static

Updates the camera zoom.

Speed up if needed.

Definition at line 427 of file camera.c.

◆ cam_vel()

void cam_vel ( double vx,
double vy )

Sets the camera velocity.

Definition at line 149 of file camera.c.

◆ cam_zoomOverride()

void cam_zoomOverride ( int enable)

Overrides the zoom system.

Parameters
enableWhether or not to override the zoom system.

Definition at line 65 of file camera.c.

Variable Documentation

◆ camera_DX

double camera_DX
static
Initial value:
=
0.

Derivative of X position (velocity) of the camera.

Definition at line 34 of file camera.c.

◆ camera_DY

double camera_DY
static
Initial value:
=
0.

Derivative of Y position (velocity) of the camera.

Definition at line 36 of file camera.c.

◆ camera_fly

int camera_fly = 0
static

Camera is flying to target.

Definition at line 47 of file camera.c.

◆ camera_flyspeed

double camera_flyspeed = 0.
static

Speed when flying.

Definition at line 48 of file camera.c.

◆ camera_followpilot

unsigned int camera_followpilot = 0
static

Pilot to follow.

Definition at line 28 of file camera.c.

◆ camera_VX

double camera_VX = 0.
static

Definition at line 38 of file camera.c.

◆ camera_VY

double camera_VY = 0.
static

Definition at line 39 of file camera.c.

◆ camera_X

double camera_X = 0.
static

X position of camera.

Definition at line 32 of file camera.c.

◆ camera_Y

double camera_Y = 0.
static

Y position of camera.

Definition at line 33 of file camera.c.

◆ camera_Z

double camera_Z = 1.
static

Current in-game zoom.

Definition at line 31 of file camera.c.

◆ camera_zoomspeed

double camera_zoomspeed = 0.
static

Speed when zooming.

Definition at line 49 of file camera.c.

◆ old_X

double old_X = 0.
static

Old X positiion.

Definition at line 41 of file camera.c.

◆ old_Y

double old_Y = 0.
static

Old Y position.

Definition at line 42 of file camera.c.

◆ target_X

double target_X = 0.
static

Target X position.

Definition at line 45 of file camera.c.

◆ target_Y

double target_Y = 0.
static

Target Y position.

Definition at line 46 of file camera.c.

◆ target_Z

double target_Z = 0.
static

Target zoom.

Definition at line 44 of file camera.c.

◆ zoom_override

int zoom_override = 0
static

Whether or not to override the zoom.

Definition at line 29 of file camera.c.