TDME2  1.9.200
DecalInternal.cpp
Go to the documentation of this file.
2 
3 #include <string>
4 #include <vector>
5 
6 #include <tdme/tdme.h>
7 #include <tdme/engine/Texture.h>
9 #include <tdme/engine/Color4.h>
12 #include <tdme/engine/Transform.h>
13 
14 using std::string;
15 using std::vector;
16 
24 
25 DecalInternal::DecalInternal(const string& id, OrientedBoundingBox* obb, Texture* texture, int32_t textureHorizontalSprites, int32_t textureVerticalSprites, float fps)
26 {
27  this->id = id;
28  this->enabled = true;
29  this->effectColorMul.set(1.0f, 1.0f, 1.0f, 1.0f);
30  this->effectColorAdd.set(0.0f, 0.0f, 0.0f, 0.0f);
31  this->pickable = false;
32  this->contributesShadows = false;
33  this->receivesShadows = false;
34  this->obb = obb;
40  obb->getAxes()[0] * obb->getHalfExtension()[0] * 2.0f,
41  obb->getAxes()[1] * obb->getHalfExtension()[1] * 2.0f,
42  obb->getAxes()[2] * obb->getHalfExtension()[2] * 2.0f
43  );
45  this->texture = texture != nullptr?texture:TextureReader::read("resources/engine/textures", "point.png");
46  this->textureHorizontalSprites = textureHorizontalSprites;
47  this->textureVerticalSprites = textureVerticalSprites;
48  this->fps = fps;
49 }
50 
52  if (texture != nullptr) texture->releaseReference();
53 }
54 
56 {
58  //
59  auto entityTransform = parentTransform * (*this);
60  entityTransformMatrix = entityTransform.getTransformMatrix();
61  //
63 }
64 
65 void DecalInternal::setTransform(const Transform& transform)
66 {
67  Transform::setTransform(transform);
68  //
69  auto entityTransform = parentTransform * (*this);
70  entityTransformMatrix = entityTransform.getTransformMatrix();
71  //
73 }
74 
76 }
77 
79 {
80 }
Color 4 definition class.
Definition: Color4.h:18
void set(float r, float g, float b, float a)
Sets this color by its components.
Definition: Color4.h:66
Texture entity.
Definition: Texture.h:24
Transform which contain scale, rotations and translation.
Definition: Transform.h:29
virtual void setTransform(const Transform &transform)
Set transform.
Definition: Transform.h:177
virtual void update()
Computes transform matrix.
Definition: Transform.cpp:33
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:26
Oriented bounding box physics primitive.
const array< Vector3, 3 > & getAxes() const
void update() override
Update transform.
void setTransform(const Transform &transform) override
From transform.
void updateInternal()
Update bounding volume and obb matrix with transform and finally world to decal space matrix.
Definition: DecalInternal.h:82
Matrix4x4 & identity()
Creates identity matrix.
Definition: Matrix4x4.h:158
Matrix4x4 & setAxes(const Vector3 &xAxis, const Vector3 &yAxis, const Vector3 &zAxis)
Set coordinate system axes.
Definition: Matrix4x4.h:334
Matrix4x4 & setTranslation(const Vector3 &translation)
Set translation.
Definition: Matrix4x4.h:442
virtual void releaseReference()
Releases a reference, thus decrementing the counter and delete it if reference counter is zero.
Definition: Reference.h:38