Kohi Game Engine
camera.h File Reference
#include "math/math_types.h"

Go to the source code of this file.

Data Structures

struct  camera
 Represents a camera that can be used for a variety of things, especially rendering. Ideally, these are created and managed by the camera system. More...
 

Typedefs

typedef struct camera camera
 Represents a camera that can be used for a variety of things, especially rendering. Ideally, these are created and managed by the camera system. More...
 

Functions

KAPI camera camera_create (void)
 Creates a new camera with default zero position and rotation, and view identity matrix. Ideally, the camera system should be used to create this instead of doing so directly. More...
 
KAPI void camera_reset (camera *c)
 Defaults the provided camera to default zero rotation and position, and view matrix to identity. More...
 
KAPI vec3 camera_position_get (const camera *c)
 Gets a copy of the camera's position. More...
 
KAPI void camera_position_set (camera *c, vec3 position)
 Sets the provided camera's position. More...
 
KAPI vec3 camera_rotation_euler_get (const camera *c)
 Gets a copy of the camera's rotation in Euler angles. More...
 
KAPI void camera_rotation_euler_set (camera *c, vec3 rotation)
 Sets the provided camera's rotation in Euler angles. More...
 
KAPI mat4 camera_view_get (camera *c)
 Obtains a copy of the camera's view matrix. If camera is dirty, a new one is created, set and returned. More...
 
KAPI vec3 camera_forward (camera *c)
 Returns a copy of the camera's forward vector. More...
 
KAPI vec3 camera_backward (camera *c)
 Returns a copy of the camera's backward vector. More...
 
KAPI vec3 camera_left (camera *c)
 Returns a copy of the camera's left vector. More...
 
KAPI vec3 camera_right (camera *c)
 Returns a copy of the camera's right vector. More...
 
KAPI vec3 camera_up (camera *c)
 Returns a copy of the camera's up vector. More...
 
KAPI void camera_move_forward (camera *c, f32 amount)
 Moves the camera forward by the given amount. More...
 
KAPI void camera_move_backward (camera *c, f32 amount)
 Moves the camera backward by the given amount. More...
 
KAPI void camera_move_left (camera *c, f32 amount)
 Moves the camera left by the given amount. More...
 
KAPI void camera_move_right (camera *c, f32 amount)
 Moves the camera right by the given amount. More...
 
KAPI void camera_move_up (camera *c, f32 amount)
 Moves the camera up (straight along the y-axis) by the given amount. More...
 
KAPI void camera_move_down (camera *c, f32 amount)
 Moves the camera down (straight along the y-axis) by the given amount. More...
 
KAPI void camera_yaw (camera *c, f32 amount)
 Adjusts the camera's yaw by the given amount. More...
 
KAPI void camera_pitch (camera *c, f32 amount)
 Adjusts the camera's pitch by the given amount. More...
 

Detailed Description

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
1.0
Date
2022-05-21

Typedef Documentation

◆ camera

typedef struct camera camera

Represents a camera that can be used for a variety of things, especially rendering. Ideally, these are created and managed by the camera system.

Function Documentation

◆ camera_backward()

KAPI vec3 camera_backward ( camera c)

Returns a copy of the camera's backward vector.

Parameters
cA pointer to a camera.
Returns
A copy of the camera's backward vector.

◆ camera_create()

KAPI camera camera_create ( void  )

Creates a new camera with default zero position and rotation, and view identity matrix. Ideally, the camera system should be used to create this instead of doing so directly.

Returns
A copy of a newly-created camera.

◆ camera_forward()

KAPI vec3 camera_forward ( camera c)

Returns a copy of the camera's forward vector.

Parameters
cA pointer to a camera.
Returns
A copy of the camera's forward vector.

◆ camera_left()

KAPI vec3 camera_left ( camera c)

Returns a copy of the camera's left vector.

Parameters
cA pointer to a camera.
Returns
A copy of the camera's left vector.

◆ camera_move_backward()

KAPI void camera_move_backward ( camera c,
f32  amount 
)

Moves the camera backward by the given amount.

Parameters
cA pointer to a camera.
amountThe amount to move.

◆ camera_move_down()

KAPI void camera_move_down ( camera c,
f32  amount 
)

Moves the camera down (straight along the y-axis) by the given amount.

Parameters
cA pointer to a camera.
amountThe amount to move.

◆ camera_move_forward()

KAPI void camera_move_forward ( camera c,
f32  amount 
)

Moves the camera forward by the given amount.

Parameters
cA pointer to a camera.
amountThe amount to move.

◆ camera_move_left()

KAPI void camera_move_left ( camera c,
f32  amount 
)

Moves the camera left by the given amount.

Parameters
cA pointer to a camera.
amountThe amount to move.

◆ camera_move_right()

KAPI void camera_move_right ( camera c,
f32  amount 
)

Moves the camera right by the given amount.

Parameters
cA pointer to a camera.
amountThe amount to move.

◆ camera_move_up()

KAPI void camera_move_up ( camera c,
f32  amount 
)

Moves the camera up (straight along the y-axis) by the given amount.

Parameters
cA pointer to a camera.
amountThe amount to move.

◆ camera_pitch()

KAPI void camera_pitch ( camera c,
f32  amount 
)

Adjusts the camera's pitch by the given amount.

Parameters
cA pointer to a camera.
amountThe amount to adjust by.

◆ camera_position_get()

KAPI vec3 camera_position_get ( const camera c)

Gets a copy of the camera's position.

Parameters
cA constant pointer to a camera.
Returns
A copy of the camera's position.

◆ camera_position_set()

KAPI void camera_position_set ( camera c,
vec3  position 
)

Sets the provided camera's position.

Parameters
cA pointer to a camera.
positionThe position to be set.

◆ camera_reset()

KAPI void camera_reset ( camera c)

Defaults the provided camera to default zero rotation and position, and view matrix to identity.

Parameters
cA pointer to the camera to be reset.

◆ camera_right()

KAPI vec3 camera_right ( camera c)

Returns a copy of the camera's right vector.

Parameters
cA pointer to a camera.
Returns
A copy of the camera's right vector.

◆ camera_rotation_euler_get()

KAPI vec3 camera_rotation_euler_get ( const camera c)

Gets a copy of the camera's rotation in Euler angles.

Parameters
cA constant pointer to a camera.
Returns
A copy of the camera's rotation in Euler angles.

◆ camera_rotation_euler_set()

KAPI void camera_rotation_euler_set ( camera c,
vec3  rotation 
)

Sets the provided camera's rotation in Euler angles.

Parameters
cA pointer to a camera.
positionThe rotation in Euler angles to be set.

◆ camera_up()

KAPI vec3 camera_up ( camera c)

Returns a copy of the camera's up vector.

Parameters
cA pointer to a camera.
Returns
A copy of the camera's up vector.

◆ camera_view_get()

KAPI mat4 camera_view_get ( camera c)

Obtains a copy of the camera's view matrix. If camera is dirty, a new one is created, set and returned.

Parameters
cA pointer to a camera.
Returns
A copy of the up-to-date view matrix.

◆ camera_yaw()

KAPI void camera_yaw ( camera c,
f32  amount 
)

Adjusts the camera's yaw by the given amount.

Parameters
cA pointer to a camera.
amountThe amount to adjust by.