mElite
1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
mElite
CameraObject.cpp
Go to the documentation of this file.
1
6
#include "
CameraObject.h
"
7
#include "
GlobalGL.h
"
8
10
15
CameraObject::CameraObject
( ) :
MovingObject
( ) {
16
m_rearView =
false
;
17
m_moveSpeed = 1;
18
}
19
21
27
CameraObject::CameraObject
(
Vector3
position ) :
MovingObject
( position ) {
28
m_rearView =
false
;
29
m_moveSpeed = 1;
30
}
31
33
41
CameraObject::CameraObject
(
float
x
,
float
y
,
float
z
) :
MovingObject
( x, y, z ) {
42
m_rearView =
false
;
43
m_moveSpeed = 1;
44
}
45
49
CameraObject::~CameraObject
(
void
) {
50
51
}
52
56
bool
CameraObject::isRearView
() {
57
return
m_rearView;
58
}
59
60
65
void
CameraObject::look
() {
66
if
( m_rearView )
67
gluLookAt(
getPos
().
x
,
getPos
().
y
,
getPos
().
z
,
getPos
().
x
-
getView
().
x
,
getPos
().
y
-
getView
().
y
,
getPos
().
z
-
getView
().
z
,
getUp
().
x
,
getUp
().
y
,
getUp
().
z
);
68
else
69
gluLookAt(
getPos
().
x
,
getPos
().
y
,
getPos
().
z
,
getPos
().
x
+
getView
().
x
,
getPos
().
y
+
getView
().
y
,
getPos
().
z
+
getView
().
z
,
getUp
().
x
,
getUp
().
y
,
getUp
().
z
);
70
}
71
75
void
CameraObject::toggleRearView
() {
76
m_rearView = !m_rearView;
77
}
78
80
85
void
CameraObject::moveDown
(
float
t ) {
86
setPos
(
getPos
().
x
- t * m_moveSpeed *
getUp
().
x
,
getPos
().
y
- t * m_moveSpeed *
getUp
().
y
,
getPos
().
z
- t * m_moveSpeed *
getUp
().
z
);
87
}
88
90
95
void
CameraObject::moveLeft
(
float
t ) {
96
setPos
(
getPos
().
x
- t * m_moveSpeed *
getRight
().
x
,
getPos
().
y
- t * m_moveSpeed *
getRight
().
y
,
getPos
().
z
- t * m_moveSpeed *
getRight
().
z
);
97
}
98
100
105
void
CameraObject::moveRight
(
float
t ) {
106
setPos
(
getPos
().
x
+ t * m_moveSpeed *
getRight
().
x
,
getPos
().
y
+ t * m_moveSpeed *
getRight
().
y
,
getPos
().
z
+ t * m_moveSpeed *
getRight
().
z
);
107
}
108
110
115
void
CameraObject::moveUp
(
float
t ) {
116
setPos
(
getPos
().
x
+ t * m_moveSpeed *
getUp
().
x
,
getPos
().
y
+ t * m_moveSpeed *
getUp
().
y
,
getPos
().
z
+ t * m_moveSpeed *
getUp
().
z
);
117
}
118
123
void
CameraObject::setMoveSpeed
(
float
speed ) {
124
m_moveSpeed = speed;
125
}
Generated on Tue Oct 2 2012 14:38:37 for mElite by
1.8.2