Tinman  1.0
carcontroller.h
Go to the documentation of this file.
1 // Copyright (C) 2014 ISAAC LACOBA MOLINA
2 // Tinman author: Isaac Lacoba Molina
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef CARCONTROLLER_H
18 #define CARCONTROLLER_H
19 #include <OgreSceneNode.h>
20 
21 #include "parser.h"
22 #include "powerup.h"
23 
24 enum class Direction {right, left};
25 
33 
34  std::vector<Ogre::SceneNode*> wheels_nodes_;
35 
36 
37  public:
38  const int rightIndex = 0;
39  const int upIndex = 1;
40  const int forwardIndex = 2;
41 
42  float mass_;
45  float wheel_width_;
52 
53  const btVector3 car_dimensions_ = btVector3(1, 0.5f, 2);
54  const btScalar suspension_rest_length_ = btScalar(0.5);
55  const btVector3 wheel_direction_cs0_ = btVector3(0,-1,0);
56  const btVector3 wheel_axle_cs_ = btVector3(-1,0,0);
57 
58  bool inverted_;
59 
60  typedef std::shared_ptr<CarController> shared;
61 
62  int nitro_;
63 
66 
67  CarController();
68  virtual ~CarController();
69  void realize( std::vector<Ogre::SceneNode*> wheels_nodes);
70 
71  void accelerate();
72  void stop_accelerating();
73 
74  void brake();
75  void stop_braking();
76 
77  void turn( Direction direction);
78  void stop_turning();
79 
80  void control_speed();
81 
82  virtual void update( float deltaT);
83 
84  void use_nitro();
85 
86  private:
87  void load_parameters(std::string file);
88  void update_lap(std::vector<Ogre::Vector3> checkpoints);
89 
90  void turn_wheels(Direction direction);
91  void reset_wheels();
92 
93  bool equals(float sut, float target, float delta) ;
94  float str_to_float(std::string string);
95 };
96 #endif
void stop_turning()
Definition: carcontroller.cpp:116
const int upIndex
Definition: carcontroller.h:39
Definition: carcontroller.h:26
float steering_clamp_
Definition: carcontroller.h:32
void control_speed()
Definition: carcontroller.cpp:122
int nitro_
Definition: carcontroller.h:62
float f_max_braking_
Definition: carcontroller.h:30
void turn_wheels(Direction direction)
Definition: carcontroller.cpp:97
Direction
Definition: carcontroller.h:24
float suspension_stiffness_
Definition: carcontroller.h:46
float gvehicle_steering_
Definition: carcontroller.h:43
float str_to_float(std::string string)
Definition: carcontroller.cpp:140
float f_engine_
Definition: carcontroller.h:64
float wheel_friction_
Definition: carcontroller.h:47
float wheel_width_
Definition: carcontroller.h:45
virtual void update(float deltaT)
Definition: carcontroller.cpp:135
void realize(std::vector< Ogre::SceneNode * > wheels_nodes)
Definition: carcontroller.cpp:46
bool accelerating_
Definition: carcontroller.h:65
const btVector3 car_dimensions_
Definition: carcontroller.h:53
float f_braking_
Definition: carcontroller.h:64
CarController()
Definition: carcontroller.cpp:4
float steering_increment_
Definition: carcontroller.h:31
void update_lap(std::vector< Ogre::Vector3 > checkpoints)
bool inverted_
Definition: carcontroller.h:58
const btVector3 wheel_axle_cs_
Definition: carcontroller.h:56
void accelerate()
Definition: carcontroller.cpp:51
float roll_influence_
Definition: carcontroller.h:50
const btScalar suspension_rest_length_
Definition: carcontroller.h:54
virtual ~CarController()
Definition: carcontroller.cpp:13
float mass_
Definition: carcontroller.h:42
void stop_accelerating()
Definition: carcontroller.cpp:61
float connection_height_
Definition: carcontroller.h:51
std::shared_ptr< CarController > shared
Definition: carcontroller.h:60
bool turning_
Definition: carcontroller.h:65
float wheel_radius_
Definition: carcontroller.h:44
bool equals(float sut, float target, float delta)
float suspension_compression_
Definition: carcontroller.h:49
float acceleration_
Definition: carcontroller.h:28
float f_max_engine_
Definition: carcontroller.h:27
void load_parameters(std::string file)
Definition: carcontroller.cpp:18
void brake()
Definition: carcontroller.cpp:68
void turn(Direction direction)
Definition: carcontroller.cpp:82
void reset_wheels()
Definition: carcontroller.cpp:108
float steering_
Definition: carcontroller.h:64
const int rightIndex
Definition: carcontroller.h:38
std::vector< Ogre::SceneNode * > wheels_nodes_
Definition: carcontroller.h:34
float deceleration_
Definition: carcontroller.h:29
const int forwardIndex
Definition: carcontroller.h:40
void stop_braking()
Definition: carcontroller.cpp:76
void use_nitro()
Definition: carcontroller.cpp:127
bool braking_
Definition: carcontroller.h:65
float suspension_damping_
Definition: carcontroller.h:48
const btVector3 wheel_direction_cs0_
Definition: carcontroller.h:55