SuperTuxKart
explosion_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_EXPLOSION_ANIMATION_HPP
20 #define HEADER_EXPLOSION_ANIMATION_HPP
21 
22 #include "karts/abstract_kart_animation.hpp"
23 #include "utils/vec3.hpp"
24 
38 {
39 protected:
40 friend class KartRewinder;
43 
46 
50 
52  float m_velocity;
53 
57 
59  btTransform m_reset_trans;
60 
61  /* Compressed values for server to send to avoid compressing everytime. */
62  int m_reset_trans_compressed[4];
63 
64  bool m_direct_hit;
65 
66  // ------------------------------------------------------------------------
67  void restoreData(BareNetworkString* b);
68  // ------------------------------------------------------------------------
69  void init(bool direct_hit, const Vec3& normal,
70  const btTransform& reset_trans);
71  // ------------------------------------------------------------------------
73  // ------------------------------------------------------------------------
74  ExplosionAnimation(AbstractKart* kart, bool direct_hit);
75 public:
76  // ------------------------------------------------------------------------
77  static ExplosionAnimation *create(AbstractKart* kart, const Vec3 &pos,
78  bool direct_hit);
79  // ------------------------------------------------------------------------
80  static ExplosionAnimation *create(AbstractKart *kart);
81  // ------------------------------------------------------------------------
82  virtual ~ExplosionAnimation();
83  // ------------------------------------------------------------------------
84  virtual void update(int ticks);
85  // ------------------------------------------------------------------------
86  virtual void updateGraphics(float dt);
87  // ------------------------------------------------------------------------
88  virtual KartAnimationType getAnimationType() const
89  { return KAT_EXPLOSION; }
90  // ------------------------------------------------------------------------
91  virtual void saveState(BareNetworkString* buffer);
92  // ------------------------------------------------------------------------
93  virtual void restoreState(BareNetworkString* buffer);
94  // ------------------------------------------------------------------------
95  bool hasResetAlready() const;
96 
97 }; // ExplosionAnimation
98 #endif
virtual void restoreState(BareNetworkString *p, int count) OVERRIDE
Actually rewind to the specified state.
Definition: kart_rewinder.cpp:275
Vec3 m_normal
The normal of kart when it started to explode.
Definition: explosion_animation.hpp:42
btTransform m_reset_trans
Used for reset kart back to flag base in CTF.
Definition: explosion_animation.hpp:59
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
static ExplosionAnimation * create(AbstractKart *kart, const Vec3 &pos, bool direct_hit)
A static create function that does only create an explosion if the explosion happens to be close enou...
Definition: explosion_animation.cpp:44
virtual void update(int ticks)
Updates the kart animation.
Definition: explosion_animation.cpp:246
virtual void updateGraphics(float dt) OVERRIDE
Updates the graphics model.
Definition: kart_rewinder.hpp:60
virtual void init(RaceManager::KartType type) OVERRIDE
This is a second initialisation phase, necessary since in the constructor virtual functions are not c...
Definition: kart.cpp:194
int m_reset_ticks
If not -1, when > world count up ticks it will use m_reset_trans below for animation.
Definition: explosion_animation.hpp:56
Definition: kart_rewinder.hpp:29
Vec3 m_add_rotation
The artificial rotation to toss the kart around.
Definition: explosion_animation.hpp:49
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:52
Vec3 m_curr_rotation
The kart's current rotation.
Definition: explosion_animation.hpp:45
virtual BareNetworkString * saveState(std::vector< std::string > *ru) OVERRIDE
Saves all state information for a kart in a memory buffer.
Definition: kart_rewinder.cpp:165
The base class for all kart animation, like rescue, explosion, or cannon.
Definition: abstract_kart_animation.hpp:59
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
This class is a &#39;mixin&#39; for kart, and handles the animated explosion.
Definition: explosion_animation.hpp:37
float m_velocity
The velocity with which the kart is moved.
Definition: explosion_animation.hpp:52