Added Model component to schema
This commit is contained in:
@@ -21,7 +21,6 @@ private:
|
||||
{
|
||||
ComponentWrapperFactory f;
|
||||
|
||||
|
||||
f = ComponentWrapperFactory("Test");
|
||||
f.AddProperty("TestInteger", 1337);
|
||||
f.AddProperty("TestFloat", 13.37f);
|
||||
@@ -31,18 +30,6 @@ private:
|
||||
f = ComponentWrapperFactory("Debug");
|
||||
f.AddProperty("Name", std::string("Unnamed"));
|
||||
RegisterComponent(f);
|
||||
|
||||
//f = ComponentWrapperFactory("Transform");
|
||||
//f.AddProperty("Position", glm::vec3(0.f, 0.f, 0.f));
|
||||
//f.AddProperty("Orientation", glm::quat());
|
||||
//f.AddProperty("Scale", glm::vec3(1.f, 1.f, 1.f));
|
||||
//RegisterComponent(f);
|
||||
|
||||
f = ComponentWrapperFactory("Model");
|
||||
f.AddProperty("Resource", std::string());
|
||||
f.AddProperty("Color", glm::vec4(1.f, 1.f, 1.f, 1.f));
|
||||
f.AddProperty("Visible", true);
|
||||
RegisterComponent(f);
|
||||
}
|
||||
|
||||
void createTestEntities()
|
||||
@@ -50,56 +37,27 @@ private:
|
||||
ResourceManager::RegisterType<EntityXMLFile>("EntityXMLFile");
|
||||
ResourceManager::Load<EntityXMLFile>("Schema/Entities/Test.xml")->PopulateWorld(this);
|
||||
|
||||
World& world = *this;
|
||||
|
||||
// Create an entity
|
||||
EntityID e = world.CreateEntity();
|
||||
|
||||
// Attach a Transform component
|
||||
world.AttachComponent(e, "Transform");
|
||||
// Fetch the component based on EntityID and component type
|
||||
ComponentWrapper transform = world.GetComponent(e, "Transform");
|
||||
// Set the fields of the Transform component
|
||||
transform["Position"] = glm::vec3(0.f, 0.f, 0.f);
|
||||
transform["Scale"] = glm::vec3(1.f, 1.f, 1.f);
|
||||
|
||||
// Move on the X axis by fetching field as reference
|
||||
((glm::vec3&)transform["Position"]).x += 10.f;
|
||||
// Shrink by a factor of 100
|
||||
((glm::vec3&)transform["Scale"]) /= 100.f;
|
||||
|
||||
// Loop through all Transform components and print them
|
||||
for (auto& transform : world.GetComponents("Transform")) {
|
||||
glm::vec3 pos = transform["Position"];
|
||||
std::cout << "Position: " << pos.x << " " << pos.y << " " << pos.z << std::endl;
|
||||
glm::vec3 scale = transform["Scale"];
|
||||
std::cout << "Scale: " << scale.x << " " << scale.y << " " << scale.z << std::endl;
|
||||
}
|
||||
|
||||
//Create some test widgets
|
||||
{
|
||||
EntityID entityScaleWidget = world.CreateEntity();
|
||||
ComponentWrapper transform = world.AttachComponent(entityScaleWidget, "Transform");
|
||||
EntityID entityScaleWidget = CreateEntity();
|
||||
ComponentWrapper transform = AttachComponent(entityScaleWidget, "Transform");
|
||||
transform["Position"] = glm::vec3(-1.5f, 0.f, 0.f);
|
||||
ComponentWrapper model = world.AttachComponent(entityScaleWidget, "Model");
|
||||
ComponentWrapper model = AttachComponent(entityScaleWidget, "Model");
|
||||
model["Resource"] = "Models/ScaleWidget.obj";
|
||||
}
|
||||
{
|
||||
EntityID entityRotationWidget = world.CreateEntity();
|
||||
ComponentWrapper transform = world.AttachComponent(entityRotationWidget, "Transform");
|
||||
EntityID entityRotationWidget = CreateEntity();
|
||||
ComponentWrapper transform = AttachComponent(entityRotationWidget, "Transform");
|
||||
transform["Position"] = glm::vec3(1.5f, 0.f, 0.f);
|
||||
ComponentWrapper model = world.AttachComponent(entityRotationWidget, "Model");
|
||||
ComponentWrapper model = AttachComponent(entityRotationWidget, "Model");
|
||||
model["Resource"] = "Models/RotationWidget.obj";
|
||||
}
|
||||
{
|
||||
EntityID entityDummyScene = world.CreateEntity();
|
||||
ComponentWrapper transform = world.AttachComponent(entityDummyScene, "Transform");
|
||||
EntityID entityDummyScene = CreateEntity();
|
||||
ComponentWrapper transform = AttachComponent(entityDummyScene, "Transform");
|
||||
transform["Position"] = glm::vec3(0, 0.f, 0.f);
|
||||
ComponentWrapper model = world.AttachComponent(entityDummyScene, "Model");
|
||||
ComponentWrapper model = AttachComponent(entityDummyScene, "Model");
|
||||
model["Resource"] = "Models/DummyScene.obj";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user