TDME2  1.9.200
ObjectInternal.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
6 #include <tdme/engine/fwd-tdme.h>
9 #include <tdme/engine/Color4.h>
14 #include <tdme/math/Matrix3x3.h>
15 
16 using std::string;
17 
27 
28 /**
29  * Object
30  * @author Andreas Drewke
31  */
33  : public ObjectBase
34 {
35  friend class EntityRenderer;
36 
37 protected:
38  string id;
39  bool enabled;
40  bool pickable;
48 
49  /**
50  * Update bounding volume
51  */
52  void updateBoundingBox();
53 
54  /**
55  * Set parent transform
56  * @param parentTransform parent transform
57  */
61  }
62 
63 public:
64  // forbid class copy
66 
67  /**
68  * Public constructor
69  * @param id id
70  * @param model model
71  * @param instances instances to compute and render by duplication
72  */
73  ObjectInternal(const string& id, Model* model, int instances);
74 
75  /**
76  * Destructor
77  */
78  virtual ~ObjectInternal();
79 
80  /**
81  * @return object id
82  */
83  inline const string& getId() {
84  return id;
85  }
86 
87  /**
88  * @return true if enabled to be rendered
89  */
90  inline bool isEnabled() {
91  return enabled;
92  }
93 
94  /**
95  * Enable/disable rendering
96  * @param enabled enabled
97  */
98  inline void setEnabled(bool enabled) {
99  this->enabled = enabled;
100  }
101 
102  /**
103  * @return if object is pickable
104  */
105  inline bool isPickable() {
106  return pickable;
107  }
108 
109  /**
110  * Set this object pickable
111  * @param pickable pickable
112  */
113  inline void setPickable(bool pickable) {
114  this->pickable = pickable;
115  }
116 
117  /**
118  * @return if entity contributes to shadows
119  */
120  inline bool isContributesShadows() {
121  return contributesShadows;
122  }
123 
124  /**
125  * Enable/disable contributes shadows
126  * @param contributesShadows contributes shadows
127  */
129  this->contributesShadows = contributesShadows;
130  }
131 
132  /**
133  * @return if entity receives shadows
134  */
135  inline bool isReceivesShadows() {
136  return receivesShadows;
137  }
138 
139  /**
140  * Enable/disable receives shadows
141  * @param receivesShadows receives shadows
142  */
144  this->receivesShadows = receivesShadows;
145  }
146 
147  /**
148  * The effect color will be multiplied with fragment color
149  * @return effect color
150  */
151  inline const Color4& getEffectColorMul() const {
152  return effectColorMul;
153  }
154 
155  /**
156  * The effect color that will be multiplied with fragment color
157  * @param effectColorMul effect color
158  */
160  this->effectColorMul = effectColorMul;
161  }
162 
163  /**
164  * The effect color will be added to fragment color
165  * @return effect color
166  */
167  inline const Color4& getEffectColorAdd() const {
168  return effectColorAdd;
169  }
170 
171  /**
172  * The effect color will be added to fragment color
173  * @return effect color
174  */
176  this->effectColorAdd = effectColorAdd;
177  }
178 
179  /**
180  * @return bounding box
181  */
183  return &boundingBox;
184  }
185 
186  /**
187  * Retrieves world bounding box
188  * @return world bounding box
189  */
191  return &worldBoundingBox;
192  }
193 
194  /**
195  * Bind a texture to a node and faces entity
196  * @param textureId texture id
197  * @param nodeId node id or empty if texture should be bound to all nodes
198  * @param facesEntityId faces entity id or empty if texture should be bound to all faces entities
199  */
200  void bindDiffuseTexture(int32_t textureId, const string& nodeId = string(), const string& facesEntityId = string());
201 
202  /**
203  * Bind frame buffer color texture to a node and faces entity of this object
204  * @param frameBuffer frame buffer
205  * @param nodeId node id or empty string for all
206  * @param facesEntityId faces entity id or empty string for all
207  */
208  void bindDiffuseTexture(ColorTexture* texture, const string& nodeId = string(), const string& facesEntityId = string());
209 
210  /**
211  * Unbind dynamic texture to a node and faces entity of this object
212  * @param nodeId node id or empty string for all
213  * @param facesEntityId faces entity id orempty string for all
214  */
215  void unbindDiffuseTexture(const string& nodeId = string(), const string& facesEntityId = string());
216 
217  /**
218  * Set texture matrix
219  * @param textureMatrix texture matrix
220  * @param nodeId node id or empty string for all
221  * @param facesEntityId faces entity id or empty string for all
222  */
223  void setTextureMatrix(const Matrix3x3& textureMatrix, const string& nodeId = string(), const string& facesEntityId = string());
224 
225  // overridden methods
226  inline void initialize() override {
228  }
229  inline void dispose() override {
231  }
232  void setTransform(const Transform& transform);
233  void update();
234 
235  /**
236  * Set node transform matrix
237  * @param id id
238  * @param matrix matrix
239  */
240  void setNodeTransformMatrix(const string& id, const Matrix4x4& matrix);
241 
242  /**
243  * Unset node transform matrix
244  * @param id id
245  */
246  void unsetNodeTransformMatrix(const string& id);
247 
248 };
Color 4 definition class.
Definition: Color4.h:18
Frame buffer class.
Definition: FrameBuffer.h:22
Transform which contain scale, rotations and translation.
Definition: Transform.h:29
Representation of a 3D model.
Definition: Model.h:35
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:26
virtual void initialize()
Initiates this object.
Definition: ObjectBase.cpp:148
virtual void dispose()
Disposes this object.
Definition: ObjectBase.cpp:189
void setParentTransform(const Transform &parentTransform)
Set parent transform.
Definition: ObjectBase.h:70
void setContributesShadows(bool contributesShadows)
Enable/disable contributes shadows.
void dispose() override
Disposes this object.
const Color4 & getEffectColorMul() const
The effect color will be multiplied with fragment color.
void setEnabled(bool enabled)
Enable/disable rendering.
void initialize() override
Initiates this object.
void setTextureMatrix(const Matrix3x3 &textureMatrix, const string &nodeId=string(), const string &facesEntityId=string())
Set texture matrix.
void setNodeTransformMatrix(const string &id, const Matrix4x4 &matrix)
Set node transform matrix.
const Color4 & getEffectColorAdd() const
The effect color will be added to fragment color.
void unbindDiffuseTexture(const string &nodeId=string(), const string &facesEntityId=string())
Unbind dynamic texture to a node and faces entity of this object.
void bindDiffuseTexture(int32_t textureId, const string &nodeId=string(), const string &facesEntityId=string())
Bind a texture to a node and faces entity.
ObjectInternal(const string &id, Model *model, int instances)
Public constructor.
void setPickable(bool pickable)
Set this object pickable.
void setEffectColorMul(const Color4 &effectColorMul)
The effect color that will be multiplied with fragment color.
void setEffectColorAdd(const Color4 &effectColorAdd)
The effect color will be added to fragment color.
void unsetNodeTransformMatrix(const string &id)
Unset node transform matrix.
BoundingBox * getWorldBoundingBox()
Retrieves world bounding box.
void setReceivesShadows(bool receivesShadows)
Enable/disable receives shadows.
void setParentTransform(const Transform &parentTransform)
Set parent transform.
Matrix3x3 class representing matrix3x3 mathematical structure and operations for 2d space.
Definition: Matrix3x3.h:20
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Definition: Matrix4x4.h:23
Color texture interface.
Definition: ColorTexture.h:13
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6