i6engine  1.0
PhysicsVelocityComponent.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_MODULES_PHYSICSVELOCITYCOMPONENT_H__
26 #define __I6ENGINE_MODULES_PHYSICSVELOCITYCOMPONENT_H__
27 
29 
31 
32 namespace i6e {
33 namespace modules {
34 
35  class PhysicsNode;
36 
42  public:
43  PhysicsVelocityComponent(PhysicsNode * node, double mass, double maxSpeed, double resistanceCoefficient, double windage);
44 
45  void accelerate(const Vec3 & acceleration, api::VelocityComponent::MaxSpeedHandling handling, const std::function<void(void)> & callback);
46 
47  void decelerate(const Vec3 & deceleration, api::VelocityComponent::DecelerationHandling handling, const std::function<void(void)> & callback);
48 
49  void stopAcceleration();
50 
51  inline void setMaxSpeed(double maxSpeed) {
52  _maxSpeed = maxSpeed;
53  }
54 
55  inline void setResistanceCoefficient(double resistanceCoefficient) {
56  _resistanceCoefficient = resistanceCoefficient;
57  }
58 
59  inline void setWindage(double windage) {
60  _windage = windage;
61  }
62 
63  void Tick();
64 
65  private:
66  PhysicsNode * _node;
67  double _mass;
68  double _maxSpeed;
69  double _resistanceCoefficient;
70  double _windage;
71  Vec3 _acceleration;
74  std::function<void(void)> _callback;
75  bool _accelerating;
76  bool _decelerating;
77 
79  };
80 
81 } /* namespace modules */
82 } /* namespace i6e */
83 
84 #endif /* __I6ENGINE_MODULES_PHYSICSVELOCITYCOMPONENT_H__ */
85 
Implements 3-dimensional vectors.
Definition: i6eVector.h:48
void setResistanceCoefficient(double resistanceCoefficient)
#define ASSERT_THREAD_SAFETY_HEADER
PhysicsVelocityComponent(PhysicsNode *node, double mass, double maxSpeed, double resistanceCoefficient, double windage)
Represents the physical state of an object simulated by the Bullet library. Contains the btTransform ...
Definition: PhysicsNode.h:81
Handles calculation of air friction.
void accelerate(const Vec3 &acceleration, api::VelocityComponent::MaxSpeedHandling handling, const std::function< void(void)> &callback)
void decelerate(const Vec3 &deceleration, api::VelocityComponent::DecelerationHandling handling, const std::function< void(void)> &callback)