SuperTuxKart
camera_normal.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_NORMAL_HPP
22 #define HEADER_CAMERA_NORMAL_HPP
23 
24 #include "graphics/camera/camera.hpp"
25 
26 #include "utils/cpp2011.hpp"
27 
32 class CameraNormal : public Camera
33 {
34 
35 private:
36 
38  video::SColor m_ambient_light;
39 
41  float m_distance;
42 
45 
48 
51 
52  Vec3 m_camera_offset;
53 
54  Mode m_last_smooth_mode;
55 
56  void moveCamera(float dt, bool smooth, float cam_angle, float distance);
57 
58  void getCameraSettings(Mode mode,
59  float *above_kart, float *cam_angle,
60  float *side_way, float *distance,
61  bool *smoothing, float *cam_roll_angle);
62 
63  void positionCamera(float dt, float above_kart, float cam_angle,
64  float side_way, float distance, float smoothing,
65  float cam_roll_angle);
66 
67  btVector3 m_kart_position;
68  btQuaternion m_kart_rotation;
69 
70  // Give a few classes access to the constructor (mostly for inheritance)
71  friend class Camera;
72  friend class CameraDebug;
73  friend class CameraEnd;
74  CameraNormal(Camera::CameraType type, int camera_index,
75  AbstractKart* kart);
76  virtual ~CameraNormal() {}
77 public:
78 
79  void restart();
80  // ------------------------------------------------------------------------
81  bool isDebug() { return false; }
82  // ------------------------------------------------------------------------
83  bool isFPS() { return false; }
84  // ------------------------------------------------------------------------
85  virtual void update(float dt) OVERRIDE;
86  // ------------------------------------------------------------------------
88  void setAmbientLight(const video::SColor &color) { m_ambient_light=color; }
89  // ------------------------------------------------------------------------
90  void setDistanceToKart(float distance) { m_distance = distance; }
91  // ------------------------------------------------------------------------
92  float getDistanceToKart() const { return m_distance; }
93  // ------------------------------------------------------------------------
95  const video::SColor &getAmbientLight() const {return m_ambient_light; }
96 
97 }; // class CameraNormal
98 
99 #endif
100 
101 /* EOF */
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Handles the debug camera.
Definition: camera_debug.hpp:34
Handles the end race camera.
Definition: camera_end.hpp:34
Handles the normal racing camera.
Definition: camera_normal.hpp:33
float m_target_speed
The speed at which the camera target changes position.
Definition: camera_normal.hpp:47
virtual void update(float dt) OVERRIDE
Called once per time frame to move the camera to the right position.
Definition: camera_normal.cpp:303
CameraNormal(Camera::CameraType type, int camera_index, AbstractKart *kart)
Constructor for the normal camera.
Definition: camera_normal.cpp:45
float m_distance
Distance between the camera and the kart.
Definition: camera_normal.hpp:41
float m_position_speed
The speed at which the camera changes position.
Definition: camera_normal.hpp:44
const video::SColor & getAmbientLight() const
Returns the current ambient light.
Definition: camera_normal.hpp:95
float m_rotation_range
Factor of the effects of steering in camera aim.
Definition: camera_normal.hpp:50
video::SColor m_ambient_light
Current ambient light for this camera.
Definition: camera_normal.hpp:38
void getCameraSettings(Mode mode, float *above_kart, float *cam_angle, float *side_way, float *distance, bool *smoothing, float *cam_roll_angle)
Determine the camera settings for the current frame.
Definition: camera_normal.cpp:192
void positionCamera(float dt, float above_kart, float cam_angle, float side_way, float distance, float smoothing, float cam_roll_angle)
Actually sets the camera based on the given parameter.
Definition: camera_normal.cpp:361
void moveCamera(float dt, bool smooth, float cam_angle, float distance)
Moves the camera smoothly from the current camera position (and target) to the new position and targe...
Definition: camera_normal.cpp:77
void setAmbientLight(const video::SColor &color)
Sets the ambient light for this camera.
Definition: camera_normal.hpp:88
This is the base class for all cameras.
Definition: camera.hpp:49
CameraType
The different camera types that can be used.
Definition: camera.hpp:53
Mode
Definition: camera.hpp:62
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35