SuperTuxKart
camera_fps.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2004-2015 Steve Baker <sjbaker1@airmail.net>
4 // Copyright (C) 2006-2015 SuperTuxKart-Team, Steve Baker
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 3
9 // of the License, or (at your option) any later version.
10 //
11 
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 
21 #ifndef HEADER_CAMERA_FPS_HPP
22 #define HEADER_CAMERA_FPS_HPP
23 
24 #include "graphics/camera.hpp"
25 
26 #include "utils/cpp2011.hpp"
27 
28 class AbstractKart;
29 
34 class CameraFPS : public Camera
35 {
36 private:
39 
42 
45 
47  bool m_smooth;
48 
51  bool m_attached;
52 
55 
58 
61 
64  core::vector3df m_lin_velocity;
65 
67  core::vector3df m_target_velocity;
68 
70  core::vector3df m_target_direction;
71 
73  core::vector3df m_direction_velocity;
74 
76  core::vector3df m_target_up_vector;
77 
79  core::vector3df m_local_position;
80 
82  core::vector3df m_local_direction;
83 
85  core::vector3df m_local_up;
86 
87 
88 
89  void positionCamera(float dt, float above_kart, float cam_angle,
90  float side_way, float distance, float smoothing);
91 
92  friend class Camera;
93  CameraFPS(int camera_index, AbstractKart* kart);
94  virtual ~CameraFPS();
95 public:
96  // ------------------------------------------------------------------------
97  static bool isFPS() { return true; }
98  // ------------------------------------------------------------------------
99 
100  virtual void update(float dt) OVERRIDE;
101  // ------------------------------------------------------------------------
103  void applyMouseMovement (float x, float y);
104 
105  // ------------------------------------------------------------------------
107  void setSmoothMovement (bool value) { m_smooth = value; }
108 
109  // ------------------------------------------------------------------------
111  bool getSmoothMovement () { return m_smooth; }
112 
113  // ------------------------------------------------------------------------
115  void setAttachedFpsCam (bool value) { m_attached = value; }
116 
117  // ------------------------------------------------------------------------
119  bool getAttachedFpsCam () { return m_attached; }
120 
121  // ------------------------------------------------------------------------
123  void setMaximumVelocity (float vel) { m_max_velocity = vel; }
124 
125  // ------------------------------------------------------------------------
127  float getMaximumVelocity () { return m_max_velocity; }
128 
129  // ------------------------------------------------------------------------
131  void setDirection (core::vector3df target) { m_target_direction = target; }
132 
133  // ------------------------------------------------------------------------
135  const core::vector3df &getDirection () { return m_target_direction; }
136 
137  // ------------------------------------------------------------------------
139  void setUpVector (core::vector3df target) { m_target_up_vector = target; }
140 
141  // ------------------------------------------------------------------------
143  const core::vector3df &getUpVector () { return m_target_up_vector; }
144 
145  // ------------------------------------------------------------------------
147  void setAngularVelocity (float vel);
148 
149  // ------------------------------------------------------------------------
151  float getAngularVelocity ();
152 
153  // ------------------------------------------------------------------------
155  void setLinearVelocity (core::vector3df vel);
156 
157  // ------------------------------------------------------------------------
159  const core::vector3df &getLinearVelocity ();
160 
161 }; // class CameraFPS
162 
163 #endif
164 
165 /* EOF */
core::vector3df m_target_direction
The target direction for the camera, only used for the first person camera.
Definition: camera_fps.hpp:70
void setSmoothMovement(bool value)
Sets if the first person camera should be moved smooth.
Definition: camera_fps.hpp:107
bool m_attached
Attache the first person camera to a kart.
Definition: camera_fps.hpp:51
const core::vector3df & getDirection()
Gets the vector, the first person camera should look at.
Definition: camera_fps.hpp:135
float m_target_angular_velocity
Target angular velocity.
Definition: camera_fps.hpp:57
virtual void update(float dt) OVERRIDE
Called once per time frame to move the camera to the right position.
Definition: camera_fps.cpp:120
core::vector3df m_direction_velocity
The speed at which the direction changes, only used for the first person camera.
Definition: camera_fps.hpp:73
bool getAttachedFpsCam()
If the first person camera should be moved with the kart.
Definition: camera_fps.hpp:119
void setLinearVelocity(core::vector3df vel)
Sets the linear velocity for this camera.
Definition: camera_fps.cpp:272
float getMaximumVelocity()
Returns the current angular velocity.
Definition: camera_fps.hpp:127
void setAttachedFpsCam(bool value)
Sets if the first person camera should be moved with the kart.
Definition: camera_fps.hpp:115
float m_position_speed
The speed at which the camera changes position.
Definition: camera_fps.hpp:38
const core::vector3df & getLinearVelocity()
Returns the current linear velocity.
Definition: camera_fps.cpp:282
void setMaximumVelocity(float vel)
Sets the angular velocity for this camera.
Definition: camera_fps.hpp:123
const core::vector3df & getUpVector()
Gets the up vector, the first person camera should use.
Definition: camera_fps.hpp:143
core::vector3df m_local_direction
Save the local direction if the first person camera is attached to the kart.
Definition: camera_fps.hpp:82
void setDirection(core::vector3df target)
Sets the vector, the first person camera should look at.
Definition: camera_fps.hpp:131
float m_rotation_range
Factor of the effects of steering in camera aim.
Definition: camera_fps.hpp:44
float m_max_velocity
Maximum velocity for fps camera.
Definition: camera_fps.hpp:60
core::vector3df m_local_position
Save the local position if the first person camera is attached to the kart.
Definition: camera_fps.hpp:79
void applyMouseMovement(float x, float y)
Applies mouse movement to the first person camera.
Definition: camera_fps.cpp:74
core::vector3df m_target_up_vector
The up vector the camera should have, only used for the first person camera.
Definition: camera_fps.hpp:76
core::vector3df m_local_up
Save the local up vector if the first person camera is attached to the kart.
Definition: camera_fps.hpp:85
float getAngularVelocity()
Returns the current target angular velocity.
Definition: camera_fps.cpp:262
core::vector3df m_target_velocity
Velocity of the target of the camera, used for end and first person camera.
Definition: camera_fps.hpp:67
virtual ~CameraFPS()
Removes the camera scene node from the scene.
Definition: camera_fps.cpp:65
float m_target_speed
The speed at which the camera target changes position.
Definition: camera_fps.hpp:41
void setAngularVelocity(float vel)
Sets the angular velocity for this camera.
Definition: camera_fps.cpp:252
bool m_smooth
Smooth acceleration with the first person camera.
Definition: camera_fps.hpp:47
core::vector3df m_lin_velocity
Linear velocity of the camera, used for end and first person camera.
Definition: camera_fps.hpp:64
bool getSmoothMovement()
If the first person camera should be moved smooth.
Definition: camera_fps.hpp:111
float m_angular_velocity
The speed at which the up-vector rotates, only used for the first person camera.
Definition: camera_fps.hpp:54
This is the base class for all cameras.
Definition: camera.hpp:48
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
void setUpVector(core::vector3df target)
Sets the up vector, the first person camera should use.
Definition: camera_fps.hpp:139
Handles the game camera.
Definition: camera_fps.hpp:34