Emergency 20 Dokumentation  4.2.0
SimpleBarrierTapeComponent.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 
16 #include <qsf/math/Transform.h>
17 #include <qsf/job/JobProxy.h>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace Ogre
25 {
26  class SceneNode;
27  namespace v1
28  {
29  class Entity;
30  }
31 }
32 namespace em5
33 {
34  class SimpleBarrierTapeMeshGenerator;
35 }
36 
37 
38 //[-------------------------------------------------------]
39 //[ Namespace ]
40 //[-------------------------------------------------------]
41 namespace em5
42 {
43 
44 
45  //[-------------------------------------------------------]
46  //[ Classes ]
47  //[-------------------------------------------------------]
56  {
57 
58 
59  //[-------------------------------------------------------]
60  //[ Friends ]
61  //[-------------------------------------------------------]
63 
64 
65  //[-------------------------------------------------------]
66  //[ Public definitions ]
67  //[-------------------------------------------------------]
68  public:
69  static const uint32 COMPONENT_ID;
70 
71 
72  //[-------------------------------------------------------]
73  //[ Public static methods ]
74  //[-------------------------------------------------------]
75  public:
76  static SimpleBarrierTapeComponent& createBarrierTapeBetweenEntities(qsf::Entity& entity1, const std::string& entity1BoneName, qsf::Entity& entity2, const std::string& entity2BoneName);
77 
78 
79  //[-------------------------------------------------------]
80  //[ Public methods ]
81  //[-------------------------------------------------------]
82  public:
90  explicit SimpleBarrierTapeComponent(qsf::Prototype* prototype);
91 
96  virtual ~SimpleBarrierTapeComponent();
97 
98  void initializeWithEntities(qsf::Entity& entity1, const std::string& entity1BoneName, qsf::Entity& entity2, const std::string& entity2BoneName);
99 
104  void getWaypoints(std::vector<glm::vec3>& outWaypoints);
105 
111  void setTransparency(float transparency);
112 
117  void resetTransparency();
118 
119 
120  //[-------------------------------------------------------]
121  //[ Public virtual qsf::Component methods ]
122  //[-------------------------------------------------------]
123  public:
124  void serialize(qsf::BinarySerializer& serializer);
125 
126 
127  //[-------------------------------------------------------]
128  //[ Protected virtual qsf::Component methods ]
129  //[-------------------------------------------------------]
130  protected:
131  virtual bool onStartup() override;
132  virtual void onShutdown() override;
133  virtual void onSetSimulating(bool simulating) override;
134  virtual void onSetActive(bool active) override;
135 
136 
137  //[-------------------------------------------------------]
138  //[ Private declarations ]
139  //[-------------------------------------------------------]
140  private:
141  struct Section
142  {
143  qsf::Transform mStartTransform;
144  qsf::Transform mEndTransform;
145  mutable float mLength;
146  std::string mOgreMeshName;
147  SimpleBarrierTapeMeshGenerator* mMeshGenerator;
148  Ogre::SceneNode* mOgreSceneNode;
149  Ogre::v1::Entity* mOgreEntity;
150 
151  Section() : mLength(0.0f), mMeshGenerator(nullptr), mOgreSceneNode(nullptr), mOgreEntity(nullptr) {}
152  };
153  typedef std::vector<Section> SectionArray;
154 
155 
156  //[-------------------------------------------------------]
157  //[ Private methods ]
158  //[-------------------------------------------------------]
159  private:
160  void updateAnimation(const qsf::JobArguments& jobArguments);
161 
162  void addSection();
163  void removeSection();
164  void updateSectionMesh(uint32 sectionIndex);
165 
166  void setTransparency(Section& section);
167  void resetTransparency(Section& section);
168 
169 
170  //[-------------------------------------------------------]
171  //[ Private data ]
172  //[-------------------------------------------------------]
173  private:
174  // Update jobs
175  qsf::JobProxy mAnimationJobProxy;
176 
177  // Start entity
178  qsf::WeakPtr<qsf::Entity> mParentEntity1;
179  qsf::WeakPtr<qsf::Entity> mEntity1;
180  std::string mBoneName1;
181 
182  // End entity
183  qsf::WeakPtr<qsf::Entity> mParentEntity2;
184  qsf::WeakPtr<qsf::Entity> mEntity2;
185  std::string mBoneName2;
186 
187  // Sections
188  SectionArray mSections;
189  float mTransparency;
190 
191  // Debug
192  qsf::DebugDrawProxy mDebugDrawProxy;
193 
194 
195  //[-------------------------------------------------------]
196  //[ CAMP reflection system ]
197  //[-------------------------------------------------------]
198  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
199 
200 
201  };
202 
203 
204 //[-------------------------------------------------------]
205 //[ Namespace ]
206 //[-------------------------------------------------------]
207 } // qsf
208 
209 
210 //[-------------------------------------------------------]
211 //[ Implementation ]
212 //[-------------------------------------------------------]
214 
215 
216 //[-------------------------------------------------------]
217 //[ CAMP reflection system ]
218 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Simple warning tape component based on existing implementation.
Definition: SimpleBarrierTapeComponent.h:55
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
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
static const uint32 COMPONENT_ID
"em5::SimpleBarrierTapeComponent" unique component ID
Definition: SimpleBarrierTapeComponent.h:69
Definition: BuildingClippingManager.h:23
Binary serializer class.
Definition: BinarySerializer.h:35
Simple warning tape mesh generator class.
Definition: SimpleBarrierTapeMeshGenerator.h:41