Skip to content
Snippets Groups Projects
Commit b7e22ae7 authored by jwendt's avatar jwendt
Browse files

Adapt combustion demo

closes #415
parent e24dc64f
No related branches found
No related tags found
1 merge request!160Feature/#415 resource pointer component
......@@ -33,11 +33,12 @@
#include "phx/input/device_system.hpp"
#include "phx/input/input_system.hpp"
#include "phx/rendering/auxiliary/splash_screen.hpp"
#include "phx/rendering/components/mesh_handle.hpp"
#include "phx/rendering/components/mesh_render_settings.hpp"
#include "phx/rendering/components/resource_component.hpp"
#include "phx/rendering/components/skybox.hpp"
#include "phx/resources/loaders/assimp_model_loader.hpp"
#include "phx/resources/loaders/scene_loader.hpp"
#include "phx/resources/resource_manager.hpp"
#include "phx/setup.hpp"
#include "vr_controller_interaction_behavior.hpp"
......@@ -92,8 +93,8 @@ int main(int, char**) {
auto surface_material_handle =
surface_transform->GetChild(0)
->GetEntity()
->GetFirstComponent<phx::MaterialHandle>();
auto surface_material = surface_material_handle->GetMaterial();
->GetFirstComponent<phx::ResourceComponent<phx::Material>>();
auto surface_material = surface_material_handle->GetResourcePointer();
surface_material->SetAmbientColor(glm::vec3(0.1f));
surface_material->SetDiffuseColor(glm::vec3(1.0f));
surface_material->SetSpecularColor(glm::vec3(0.4f));
......@@ -106,13 +107,14 @@ int main(int, char**) {
auto boundigbox_mesh_entity =
boundingbox_transform->GetChild(0)->GetEntity();
auto boundingbox_mesh_handle =
boundigbox_mesh_entity->GetFirstComponent<phx::MeshHandle>();
boundigbox_mesh_entity
->GetFirstComponent<phx::ResourceComponent<phx::Mesh>>();
auto render_settings =
boundigbox_mesh_entity->AddComponent<phx::MeshRenderSettings>();
render_settings->SetWireframeMode(true);
std::array<glm::vec3, 2> bbox =
boundingbox_mesh_handle->GetMesh()->GetBoundingBox();
boundingbox_mesh_handle->GetResourcePointer()->GetBoundingBox();
glm::vec3 bbox_diff = bbox[1] - bbox[0];
glm::vec3 center_vec = bbox_diff * 0.5f * 0.001f;
surface_transform->SetLocalTranslation(-center_vec);
......@@ -130,13 +132,14 @@ int main(int, char**) {
"models/cube/cube.obj", scene.get());
auto floor_transform = floor_entity->GetFirstComponent<phx::Transform>();
floor_transform->SetLocalScale(glm::vec3(1000.0f, 0.05f, 1000.0f));
auto floor_material = floor_transform->GetChild(0)
auto floor_material =
floor_transform->GetChild(0)
->GetEntity()
->GetFirstComponent<phx::MaterialHandle>();
floor_material->GetMaterial()->SetDiffuseColor(glm::vec3(0.5f, 0.5f, 0.5f));
floor_material->GetMaterial()->SetSpecularColor(
glm::vec3(1.0f, 1.0f, 1.0f));
floor_material->GetMaterial()->SetAmbientColor(glm::vec3(0.1f, 0.1f, 0.1f));
->GetFirstComponent<phx::ResourceComponent<phx::Material>>()
->GetResourcePointer();
floor_material->SetDiffuseColor(glm::vec3(0.5f, 0.5f, 0.5f));
floor_material->SetSpecularColor(glm::vec3(1.0f, 1.0f, 1.0f));
floor_material->SetAmbientColor(glm::vec3(0.1f, 0.1f, 0.1f));
if (right_interaction_behavior)
right_interaction_behavior->SetTarget(vis_root_transform);
......@@ -145,12 +148,14 @@ int main(int, char**) {
"models/cube/cube2.obj", scene.get());
auto desk_transform = desk_entity->GetFirstComponent<phx::Transform>();
desk_transform->SetLocalScale(glm::vec3(2.0f, 0.03f, 1.0f));
auto desk_material = desk_transform->GetChild(0)
auto desk_material =
desk_transform->GetChild(0)
->GetEntity()
->GetFirstComponent<phx::MaterialHandle>();
desk_material->GetMaterial()->SetDiffuseColor(glm::vec3(0.5f, 1.0f, 0.5f));
desk_material->GetMaterial()->SetSpecularColor(glm::vec3(1.0f, 1.0f, 1.0f));
desk_material->GetMaterial()->SetAmbientColor(glm::vec3(0.1f, 0.2f, 0.1f));
->GetFirstComponent<phx::ResourceComponent<phx::Material>>()
->GetResourcePointer();
desk_material->SetDiffuseColor(glm::vec3(0.5f, 1.0f, 0.5f));
desk_material->SetSpecularColor(glm::vec3(1.0f, 1.0f, 1.0f));
desk_material->SetAmbientColor(glm::vec3(0.1f, 0.2f, 0.1f));
auto desk_root = scene->CreateEntity();
auto desk_root_transform = desk_root->AddComponent<phx::Transform>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment