merge fixes

This commit is contained in:
viktorljung
2015-12-08 10:15:12 +01:00
parent e7427bf3ad
commit d556f964e6
2 changed files with 23 additions and 25 deletions
+21 -23
View File
@@ -19,13 +19,7 @@ private:
void registerTestComponents() void registerTestComponents()
{ {
ComponentWrapperFactory f; ComponentWrapperFactory f;
},
{
"Model",
{
std::make_tuple(sizeof(std::string), "ModelFile", std::string("Unnamed")),
std::make_tuple(sizeof(glm::vec4), "Color", glm::vec4(1.f, 1.f, 1.f, 1.f)),
}
f = ComponentWrapperFactory("Test"); f = ComponentWrapperFactory("Test");
f.AddProperty("TestInteger", 1337); f.AddProperty("TestInteger", 1337);
@@ -86,24 +80,28 @@ private:
ComponentWrapper debug = world.GetComponent(transform.EntityID, "Debug"); ComponentWrapper debug = world.GetComponent(transform.EntityID, "Debug");
std::cout << "Name: " << (std::string)debug["Name"] << std::endl; std::cout << "Name: " << (std::string)debug["Name"] << std::endl;
} }
ComponentWrapper testTransform = GetComponent(entityScaleWidget, "Transform");
testTransform["Position"] = glm::vec3(-1.5f, 0.f, 0.f); //Create some test widgets
glm::quat ori = testTransform["Orientation"]; {
glm::vec3 scale = testTransform["Scale"]; EntityID entityScaleWidget = world.CreateEntity();
ComponentWrapper testModel = GetComponent(entityScaleWidget, "Model"); ComponentWrapper transform = world.AttachComponent(entityScaleWidget, "Transform");
testModel["ModelFile"] = "Models/ScaleWidget.obj"; transform["Position"] = glm::vec3(-1.5f, 0.f, 0.f);
glm::vec4 col = testModel["Color"]; ComponentWrapper model = world.AttachComponent(entityScaleWidget, "Model");
model["Resource"] = "Models/ScaleWidget.obj";
} }
{ {
EntityID entityRotationWidget = CreateEntity(); EntityID entityRotationWidget = world.CreateEntity();
AttachComponent(entityRotationWidget, "Transform"); ComponentWrapper transform = world.AttachComponent(entityRotationWidget, "Transform");
AttachComponent(entityRotationWidget, "Model"); transform["Position"] = glm::vec3(1.5f, 0.f, 0.f);
ComponentWrapper testTransform = GetComponent(entityRotationWidget, "Transform"); ComponentWrapper model = world.AttachComponent(entityRotationWidget, "Model");
testTransform["Position"] = glm::vec3(1.5f, 0.f, 0.f); model["Resource"] = "Models/RotationWidget.obj";
glm::quat ori = testTransform["Orientation"]; }
glm::vec3 scale = testTransform["Scale"]; {
ComponentWrapper testModel = GetComponent(entityRotationWidget, "Model"); EntityID entityDummyScene = world.CreateEntity();
testModel["ModelFile"] = "Models/RotationWidget.obj"; ComponentWrapper transform = world.AttachComponent(entityDummyScene, "Transform");
transform["Position"] = glm::vec3(0, 0.f, 0.f);
ComponentWrapper model = world.AttachComponent(entityDummyScene, "Model");
model["Resource"] = "Models/DummyScene.obj";
} }
+2 -2
View File
@@ -38,9 +38,9 @@ void RenderQueueFactory::FillModels(World* world, RenderQueue* renderQueue)
{ {
for(auto& modelC : world->GetComponents("Model")) { for(auto& modelC : world->GetComponents("Model")) {
ModelJob job; ModelJob job;
std::string modelFile = modelC["ModelFile"]; std::string resource = modelC["Resource"];
glm::vec4 color = modelC["Color"]; glm::vec4 color = modelC["Color"];
Model* model = ResourceManager::Load<Model>(modelFile); Model* model = ResourceManager::Load<Model>(resource);
for (auto texGroup : model->TextureGroups) { for (auto texGroup : model->TextureGroups) {
job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0; job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;