30 h->m_children.clear();
73 for (
Entity* c : childrenCopy)
78 if (hc && hc->m_parent == e)
90 h->m_children.clear();
100 if (!possibleAncestor || !node)
return false;
103 while (h && h->m_parent)
105 if (h->m_parent == possibleAncestor)
return true;
118 if (!e)
return false;
120 return (!h || h->m_parent ==
nullptr);
131 if (!child || !parent)
return false;
132 if (child == parent)
return false;
146 if (!hc || !hp)
return false;
157 if (!child)
return false;
160 if (!hc)
return false;
162 Entity* parent = hc->m_parent;
163 if (!parent)
return true;
168 hc->m_parent =
nullptr;
180 e->update(deltaTime, deviceContext);
205 auto worldMatrix = t->matrix * parentWorld;
206 t->worldMatrix = worldMatrix;
208 for (
Entity* c : h->m_children) {
217 e->render(deviceContext);
231 if (lightComponent) {
236 auto transform = entity->getComponent<
Transform>();
237 if (!meshRenderer || !transform || !meshRenderer->
isVisible()) {
242 renderObject.
mesh = meshRenderer->getMesh();
243 renderObject.materialInstance = meshRenderer->getMaterialInstance();
244 renderObject.materialInstances = meshRenderer->getMaterialInstances();
245 renderObject.world = transform->worldMatrix;
249 XMFLOAT4X4 worldMatrix{};
250 XMStoreFloat4x4(&worldMatrix, transform->worldMatrix);
252 float dx = objectPos.
x - cameraPos.
x;
253 float dy = objectPos.
y - cameraPos.
y;
254 float dz = objectPos.
z - cameraPos.
z;
255 renderObject.distanceToCamera = dx * dx + dy * dy + dz * dz;
258 if (renderObject.materialInstance &&
259 renderObject.materialInstance->getMaterial()) {
260 domain = renderObject.materialInstance->getMaterial()->getDomain();
264 if (renderObject.transparent) {
Declara la API de Camera dentro del subsistema Utilities.
Declara la API de DeviceContext dentro del subsistema Core.
Declara la API de Entity dentro del subsistema ECS.
Declara la API de HierarchyComponent dentro del subsistema SceneGraph.
Declara la API de LightComponent dentro del subsistema ECS.
Declara la API de MaterialInstance dentro del subsistema Rendering.
Declara la API de Material dentro del subsistema Rendering.
Declara la API de MeshRendererComponent dentro del subsistema ECS.
Declara la API de RenderScene dentro del subsistema Rendering.
Declara la API de SceneGraph dentro del subsistema SceneGraph.
EU::Vector3 getPosition() const
Obtiene la posición en mundo.
Clase TSharedPointer para manejar la gestión de memoria compartida.
float x
The x-coordinate of the vector.
float z
The z-coordinate of the vector.
float y
The y-coordinate of the vector.
void addComponent(EU::TSharedPointer< T > component)
Agrega un componente a la entidad.
EU::TSharedPointer< T > getComponent()
Obtiene un componente de la entidad por su tipo.
std::vector< Entity * > m_children
void addChild(Entity *child)
void removeChild(Entity *child)
bool canCastShadow() const
Contenedor temporal con los elementos visibles de un frame.
std::vector< RenderObject > transparentObjects
Objetos transparentes ordenables por distancia.
std::vector< LightData > directionalLights
Luces direccionales activas en la escena.
std::vector< RenderObject > opaqueObjects
Objetos opacos listos para renderizar.
void gatherRenderScene(RenderScene &outScene, const Camera &camera)
bool isRegistered(Entity *e) const
bool isRoot(Entity *e) const
void addEntity(Entity *e)
Registra una entidad dentro del grafo.
void render(DeviceContext &deviceContext)
void updateWorldRecursive(Entity *node, const XMMATRIX &parentWorld)
bool detach(Entity *child)
void update(float deltaTime, DeviceContext &deviceContext)
void removeEntity(Entity *e)
Elimina una entidad del grafo si esta registrada.
std::vector< Entity * > m_entities
Entidades registradas en el grafo.
bool attach(Entity *child, Entity *parent)
bool isAncestor(Entity *possibleAncestor, Entity *node) const