Emergency 20 Dokumentation  4.2.0
SimpleFireHoseComponent.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
17 #include <qsf/math/Transform.h>
18 #include <qsf/job/JobProxy.h>
20 
21 
22 //[-------------------------------------------------------]
23 //[ Forward declarations ]
24 //[-------------------------------------------------------]
25 namespace Ogre
26 {
27  class SceneNode;
28  namespace v1
29  {
30  class Entity;
31  }
32 }
33 namespace em5
34 {
35  class SimpleFireHoseMeshGenerator;
36 }
37 
38 
39 //[-------------------------------------------------------]
40 //[ Namespace ]
41 //[-------------------------------------------------------]
42 namespace em5
43 {
44 
45 
46  //[-------------------------------------------------------]
47  //[ Classes ]
48  //[-------------------------------------------------------]
57  {
58 
59 
60  //[-------------------------------------------------------]
61  //[ Friends ]
62  //[-------------------------------------------------------]
64 
65 
66  //[-------------------------------------------------------]
67  //[ Public definitions ]
68  //[-------------------------------------------------------]
69  public:
70  static const uint32 COMPONENT_ID;
71 
72 
73  //[-------------------------------------------------------]
74  //[ Public static methods ]
75  //[-------------------------------------------------------]
76  public:
77  static SimpleFireHoseComponent& createFirehoseBetweenEntities(qsf::Entity& hydrant, const std::string& hydrantBoneName, qsf::Entity& nozzle, const std::string& nozzleBoneName);
78 
79 
80  //[-------------------------------------------------------]
81  //[ Public methods ]
82  //[-------------------------------------------------------]
83  public:
91  inline explicit SimpleFireHoseComponent(qsf::Prototype* prototype);
92 
97  inline virtual ~SimpleFireHoseComponent();
98 
99  void initializeWithEntities(qsf::Entity& connector, const std::string& connectorBoneName, qsf::Entity& nozzle, const std::string& nozzleBoneName);
100 
105  void getWaypoints(std::vector<glm::vec3>& outWaypoints);
106 
107  bool isGhost() const;
108 
109 
110  //[-------------------------------------------------------]
111  //[ Public virtual qsf::Component methods ]
112  //[-------------------------------------------------------]
113  public:
114  void serialize(qsf::BinarySerializer& serializer);
115 
116 
117  //[-------------------------------------------------------]
118  //[ Protected virtual qsf::Component methods ]
119  //[-------------------------------------------------------]
120  protected:
121  virtual bool onStartup() override;
122  virtual void onShutdown() override;
123  virtual void onSetSimulating(bool simulating) override;
124 
125 
126  //[-------------------------------------------------------]
127  //[ Private declarations ]
128  //[-------------------------------------------------------]
129  private:
130  struct Section : public qsf::FastPodAllocator<Section>
131  {
132  qsf::Transform mStartTransform;
133  qsf::Transform mEndTransform;
134  mutable float mLength;
135  std::string mOgreMeshName;
136  std::string mOgreEntityName;
137  SimpleFireHoseMeshGenerator* mMeshGenerator;
138  Ogre::SceneNode* mOgreSceneNode;
139  Ogre::v1::Entity* mOgreEntity;
140 
141  Section() :
142  mLength(0.0f),
143  mMeshGenerator(nullptr),
144  mOgreSceneNode(nullptr),
145  mOgreEntity(nullptr)
146  {}
147  };
148  typedef std::vector<Section> SectionArray;
149 
150 
151  //[-------------------------------------------------------]
152  //[ Private methods ]
153  //[-------------------------------------------------------]
154  private:
155  void updateAnimation(const qsf::JobArguments& jobArguments);
156 
157  void addSection();
158  void removeSection();
159  void updateSectionMesh(uint32 sectionIndex);
160  void updateTransform(qsf::Transform& transform, qsf::Entity& targetEntity, const std::string& targetBoneName);
161 
162 
163  //[-------------------------------------------------------]
164  //[ Private data ]
165  //[-------------------------------------------------------]
166  private:
167  // Update jobs
168  qsf::JobProxy mAnimationJobProxy;
169 
170  // Start entity: connector on hydrant
171  qsf::WeakPtr<qsf::Entity> mHydrantEntity;
172  qsf::WeakPtr<qsf::Entity> mConnectorEntity;
173  std::string mConnectorBoneName;
174 
175  // End entity: nozzle carried by fireman
176  qsf::WeakPtr<qsf::Entity> mFiremanEntity;
177  qsf::WeakPtr<qsf::Entity> mNozzleEntity;
178  std::string mNozzleBoneName;
179 
180  float mMaxRangeHydrant;
181 
182  // Sections
183  SectionArray mSections;
184 
185  // Debug
186  qsf::DebugDrawProxy mDebugDrawProxy;
187 
188 
189  //[-------------------------------------------------------]
190  //[ CAMP reflection system ]
191  //[-------------------------------------------------------]
192  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
193 
194 
195  };
196 
197 
198 //[-------------------------------------------------------]
199 //[ Namespace ]
200 //[-------------------------------------------------------]
201 } // qsf
202 
203 
204 //[-------------------------------------------------------]
205 //[ Implementation ]
206 //[-------------------------------------------------------]
208 
209 
210 //[-------------------------------------------------------]
211 //[ CAMP reflection system ]
212 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Abstract component class.
Definition: Component.h:105
Entity class.
Definition: Entity.h:46
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: FastPodAllocator.h:41
Simple fire hose mesh generator class.
Definition: SimpleFireHoseMeshGenerator.h:48
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
3D transform class
Definition: Transform.h:45
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
Debug draw proxy class.
Definition: DebugDrawProxy.h:46
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Prototype class.
Definition: Prototype.h:100
Simple fire hose component based on existing implementation.
Definition: SimpleFireHoseComponent.h:56
static const uint32 COMPONENT_ID
"em5::SimpleFireHoseComponent" unique component ID
Definition: SimpleFireHoseComponent.h:70
Definition: BuildingClippingManager.h:23
Binary serializer class.
Definition: BinarySerializer.h:35