#include <Camera.h>
Collaboration diagram for pge::Camera:
Public Member Functions | |
Camera () | |
Constructor. | |
~Camera (void) | |
Destructor. | |
void | timer (unsigned int delay) |
Vector3f | getPosition (void) |
void | setPosition (Vector3f position) |
void | setXZAngle (float xzAngle) |
void | setXYAngle (float xyAngle) |
void | setDirection (Vector3f direction) |
void | forward (void) |
void | backward (void) |
void | turnLeft (int delta) |
void | turnRight (int delta) |
void | turnUp (int delta) |
void | turnDown (int delta) |
void | up (void) |
void | down (void) |
void | slideLeft (void) |
void | slideRight (void) |
void | applyCameraView (void) |
void | applyCameraRotation (void) |
void | applyCameraPosition (void) |
void | revertCameraView (void) |
Sphere * | getBoundingSphere (void) |
Private Member Functions | |
void | updateDirection (void) |
void | updatePhysics (unsigned int delay) |
Private Attributes | |
float | m_keyTurn |
float | m_turnSens |
float | m_xyMinAngle |
float | m_xyMaxAngle |
float | m_xzAngle |
float | m_xyAngle |
Vector3f | m_direction |
float | m_speedUp |
float | m_slowDown |
float | m_mass |
Vector3f | m_force |
Vector3f | m_velocity |
Sphere * | m_boundingSphere |
|
Constructor.
Definition at line 18 of file Camera.cpp. References m_boundingSphere, m_direction, m_force, m_keyTurn, m_mass, m_slowDown, m_speedUp, m_turnSens, m_velocity, m_xyAngle, m_xyMaxAngle, m_xyMinAngle, and m_xzAngle.
00018 { 00019 m_keyTurn = 0.1f; 00020 m_turnSens = 0.1f; 00021 m_xyMinAngle = -88.0f; 00022 m_xyMaxAngle = 88.0f; 00023 m_xzAngle = 0.0f; 00024 m_xyAngle = 0.0f; 00025 m_direction = Vector3f(0.0f, 0.0f, -1.0f); 00026 m_speedUp = 100.0f; 00027 m_slowDown = 0.1f; 00028 m_mass = 1.0f; 00029 m_force = Vector3f(); 00030 m_velocity = Vector3f(); 00031 00032 m_boundingSphere = new Sphere(Vector3f(0.0f, 10.0f, 0.0f), 1.0f); 00033 } |
|
Destructor.
Definition at line 41 of file Camera.cpp.
00041 { 00042 } |
|
Definition at line 292 of file Camera.cpp. References m_boundingSphere, pge::Sphere::m_center, and pge::Vector3f::m_v.
00292 { 00293 renderer::translate(-m_boundingSphere->m_center.m_v[0], -m_boundingSphere->m_center.m_v[1], 00294 -m_boundingSphere->m_center.m_v[2]); 00295 } |
|
Definition at line 281 of file Camera.cpp. References m_xyAngle, and m_xzAngle. Referenced by pge::World::render().
00281 { 00282 renderer::rotate(-m_xyAngle, 1.0f, 0.0f, 0.0f); 00283 renderer::rotate(180.0f - m_xzAngle, 0.0f, 1.0f, 0.0f); 00284 } |
|
Definition at line 266 of file Camera.cpp. References pge::Vector3f::add(), m_boundingSphere, pge::Sphere::m_center, m_direction, and pge::Vector3f::m_v. Referenced by pge::World::render().
00266 { 00267 Vector3f view = m_boundingSphere->m_center.add(m_direction); 00268 00269 00270 gluLookAt(m_boundingSphere->m_center.m_v[0], m_boundingSphere->m_center.m_v[1], 00271 m_boundingSphere->m_center.m_v[2], view.m_v[0], 00272 view.m_v[1], view.m_v[2], 0.0f, 1.0f, 0.0f); 00273 } |
Here is the call graph for this function:
|
Definition at line 120 of file Camera.cpp. References pge::Vector3f::add(), m_direction, m_force, m_speedUp, and pge::Vector3f::multiply(). Referenced by pge::World::action().
00120 { 00121 m_force = m_force.add(m_direction.multiply(-1.0f * m_speedUp)); 00122 } |
Here is the call graph for this function:
|
Definition at line 209 of file Camera.cpp. References pge::Vector3f::add(), m_force, m_speedUp, and pge::Vector3f::multiply(). Referenced by pge::World::action().
|
Here is the call graph for this function:
|
Definition at line 110 of file Camera.cpp. References pge::Vector3f::add(), m_direction, m_force, m_speedUp, and pge::Vector3f::multiply(). Referenced by pge::World::action().
00110 { 00111 m_force = m_force.add(m_direction.multiply(m_speedUp)); 00112 } |
Here is the call graph for this function:
|
Definition at line 315 of file Camera.cpp. References m_boundingSphere. Referenced by pge::SingleTexturedMesh::render().
00315 { 00316 return m_boundingSphere; 00317 } |
|
Definition at line 60 of file Camera.cpp. References m_boundingSphere, and pge::Sphere::m_center. Referenced by pge::SingleTexturedMesh::render().
00060 { 00061 return m_boundingSphere->m_center; 00062 } |
|
Definition at line 303 of file Camera.cpp. References m_boundingSphere, pge::Sphere::m_center, pge::Vector3f::m_v, m_xyAngle, and m_xzAngle.
00303 { 00304 renderer::rotate(-(180.0f - m_xzAngle), 0.0f, 1.0f, 0.0f); 00305 renderer::rotate(m_xyAngle, 1.0f, 0.0f, 0.0f); 00306 renderer::translate(m_boundingSphere->m_center.m_v[0], m_boundingSphere->m_center.m_v[1], m_boundingSphere->m_center.m_v[2]); 00307 } |
|
Definition at line 100 of file Camera.cpp. References m_direction.
00100 { 00101 m_direction = direction; 00102 } |
|
Definition at line 70 of file Camera.cpp. References m_boundingSphere, and pge::Sphere::m_center.
00070 { 00071 m_boundingSphere->m_center = position; 00072 } |
|
Definition at line 90 of file Camera.cpp. References m_xyAngle.
00090 { 00091 m_xyAngle = xyAngle; 00092 } |
|
Definition at line 80 of file Camera.cpp. References m_xzAngle.
00080 { 00081 m_xzAngle = xzAngle; 00082 } |
|
Definition at line 222 of file Camera.cpp. References pge::Vector3f::add(), m_force, m_speedUp, pge::Vector3f::m_v, m_xzAngle, pge::Vector3f::multiply(), pge::Vector3f::normalize(), and PIOVER180. Referenced by pge::World::action().
00222 { 00223 Vector3f force = Vector3f(0.0f, 0.0f, 0.0f); 00224 float x; 00225 float z; 00226 00227 x = (float)sin((90.0f + m_xzAngle) * PIOVER180); 00228 z = (float)cos((90.0f + m_xzAngle) * PIOVER180); 00229 00230 force.m_v[0] = x; 00231 force.m_v[2] = z; 00232 force.normalize(); 00233 force = force.multiply(m_speedUp); 00234 00235 m_force = m_force.add(force); 00236 } |
Here is the call graph for this function:
|
Definition at line 244 of file Camera.cpp. References pge::Vector3f::add(), m_force, m_speedUp, pge::Vector3f::m_v, m_xzAngle, pge::Vector3f::multiply(), pge::Vector3f::normalize(), and PIOVER180. Referenced by pge::World::action().
00244 { 00245 Vector3f force = Vector3f(0.0f, 0.0f, 0.0f); 00246 float x; 00247 float z; 00248 00249 x = (float)sin((270.0f + m_xzAngle) * PIOVER180); 00250 z = (float)cos((270.0f + m_xzAngle) * PIOVER180); 00251 00252 force.m_v[0] = x; 00253 force.m_v[2] = z; 00254 force.normalize(); 00255 force = force.multiply(m_speedUp); 00256 00257 m_force = m_force.add(force); 00258 } |
Here is the call graph for this function:
|
Definition at line 50 of file Camera.cpp. References updatePhysics(). Referenced by pge::World::timer().
00050 { 00051 updatePhysics(delay); 00052 } |
Here is the call graph for this function:
|
Definition at line 178 of file Camera.cpp. References m_keyTurn, m_turnSens, m_xyAngle, m_xyMinAngle, and updateDirection(). Referenced by pge::World::action().
00178 { 00179 if(m_xyAngle > m_xyMinAngle) { 00180 // If delta is -1 we have a keystroke. 00181 if(delta == -1) { 00182 m_xyAngle -= m_keyTurn; 00183 } else { 00184 m_xyAngle -= (m_turnSens * (float)delta); 00185 } 00186 } 00187 updateDirection(); 00188 } |
Here is the call graph for this function:
|
Definition at line 130 of file Camera.cpp. References m_keyTurn, m_turnSens, m_xzAngle, and updateDirection(). Referenced by pge::World::action().
00130 { 00131 if(delta == -1) { 00132 m_xzAngle += m_keyTurn; 00133 } else { 00134 m_xzAngle += (m_turnSens * (float)delta); 00135 } 00136 updateDirection(); 00137 } |
Here is the call graph for this function:
|
Definition at line 145 of file Camera.cpp. References m_keyTurn, m_turnSens, m_xzAngle, and updateDirection(). Referenced by pge::World::action().
00145 { 00146 if(delta == -1) { 00147 m_xzAngle -= m_keyTurn; 00148 } else { 00149 m_xzAngle -= (m_turnSens * (float)delta); 00150 } 00151 updateDirection(); 00152 } |
Here is the call graph for this function:
|
Definition at line 160 of file Camera.cpp. References m_keyTurn, m_turnSens, m_xyAngle, m_xyMaxAngle, and updateDirection(). Referenced by pge::World::action().
00160 { 00161 if(m_xyAngle < m_xyMaxAngle) { 00162 // If delta is -1 we have a keystroke. 00163 if(delta == -1) { 00164 m_xyAngle += m_keyTurn; 00165 } else { 00166 m_xyAngle += (m_turnSens * (float)delta); 00167 } 00168 } 00169 updateDirection(); 00170 } |
Here is the call graph for this function:
|
Definition at line 196 of file Camera.cpp. References pge::Vector3f::add(), m_force, m_speedUp, and pge::Vector3f::multiply(). Referenced by pge::World::action().
|
Here is the call graph for this function:
|
Definition at line 325 of file Camera.cpp. References m_direction, pge::Vector3f::m_v, m_xyAngle, and m_xzAngle. Referenced by turnDown(), turnLeft(), turnRight(), and turnUp().
00325 { 00326 float x; 00327 float y; 00328 float z; 00329 x = (float)sin(mathutils::degreeToRadian(m_xzAngle)); 00330 y = (float)sin(mathutils::degreeToRadian(m_xyAngle)); 00331 z = (float)cos(mathutils::degreeToRadian(m_xzAngle)); 00332 00333 m_direction.m_v[0] = x; 00334 m_direction.m_v[1] = y; 00335 m_direction.m_v[2] = z; 00336 } |
|
Definition at line 344 of file Camera.cpp. References pge::Vector3f::add(), pge::Vector3f::divide(), m_boundingSphere, pge::Sphere::m_center, m_force, m_mass, m_slowDown, pge::Vector3f::m_v, m_velocity, pge::Vector3f::multiply(), and pge::Vector3f::subtract(). Referenced by timer().
00344 { 00345 // 00346 // Variables 00347 // 00348 float deltaTime; 00349 00350 deltaTime = (float) delay / 1000.0f; 00351 00352 // Calculate new velocity 00353 m_velocity = m_velocity.add((m_force.divide(m_mass)).multiply(deltaTime)); 00354 00355 // Apply velocity to position 00356 m_boundingSphere->m_center = m_boundingSphere->m_center.add(m_velocity.multiply(deltaTime)); 00357 00358 // Reset force. 00359 m_force.m_v[0] = 0.0f; 00360 m_force.m_v[1] = 0.0f; 00361 m_force.m_v[2] = 0.0f; 00362 00363 // Make the object loose velocity when there is no force added. 00364 // We do this by subtracting the velocity vector multiplied by a constant 00365 // smaller than 1.0f, so we do not subtract the full vector but only a smaller one. 00366 m_velocity = m_velocity.subtract(m_velocity.multiply(m_slowDown)); 00367 } |
Here is the call graph for this function:
|
Definition at line 96 of file Camera.h. Referenced by applyCameraPosition(), applyCameraView(), Camera(), getBoundingSphere(), getPosition(), revertCameraView(), setPosition(), and updatePhysics(). |
|
Definition at line 88 of file Camera.h. Referenced by applyCameraView(), backward(), Camera(), forward(), setDirection(), and updateDirection(). |
|
Definition at line 93 of file Camera.h. Referenced by backward(), Camera(), down(), forward(), slideLeft(), slideRight(), up(), and updatePhysics(). |
|
Definition at line 80 of file Camera.h. Referenced by Camera(), turnDown(), turnLeft(), turnRight(), and turnUp(). |
|
Definition at line 92 of file Camera.h. Referenced by Camera(), and updatePhysics(). |
|
Definition at line 91 of file Camera.h. Referenced by Camera(), and updatePhysics(). |
|
Definition at line 90 of file Camera.h. Referenced by backward(), Camera(), down(), forward(), slideLeft(), slideRight(), and up(). |
|
Definition at line 81 of file Camera.h. Referenced by Camera(), turnDown(), turnLeft(), turnRight(), and turnUp(). |
|
Definition at line 94 of file Camera.h. Referenced by Camera(), and updatePhysics(). |
|
Definition at line 87 of file Camera.h. Referenced by applyCameraRotation(), Camera(), revertCameraView(), setXYAngle(), turnDown(), turnUp(), and updateDirection(). |
|
|
|
Definition at line 83 of file Camera.h. Referenced by Camera(), and turnDown(). |
|
Definition at line 86 of file Camera.h. Referenced by applyCameraRotation(), Camera(), revertCameraView(), setXZAngle(), slideLeft(), slideRight(), turnLeft(), turnRight(), and updateDirection(). |