SpiecsEngine
 
Loading...
Searching...
No Matches

◆ OnPreActivate()

void Spices::EditorWorld::OnPreActivate ( )
overridevirtual

This interface define the specific world behave before on activated.

Implements Spices::World.

Reimplemented in Spices::WhittedRTWorld, and Spices::GameEditorWorld.

Definition at line 16 of file EditorWorld.cpp.

17 {
19
20 // camera
21 {
22 Entity cameraentity = CreateEntity("EditorCamera");
23 CameraComponent& camComp = cameraentity.AddComponent<CameraComponent>(true);
24 camComp.SetCamera(std::make_shared<Camera>());
25 camComp.GetCamera()->SetPerspective(45.0f, 0.001f, 100000.0f);
26 //camComp.GetCamera()->SetOrthographic(-100.0f, 100.0f, 100.0f, -100.0f, 0.001f, 100000.0f);
27 TransformComponent& transformComp = cameraentity.GetComponent<TransformComponent>();
28 transformComp.SetPosition({ 30.0f, 6.0f, 15.0f });
29 transformComp.SetRotation({8.0f, -90.0f, 0.0f});
30
31 cameraentity.AddComponent<NativeScriptComponent>(std::make_shared<CameraController>());
32 }
33
34 // skybox
35 {
36 Entity skyboxentity = CreateEntity("SkyBox");
37 SkyBoxComponent& skyboxComp = skyboxentity.AddComponent<SkyBoxComponent>();
38 skyboxComp.SetMaterial("BasePassRenderer.SkyBox.little_paris_eiffel_tower_4k");
39 TransformComponent& transformComp = skyboxentity.GetComponent<TransformComponent>();
40 transformComp.SetScale({50000000.0f, 50000000.0f, 50000000.0f});
41 }
42
43 // directionallight
44 {
45 Entity dirlightentity = CreateEntity("DirectionalLight_0");
46 TransformComponent& transformComp = dirlightentity.GetComponent<TransformComponent>();
47 DirectionalLightComponent& dirlightComp = dirlightentity.AddComponent<DirectionalLightComponent>();
48 transformComp.SetRotation({0.0f, 25.0f, 50.0f});
49 dirlightComp.SetColor({ 1.0f, 1.0f, 1.0f });
50 dirlightComp.SetIntensity(5.0f);
51 }
52 }
#define SPICES_PROFILE_ZONE
Entity CreateEntity(const std::string &name="None")
Create a new empty entity in this world.
Definition World.cpp:13
friend class Entity
Definition World.h:262

References Spices::World::CreateEntity(), Spices::CameraComponent::SetCamera(), Spices::DirectionalLightComponent::SetIntensity(), and Spices::SkyBoxComponent::SetMaterial().

Referenced by Spices::WhittedRTWorld::OnPreActivate(), and Spices::GameEditorWorld::OnPreActivate().