5 #include <unordered_map>
27 using std::unordered_map;
57 unordered_map<string, EntityHierarchyLevel*>
children;
109 if (
id == entityHierarchyLevel->
id)
return entityHierarchyLevel;
110 for (
const auto& [childEntityId, childEntity]: entityHierarchyLevel->
children) {
112 if (childEntityHierarchyLevel !=
nullptr)
return childEntityHierarchyLevel;
131 void deleteHierarchy(EntityHierarchyLevel* entityHierarchyLevel,
int depth);
158 if (entityHierarchyLevel ==
nullptr || entityHierarchyLevel->parent ==
nullptr)
return nullptr;
159 return entityHierarchyLevel->entity;
179 const vector<Entity*>
query(
const string& parentId =
string());
208 vector<Entity*> entitiesByType;
211 entitiesByType.push_back(entity);
214 return entitiesByType;
258 inline const string&
getId()
override {
Color 4 definition class.
Entity hierarchy to be used with engine class.
BoundingBox * getBoundingBox() override
const Vector3 & getTranslation() const override
void updateHierarchy(const Transform &parentTransform, EntityHierarchyLevel *entityHierarchyLevel, int depth, bool &firstEntity)
Update hierarchy from given entity hierarchy level ongoing.
const Transform & getTransform() const override
RenderPass getRenderPass() const override
void dispose() override
Dispose this entity.
void setTranslation(const Vector3 &translation) override
Set translation.
Transform parentTransform
void removeRotation(const int idx) override
Remove rotation.
Rotation & getRotation(const int idx) override
Get rotation at given index.
BoundingBox worldBoundingBox
const int getRotationCount() const override
Entity * getEntityByType(EntityType entityType)
Returns first found entity with given entity type.
const Vector3 & getRotationAxis(const int idx) const override
void initialize() override
Initiates this entity.
bool isReceivesShadows() override
void setRenderPass(RenderPass renderPass) override
Set render pass.
void setReceivesShadows(bool receivesShadows) override
Enable/disable receives shadows.
void addRotation(const Vector3 &axis, const float angle) override
Add rotation.
void update() override
Update transform.
void setPickable(bool pickable) override
Set this entity pickable.
void setEffectColorMul(const Color4 &effectColorMul) override
Set effect color that will be multiplied with fragment color.
vector< Entity * > getEntitiesByType(EntityType entityType)
Return entities with given entity type.
bool isPickable() override
void addEntity(Entity *entity, const string &parentId=string())
Adds a entity to the hierarchy.
Matrix4x4 entityTransformMatrix
void setTransform(const Transform &transform) override
Set transform.
void deleteHierarchy(EntityHierarchyLevel *entityHierarchyLevel, int depth)
Delete hierarchy from given entity hierarchy level ongoing.
EntityHierarchyLevel entityRoot
const vector< Entity * > & getEntities()
vector< Entity * > entities
EntityHierarchyLevel * getEntityHierarchyLevel(const string &id)
Get entity hierarchy level by given entity id.
const Quaternion & getRotationsQuaternion() const override
void setScale(const Vector3 &scale) override
Set scale.
bool isContributesShadows() override
const Vector3 & getScale() const override
const vector< Entity * > query(const string &parentId=string())
Query sub entities of parent entity.
const float getRotationAngle(const int idx) const override
BoundingBox * getWorldBoundingBox() override
void removeEntity(const string &id)
Removes a entity from hierarchy by given unique entity id.
const Color4 & getEffectColorMul() const override
The effect color will be multiplied with fragment color.
void setFrustumCulling(bool frustumCulling) override
Set frustum culling.
void setEngine(Engine *engine) override
Set up engine.
Entity * getEntity(const string &id)
void setEnabled(bool enabled) override
Enable/disable rendering.
EntityHierarchyLevel * getEntityHierarchyLevel(EntityHierarchyLevel *entityHierarchyLevel, const string &id)
Retrieve entity hierarchy level by given entity id or nullptr if not found.
const Transform & getParentTransform() const override
const Matrix4x4 & getTransformMatrix() const override
const string & getId() override
EntityType getEntityType() override
Matrix4x4 entityTransformMatrixInverted
void setContributesShadows(bool contributesShadows) override
Enable/disable contributes shadows.
void setRotationAxis(const int idx, const Vector3 &axis) override
Set rotation axis.
bool isFrustumCulling() override
bool isEnabled() override
virtual ~EntityHierarchy()
Destructor.
void setEffectColorAdd(const Color4 &effectColorAdd) override
Set effect color that will be added to fragment color.
const Color4 & getEffectColorAdd() const override
The effect color will be added to fragment color.
void setParentTransform(const Transform &parentTransform) override
Set parent transform.
void setRenderer(Renderer *renderer) override
Set up renderer.
void setRotationAngle(const int idx, const float angle) override
virtual void setEffectColorMul(const Color4 &effectColorMul)=0
Set effect color that will be multiplied with fragment color.
virtual EntityType getEntityType()=0
virtual void setContributesShadows(bool contributesShadows)=0
Enable/disable contributes shadows.
friend class EntityHierarchy
@ ENTITYTYPE_ENTITYHIERARCHY
virtual void setPickable(bool pickable)=0
Set this entity pickable.
virtual void setReceivesShadows(bool receivesShadows)=0
Enable/disable receives shadows.
virtual void setEffectColorAdd(const Color4 &effectColorAdd)=0
Set effect color that will be added to fragment color.
Object to be used with engine class.
Representation of a 3D model.
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
void fromBoundingVolumeWithTransformMatrix(BoundingBox *original, const Matrix4x4 &transformMatrix)
Create bounding volume from given original(of same type) with applied transform matrix.
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Matrix4x4 clone() const
Clones this matrix.
Matrix4x4 & invert()
Inverts this matrix.
Quaternion class representing quaternion mathematical structure and operations with x,...
Vector3 class representing vector3 mathematical structure and operations with x, y,...
unordered_map< string, EntityHierarchyLevel * > children
EntityHierarchyLevel * parent
EntityHierarchyLevel(const string &id, EntityHierarchyLevel *parent, Entity *entity)
#define FORBID_CLASS_COPY(CLASS)