MCPcopy Create free account
hub / github.com/JeanPhilippeKernel/RendererEngine / Initialize

Method Initialize

Tetragrama/src/Layers/RenderLayer.cpp:26–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24 RenderLayer::RenderLayer(std::string_view name) : m_texture_manager(new ZEngine::Managers::TextureManager()), Layer(name.data()) {}
25
26 void RenderLayer::Initialize() {
27
28 m_texture_manager->Load("Assets/Images/free_image.png");
29 m_texture_manager->Load("Assets/Images/Crate.png");
30 m_texture_manager->Load("Assets/Images/Checkerboard_2.png");
31 m_texture_manager->Load("Assets/Images/container2_specular.png");
32 m_texture_manager->Load("Assets/Images/container2.png");
33
34 m_scene = CreateRef<GraphicScene3D>();
35 m_scene->Initialize();
36 m_scene->OnSceneRenderCompleted = std::bind(&RenderLayer::OnSceneRenderCompletedCallback, this, std::placeholders::_1);
37
38 Messengers::IMessenger::SendAsync<ZEngine::Components::UI::UIComponent, Messengers::GenericMessage<Ref<GraphicScene>>>(
39 EDITOR_RENDER_LAYER_SCENE_AVAILABLE, Messengers::GenericMessage<Ref<GraphicScene>>{m_scene});
40
41 auto camera_entity = m_scene->CreateEntity("Main camera");
42 camera_entity.AddComponent<CameraComponent>(CreateRef<OrbitCameraController>(GetAttachedWindow(), Vector3(0.0f, 20.0f, 120.f), 10.0f, -20.0f));
43
44 auto light_entity = m_scene->CreateEntity("light");
45 light_entity.AddComponent<GeometryComponent>(CreateRef<CubeGeometry>());
46 auto& light_transform = light_entity.GetComponent<TransformComponent>();
47 light_transform.SetPosition({-30.0f, 10.f, 0.0f});
48 light_transform.SetScaleSize({1.f, 1.0f, 1.f});
49 light_transform.SetRotationAngle(0.0f);
50 light_transform.SetRotationAxis({0.0f, 1.0f, 0.0f});
51 Ref<BasicMaterial> light_material = CreateRef<BasicMaterial>();
52 light_material->SetTexture(CreateTexture(1, 1));
53 light_entity.AddComponent<LightComponent>(Maths::Vector3{0.2f, 0.2f, 0.2f}, Maths::Vector3{0.5f, 0.5f, 0.5f}, Maths::Vector3{1.0f, 1.0f, 1.0f});
54 light_entity.AddComponent<MaterialComponent>(std::move(light_material));
55
56 auto checkboard_entity = m_scene->CreateEntity("Checkboard");
57 auto& checkboard_transform = checkboard_entity.GetComponent<TransformComponent>();
58 checkboard_transform.SetPosition({0.f, -0.5f, 0.0f});
59 checkboard_transform.SetScaleSize({1000.f, .0f, 1000.f});
60 checkboard_transform.SetRotationAngle(0.0f);
61 checkboard_transform.SetRotationAxis({1.f, 0.0f, 0.0f});
62 checkboard_entity.AddComponent<GeometryComponent>(CreateRef<CubeGeometry>());
63 Ref<StandardMaterial> material = CreateRef<StandardMaterial>();
64 material->SetDiffuseMap(m_texture_manager->Obtains("Checkerboard_2"));
65 material->SetTileFactor(20.f);
66 Ref<Rendering::Textures::Texture> specular_map_2(Rendering::Textures::CreateTexture(1, 1));
67 specular_map_2->SetData(60, 60, 60, 100);
68 material->SetSpecularMap(specular_map_2);
69 material->SetShininess(10.0f);
70 material->SetLight(light_entity.GetComponent<LightComponent>().GetLight());
71 checkboard_entity.AddComponent<MaterialComponent>(std::move(material));
72
73 auto cube_box_entity = m_scene->CreateEntity("box");
74 auto& cube_box_transform = cube_box_entity.GetComponent<TransformComponent>();
75 cube_box_transform.SetPosition({0.f, 10.f, 0.0f});
76 cube_box_transform.SetScaleSize({10.f, 10.0f, 10.f});
77 cube_box_transform.SetRotationAngle(0.0f);
78 cube_box_transform.SetRotationAxis({0.f, 1.0f, 0.0f});
79 cube_box_entity.AddComponent<GeometryComponent>(CreateRef<CubeGeometry>());
80 Ref<StandardMaterial> cube_box_material = CreateRef<StandardMaterial>();
81 cube_box_material->SetDiffuseMap(m_texture_manager->Obtains("container2"));
82 cube_box_material->SetSpecularMap(m_texture_manager->Obtains("container2_specular"));
83 cube_box_material->SetShininess(100.0f);

Callers

nothing calls this directly

Calls 15

CreateTextureFunction · 0.85
CreateEntityMethod · 0.80
SetDiffuseMapMethod · 0.80
SetTileFactorMethod · 0.80
SetSpecularMapMethod · 0.80
SetShininessMethod · 0.80
SetLightMethod · 0.80
GetLightMethod · 0.80
GetTextureMethod · 0.80
SetPositionMethod · 0.45
SetScaleSizeMethod · 0.45
SetRotationAngleMethod · 0.45

Tested by

no test coverage detected