TDME2  1.9.200
LinesInternal.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <tdme/tdme.h>
8 #include <tdme/engine/fwd-tdme.h>
10 #include <tdme/engine/Color4.h>
18 #include <tdme/engine/Transform.h>
19 
20 using std::string;
21 using std::vector;
22 
32 
33 /**
34  * Lines entity internal
35  * @author Andreas Drewke
36  */
38  : public Transform
39 {
41 
42 protected:
43  string id;
44  Engine* engine { nullptr };
45  Renderer* renderer { nullptr };
46  bool enabled;
47  float lineWidth;
48  Texture* texture { nullptr };
49  int32_t textureId { -1 };
50 
55  bool pickable;
58 
59  vector<Vector3> points;
61  vector<Color4> colors;
62 
63  vector<int32_t>* vboIds;
64 
67 
68  /**
69  * Set parent transform
70  * @param parentTransform parent transform
71  */
73  //
74  this->parentTransform = parentTransform;
75  auto entityTransform = parentTransform * (*this);
76  entityTransformMatrix = entityTransform.getTransformMatrix();
77  //
79  }
80 /**
81  * Update bounding volume
82  */
83  inline void updateBoundingBox() {
85  worldBoundingBox.getMin().sub(0.05f); // scale a bit up to make picking work better
86  worldBoundingBox.getMax().add(0.05f); // same here
88  }
89 
90 public:
91  // forbid class copy
93 
94  /**
95  * Public constructor
96  * @param id id
97  * @param lineWidth line width
98  * @param points points
99  * @param color color
100  * @param colors optional colors
101  * @param texture optional texture
102  */
103  LinesInternal(const string& id, float lineWidth, const vector<Vector3>& points, const Color4& color, const vector<Color4>& colors = {}, Texture* texture = nullptr);
104 
105  /**
106  * Destructor
107  */
108  virtual ~LinesInternal();
109 
110  /**
111  * @return id
112  */
113  inline const string& getId() {
114  return id;
115  }
116 
117  /**
118  * Set renderer
119  * @param renderer renderer
120  */
121  inline void setRenderer(Renderer* renderer) {
122  this->renderer = renderer;
123  }
124 
125  /**
126  * Set engine
127  * @param engine engine
128  */
129  inline void setEngine(Engine* engine) {
130  this->engine = engine;
131  }
132 
133  /**
134  * @return is enabled
135  */
136  inline bool isEnabled() {
137  return enabled;
138  }
139 
140  /**
141  * Set enabled
142  * @param enabled enabled
143  */
144  inline void setEnabled(bool enabled) {
145  this->enabled = enabled;
146  }
147 
148  /**
149  * @return effect color mul
150  */
151  inline const Color4& getEffectColorMul() const {
152  return effectColorMul;
153  }
154 
155  /**
156  * Set effect color mul
157  * @param effectColorMul effect color mul
158  */
160  this->effectColorMul = effectColorMul;
161  }
162 
163  /**
164  * @return effect color mul
165  */
166  inline const Color4& getEffectColorAdd() const {
167  return effectColorMul;
168  }
169 
170  /**
171  * Set effect color add
172  * @param effectColorAdd effect color add
173  */
175  this->effectColorAdd = effectColorAdd;
176  }
177 
178  /**
179  * @return is pickable
180  */
181  inline bool isPickable() const {
182  return pickable;
183  }
184 
185  /**
186  * Set pickable
187  * @param pickable pickable
188  */
189  inline void setPickable(bool pickable) {
190  this->pickable = pickable;
191  }
192 
193  /**
194  * @return if entity contributes to shadows
195  */
196  inline bool isContributesShadows() {
197  return contributesShadows;
198  }
199 
200  /**
201  * Enable/disable contributes shadows
202  * @param contributesShadows contributes shadows
203  */
205  this->contributesShadows = contributesShadows;
206  }
207 
208  /**
209  * @return if entity receives shadows
210  */
211  inline bool isReceivesShadows() {
212  return receivesShadows;
213  }
214 
215  /**
216  * Enable/disable receives shadows
217  * @param receivesShadows receives shadows
218  */
220  this->receivesShadows = receivesShadows;
221  }
222 
223  /**
224  * @return bounding box
225  */
227  return &boundingBox;
228  }
229 
230  /**
231  * @return world bounding box
232  */
234  return &worldBoundingBox;
235  }
236 
237  /**
238  * @return line width
239  */
240  inline float getLineWidth() {
241  return lineWidth;
242  }
243 
244  /**
245  * @return texture id
246  */
247  inline int32_t getTextureId() {
248  return textureId;
249  }
250 
251  /**
252  * Update transform
253  */
254  void update() override;
255 
256  /**
257  * From transform
258  * @param transform transform
259  */
260  void setTransform(const Transform& transform) override;
261 
262  /**
263  * Initialize
264  */
265  void initialize();
266 
267  /**
268  * Dispose
269  */
270  void dispose();
271 
272 };
Color 4 definition class.
Definition: Color4.h:18
Engine main class.
Definition: Engine.h:131
Texture entity.
Definition: Texture.h:24
Transform which contain scale, rotations and translation.
Definition: Transform.h:29
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:26
void fromBoundingVolumeWithTransformMatrix(BoundingBox *original, const Matrix4x4 &transformMatrix)
Create bounding volume from given original(of same type) with applied transform matrix.
Definition: BoundingBox.cpp:79
void update()
Updates this bounding box.
void setContributesShadows(bool contributesShadows)
Enable/disable contributes shadows.
void setEngine(Engine *engine)
Set engine.
void setEnabled(bool enabled)
Set enabled.
void update() override
Update transform.
void setTransform(const Transform &transform) override
From transform.
void updateBoundingBox()
Update bounding volume.
Definition: LinesInternal.h:83
void setPickable(bool pickable)
Set pickable.
void setEffectColorMul(const Color4 &effectColorMul)
Set effect color mul.
void setEffectColorAdd(const Color4 &effectColorAdd)
Set effect color add.
LinesInternal(const string &id, float lineWidth, const vector< Vector3 > &points, const Color4 &color, const vector< Color4 > &colors={}, Texture *texture=nullptr)
Public constructor.
void setRenderer(Renderer *renderer)
Set renderer.
void setReceivesShadows(bool receivesShadows)
Enable/disable receives shadows.
void setParentTransform(const Transform &parentTransform)
Set parent transform.
Definition: LinesInternal.h:72
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Definition: Matrix4x4.h:23
Vector3 & add(float scalar)
Adds a scalar.
Definition: Vector3.h:153
Vector3 & sub(float scalar)
Subtracts a scalar.
Definition: Vector3.h:177
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6