2015-07-13 19:17:05 +03:00
|
|
|
/*******************************************************************************************
|
|
|
|
*
|
|
|
|
* raylib Camera System - Camera Modes Setup and Control Functions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015 Marc Palau and Ramon Santamaria
|
|
|
|
*
|
|
|
|
* This software is provided "as-is", without any express or implied warranty. In no event
|
|
|
|
* will the authors be held liable for any damages arising from the use of this software.
|
|
|
|
*
|
|
|
|
* Permission is granted to anyone to use this software for any purpose, including commercial
|
|
|
|
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
|
|
|
*
|
|
|
|
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
|
|
|
* wrote the original software. If you use this software in a product, an acknowledgment
|
|
|
|
* in the product documentation would be appreciated but is not required.
|
|
|
|
*
|
|
|
|
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
|
|
|
* as being the original software.
|
|
|
|
*
|
|
|
|
* 3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*
|
|
|
|
**********************************************************************************************/
|
|
|
|
|
|
|
|
#ifndef CAMERA_H
|
|
|
|
#define CAMERA_H
|
|
|
|
|
2015-07-29 22:42:11 +03:00
|
|
|
#ifndef PI
|
|
|
|
#define PI 3.14159265358979323846
|
|
|
|
#endif
|
|
|
|
|
2016-02-03 19:45:28 +03:00
|
|
|
#define DEG2RAD (PI/180.0f)
|
|
|
|
#define RAD2DEG (180.0f/PI)
|
2015-07-13 19:17:05 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Defines and Macros
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
//...
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Types and Structures Definition
|
2015-07-29 22:42:11 +03:00
|
|
|
// NOTE: Below types are required for CAMERA_STANDALONE usage
|
2015-07-13 19:17:05 +03:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Camera modes
|
|
|
|
typedef enum { CAMERA_CUSTOM = 0, CAMERA_FREE, CAMERA_ORBITAL, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON } CameraMode;
|
|
|
|
|
2015-07-29 22:42:11 +03:00
|
|
|
// Vector2 type
|
|
|
|
typedef struct Vector2 {
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
} Vector2;
|
|
|
|
|
|
|
|
// Vector3 type
|
|
|
|
typedef struct Vector3 {
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
} Vector3;
|
|
|
|
|
|
|
|
// Camera type, defines a camera position/orientation in 3d space
|
|
|
|
typedef struct Camera {
|
|
|
|
Vector3 position;
|
|
|
|
Vector3 target;
|
|
|
|
Vector3 up;
|
|
|
|
} Camera;
|
2015-07-13 19:17:05 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" { // Prevents name mangling of functions
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Global Variables Definition
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
//...
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Module Functions Declaration
|
|
|
|
//----------------------------------------------------------------------------------
|
2015-07-29 22:42:11 +03:00
|
|
|
void SetCameraMode(int mode); // Set camera mode (multiple camera modes available)
|
2015-08-30 18:46:19 +03:00
|
|
|
void UpdateCamera(Camera *camera); // Update camera (player position is ignored)
|
|
|
|
void UpdateCameraPlayer(Camera *camera, Vector3 *position); // Update camera and player position (1st person and 3rd person cameras)
|
2015-07-29 22:42:11 +03:00
|
|
|
|
2015-08-28 15:14:12 +03:00
|
|
|
void SetCameraPosition(Vector3 position); // Set internal camera position
|
|
|
|
void SetCameraTarget(Vector3 target); // Set internal camera target
|
2016-03-05 15:05:45 +03:00
|
|
|
void SetCameraFovy(float fovy); // Set internal camera field-of-view-y
|
2015-07-29 22:42:11 +03:00
|
|
|
|
|
|
|
void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera)
|
|
|
|
void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera)
|
|
|
|
void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera)
|
|
|
|
|
2015-08-28 15:14:12 +03:00
|
|
|
void SetCameraMoveControls(int frontKey, int backKey,
|
|
|
|
int leftKey, int rightKey,
|
|
|
|
int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras)
|
2015-07-29 22:42:11 +03:00
|
|
|
void SetCameraMouseSensitivity(float sensitivity); // Set camera mouse sensitivity (1st person and 3rd person cameras)
|
2015-07-13 19:17:05 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // CAMERA_H
|