Added crude absolute positioning when rendering
This commit is contained in:
+1
-1
Submodule assets updated: 5a207bbb3e...8a7ecf53f7
@@ -23,6 +23,8 @@ public:
|
|||||||
ComponentWrapper GetComponent(EntityID entity, std::string componentType);
|
ComponentWrapper GetComponent(EntityID entity, std::string componentType);
|
||||||
// Get all components of the specified type
|
// Get all components of the specified type
|
||||||
const ComponentPool* GetComponents(std::string componentType);
|
const ComponentPool* GetComponents(std::string componentType);
|
||||||
|
// Get entity parent
|
||||||
|
EntityID GetParent(EntityID entity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EntityID m_CurrentEntityID = 1;
|
EntityID m_CurrentEntityID = 1;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ private:
|
|||||||
void FillLights(World* world, RenderQueue* renderQueue);
|
void FillLights(World* world, RenderQueue* renderQueue);
|
||||||
|
|
||||||
glm::mat4 ModelMatrix(World* world, EntityID entity);
|
glm::mat4 ModelMatrix(World* world, EntityID entity);
|
||||||
glm::vec3 GetAbsolutePosition(World* world, ComponentWrapper transformComponent);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<xs:element name="Position" type="t:Vector" minOccurs="0">
|
<xs:element name="Position" type="t:Vector" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>The position vector</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>The position vector</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="Orientation" type="t:Quaternion" minOccurs="0"/>
|
<xs:element name="Orientation" type="t:Vector" minOccurs="0"/>
|
||||||
<xs:element name="Scale" type="t:Vector" minOccurs="0"/>
|
<xs:element name="Scale" type="t:Vector" minOccurs="0"/>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
<Entity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd" xmlns:c="components">
|
<Entity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd" xmlns:c="components">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Transform></c:Transform>
|
<c:Transform>
|
||||||
|
<Orientation X="0" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/DummyScene.obj</Resource>
|
<Resource>Models/DummyScene.obj</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
@@ -37,8 +39,59 @@
|
|||||||
</c:Transform>
|
</c:Transform>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Core/UnitRaptor.obj</Resource>
|
<Resource>Models/Core/UnitRaptor.obj</Resource>
|
||||||
|
<Color R="1" G="0.4" B="0.8"/>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
</Components>
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.2" Y="0"/>
|
||||||
|
<Orientation X="0" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.4"/>
|
||||||
|
<Scale X="0.1" Y="0.4" Z="0.1"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.obj</Resource>
|
||||||
|
<Color R="1" G="0.4" B="0.8"/>
|
||||||
|
</c:Model>
|
||||||
|
</Components>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.6"/>
|
||||||
|
<Scale X="1.7" Y="0.03" Z="0.1"/>
|
||||||
|
<Orientation X="0" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.obj</Resource>
|
||||||
|
<Color R="1" G="0.4" B="0.8"/>
|
||||||
|
</c:Model>
|
||||||
|
</Components>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.6"/>
|
||||||
|
<Scale X="1.7" Y="0.03" Z="0.1"/>
|
||||||
|
<Orientation X="0" Y="1.57" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.obj</Resource>
|
||||||
|
<Color R="1" G="0.4" B="0.8"/>
|
||||||
|
</c:Model>
|
||||||
|
</Components>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
@@ -47,6 +47,12 @@ const ComponentPool* World::GetComponents(std::string componentType)
|
|||||||
return (it != m_ComponentPools.end()) ? it->second : nullptr;
|
return (it != m_ComponentPools.end()) ? it->second : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EntityID World::GetParent(EntityID entity)
|
||||||
|
{
|
||||||
|
return m_EntityParents.at(entity);
|
||||||
|
}
|
||||||
|
|
||||||
EntityID World::generateEntityID()
|
EntityID World::generateEntityID()
|
||||||
{
|
{
|
||||||
// TODO: Make EntityID generation smarter
|
// TODO: Make EntityID generation smarter
|
||||||
|
|||||||
@@ -21,16 +21,15 @@ glm::mat4 RenderQueueFactory::ModelMatrix(World* world, EntityID entity)
|
|||||||
ComponentWrapper transformComponent = world->GetComponent(entity, "Transform");
|
ComponentWrapper transformComponent = world->GetComponent(entity, "Transform");
|
||||||
glm::vec3 position = transformComponent["Position"];
|
glm::vec3 position = transformComponent["Position"];
|
||||||
glm::vec3 scale = transformComponent["Scale"];
|
glm::vec3 scale = transformComponent["Scale"];
|
||||||
glm::quat oritentation = transformComponent["Orientation"];
|
glm::vec3 oritentation = transformComponent["Orientation"];
|
||||||
|
|
||||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(oritentation) * glm::scale(scale);
|
glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(glm::quat(oritentation)) * glm::scale(scale);
|
||||||
return modelMatrix;
|
EntityID parent = world->GetParent(entity);
|
||||||
}
|
if (parent != 0) {
|
||||||
|
return ModelMatrix(world, parent) * modelMatrix;
|
||||||
glm::vec3 GetAbsolutePosition(World* world, ComponentWrapper transformComponent)
|
} else {
|
||||||
{
|
return modelMatrix;
|
||||||
// positionComponent.EntityID
|
}
|
||||||
return glm::vec3();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderQueueFactory::FillModels(World* world, RenderQueue* renderQueue)
|
void RenderQueueFactory::FillModels(World* world, RenderQueue* renderQueue)
|
||||||
|
|||||||
+1
-1
@@ -65,8 +65,8 @@ void Game::Tick()
|
|||||||
m_EventBroker->Swap();
|
m_EventBroker->Swap();
|
||||||
|
|
||||||
testTick(dt);
|
testTick(dt);
|
||||||
m_RenderQueueFactory->Update(m_World);
|
|
||||||
|
|
||||||
|
m_RenderQueueFactory->Update(m_World);
|
||||||
m_Renderer->Draw(m_RenderQueueFactory->RenderQueues());
|
m_Renderer->Draw(m_RenderQueueFactory->RenderQueues());
|
||||||
|
|
||||||
m_EventBroker->Swap();
|
m_EventBroker->Swap();
|
||||||
|
|||||||
Reference in New Issue
Block a user