forked from rtpHarry/Sokoban
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCamera.h
More file actions
103 lines (78 loc) · 2.81 KB
/
Camera.h
File metadata and controls
103 lines (78 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Camera.h: interface for the CCamera class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CAMERA_H__E4571EB4_1D90_4482_B860_117BD1F17214__INCLUDED_)
#define AFX_CAMERA_H__E4571EB4_1D90_4482_B860_117BD1F17214__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Vector3.h"
//////////////////////////////////////////////////////////////////////////
// Maths
// math utility functions
CVector3 Cross(CVector3 vVector1, CVector3 vVector2);
float Magnitude(CVector3 vNormal);
CVector3 Normalize(CVector3 vVector);
//////////////////////////////////////////////////////////////////////////
struct CameraOrientation
{
CVector3 m_Position;
CVector3 m_View;
};
#define kSpeed 0.02
// CCamera
///////////
// A camera class for easier control of movement within an openGL world
////////////////////////
class CCamera
{
public:
// access functions for member variables
CVector3 Position() { return m_vPosition; }
CVector3 View() { return m_vView; }
CVector3 UpVector() { return m_vUpVector; }
CVector3 Strafe() { return m_vStrafe; }
// default contructor / destructor
CCamera();
virtual ~CCamera();
// put a camera in a specific position
void PositionCamera (float positionX, float positionY, float positionZ, float viewX, float viewY, float viewZ, float upVectorX, float upVectorY, float upVectorZ);
// This type of viewing is used in most first person games.
//////////////
// call from key check function
void SetViewByMouse();
// this performs an axis-angle rotation around the camera's position
//////////////
// usage : positive number = left
// negative number = right
void RotateView(float angle, float x, float y, float z);
// rotate around a point, an object or third person camera model
void RotateAroundPoint(CVector3 vCenter, float angle, float x, float y, float z);
// This strafes the camera left or right depending on the speed (+/-)
void StrafeCamera(float speed);
// This checks for keyboard movement
// not in use :: currently handled by update() function in main app
void CheckForMovement();
// This uses gluLookAt() to tell OpenGL where to look
void Look();
// This updates the camera's view and other data (Should be called each frame)
void Update();
// move camera forwards or backwards
/////////////
// usage : positive number = forwards
// negative number = backwards
void MoveCamera (float speed);
private:
// camera's location and orientation
CVector3 m_vPosition;
CVector3 m_vView;
CVector3 m_vUpVector;
CVector3 m_vStrafe;
bool m_bMouseControlOn;
public:
// Toggle if the mouse controls the camera
void ToggleMouseControl(void);
// dumps the camera position to a file
void DEBUG_WritePositionToFile(void);
};
#endif // !defined(AFX_CAMERA_H__E4571EB4_1D90_4482_B860_117BD1F17214__INCLUDED_)