SuperTuxKart
cannon_animation.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2012-2015 Joerg Henrichs
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program 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
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_CANNON_ANIMATION_HPP
20 #define HEADER_CANNON_ANIMATION_HPP
21 
22 #include "karts/abstract_kart_animation.hpp"
23 #include "utils/vec3.hpp"
24 
25 #include "LinearMath/btQuaternion.h"
26 
27 class AbstractKart;
28 class AnimationBase;
29 class CheckCannon;
30 class Flyable;
31 class Ipo;
32 
39 {
40 protected:
41 friend class KartRewinder;
42 friend class Flyable;
43  // ------------------------------------------------------------------------
45  // ------------------------------------------------------------------------
46  CannonAnimation(Flyable* flyable, BareNetworkString* buffer);
47  // ------------------------------------------------------------------------
48  void init(Ipo *ipo, const Vec3 &start_left, const Vec3 &start_right,
49  const Vec3 &end_left, const Vec3 &end_right, float skid_rot);
50  // ------------------------------------------------------------------------
51  void initDeltaHeading(float skidding_rotation);
52  // ------------------------------------------------------------------------
53  void restoreData(BareNetworkString* buffer);
54 
55 private:
58 
59  /* Skidding rotation by the time the kart enter this cannon,
60  * will be restored during rewind, */
61  float m_skid_rot;
62 
68 
71 
75 
79 
83 
87 
90  btQuaternion m_delta_heading;
91 
95 
96 public:
98  float skid_rot);
99  CannonAnimation(Flyable *flyable, CheckCannon* cc);
100  virtual ~CannonAnimation();
101  virtual void update(int ticks);
102  // ------------------------------------------------------------------------
103  virtual KartAnimationType getAnimationType() const { return KAT_CANNON; }
104  // ------------------------------------------------------------------------
105  virtual void saveState(BareNetworkString* buffer);
106  // ------------------------------------------------------------------------
107  virtual void restoreState(BareNetworkString* buffer);
108 }; // CannonAnimation
109 #endif
Implements a simple checkline that will cause a kart or flyable to be shot to a specified point...
Definition: check_cannon.hpp:45
This animation shoots the kart to a specified point on the track.
Definition: cannon_animation.hpp:38
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
virtual void update(int ticks)
Updates the kart animation.
Definition: cannon_animation.cpp:259
float m_start_line_length
Length of the (adjusted, i.e.
Definition: cannon_animation.hpp:78
virtual void restoreState(BareNetworkString *buffer, int count) OVERRIDE
Called when a state needs to be replayed.
Definition: flyable.cpp:694
AnimationBase * m_curve
Stores the curve interpolation for the cannon.
Definition: cannon_animation.hpp:70
void init(Ipo *ipo, const Vec3 &start_left, const Vec3 &start_right, const Vec3 &end_left, const Vec3 &end_right, float skid_rot)
Common initialisation for kart-based and flyable-based animations.
Definition: cannon_animation.cpp:114
CheckCannon * m_check_cannon
The CheckCannon which created this animation.
Definition: cannon_animation.hpp:57
uint32_t m_current_rotation
Current rotation of the object, saved for rewinding usage if needed, it will be compressed by MiniGLM...
Definition: cannon_animation.hpp:94
CannonAnimation(AbstractKart *kart, BareNetworkString *buffer)
The constructor for the cannon animation for kart during rewind.
Definition: cannon_animation.cpp:64
virtual BareNetworkString * saveState(std::vector< std::string > *ru) OVERRIDE
Provides a copy of the state of the object in one memory buffer.
Definition: flyable.cpp:669
Vec3 m_delta
This is the difference between the position of the kart when the cannon line is crossed and the curve...
Definition: cannon_animation.hpp:67
A base class for all animations.
Definition: animation_base.hpp:40
Definition: kart_rewinder.hpp:29
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:52
float m_end_line_length
Length of the (adjusted, i.e.
Definition: cannon_animation.hpp:82
Flyable * m_flyable
If this animation is used for a flyable (e.g.
Definition: cannon_animation.hpp:74
float m_fraction_of_line
Stores the position of the kart relative to the line width at the current location.
Definition: cannon_animation.hpp:86
Definition: flyable.hpp:48
The base class for all kart animation, like rescue, explosion, or cannon.
Definition: abstract_kart_animation.hpp:59
A class to manage a single blender IPO curve.
Definition: ipo.hpp:37
btQuaternion m_delta_heading
The initial heading of the kart when crossing the line.
Definition: cannon_animation.hpp:90
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61