SpiecsEngine
 
Loading...
Searching...
No Matches

◆ OnPreActivate()

void Spices::GameEditorWorld::OnPreActivate ( )
overridevirtual

This interface define the specific world behave before on activated.

Reimplemented from Spices::EditorWorld.

Definition at line 11 of file GameEditorWorld.cpp.

12 {
14
15 ResourceSystem::RegistryResourceFolder(SPICES_GAME_ASSETS_PATH);
16
18
19 // 3dsmax poly canton
20 {
21 /*Entity& meshentity = CreateEntity("DefaultMesh");
22 MeshComponent& meshComp = meshentity.AddComponent<MeshComponent>();
23 TransformComponent& transformComp1 = meshentity.GetComponent<TransformComponent>();
24 transformComp1.SetScale({ 25.0f, 25.0f, 25.0f });
25 transformComp1.SetPostion({ 0.0f, -5.0f, 0.0f });
26
27 std::shared_ptr<FilePack> pack1 = std::make_shared<FilePack>("112");
28 pack1->SetMaterial("BasePassRenderer.Mesh.0");
29 std::shared_ptr<Mesh> mesh = Mesh::Builder().AddPack(pack1).Build();
30 meshComp.SetMesh(mesh);*/
31 }
32
33 // bridge pbr model
34 {
35 WorldFunctions::CreateMeshEntity(this, "DefaultMesh", []() {
36
37 std::shared_ptr<FilePack> pack1 = std::make_shared<FilePack>("interior_stair_wl3ieamdw_01");
38 std::shared_ptr<FilePack> pack2 = std::make_shared<FilePack>("interior_stair_wl3ieamdw_02");
39 std::shared_ptr<FilePack> pack3 = std::make_shared<FilePack>("interior_stair_wl3ieamdw_03");
40 std::shared_ptr<FilePack> pack4 = std::make_shared<FilePack>("interior_stair_wl3ieamdw_04");
41 std::shared_ptr<FilePack> pack5 = std::make_shared<FilePack>("interior_stair_wl3ieamdw_05");
42
43 pack1->SetMaterial("BasePassRenderer.Mesh.interior_stair_wl3ieamdw");
44 pack2->SetMaterial("BasePassRenderer.Mesh.interior_stair_wl3ieamdw");
45 pack3->SetMaterial("BasePassRenderer.Mesh.interior_stair_wl3ieamdw");
46 pack4->SetMaterial("BasePassRenderer.Mesh.interior_stair_wl3ieamdw");
47 pack5->SetMaterial("BasePassRenderer.Mesh.interior_stair_wl3ieamdw");
48
49 return Mesh::Builder().AddPack(pack1).AddPack(pack2).AddPack(pack3).AddPack(pack4).AddPack(pack5).Build();
50
51 }, [](Entity& e) {
52
53 auto& transform = e.GetComponent<TransformComponent>();
54 transform.SetPosition({ 10.0f, 2.0f, 30.0f });
55 transform.SetRotation({ -180.0f, 0.0f, -180.0f });
56
57 });
58 }
59
60 // CornellBox
61 {
62 for(int i = 0; i < 3; i++)
63 {
64 std::stringstream ss;
65 ss << "CornellBox_" << i;
66
67 WorldFunctions::CreateMeshEntity(this, ss.str(), [=]() {
68
69 std::shared_ptr<FilePack> pack = std::make_shared<FilePack>("Test_room");
70
71 std::stringstream mss;
72 mss << "BasePassRenderer.Mesh.CornellBox" << i;
73 pack->SetMaterial(mss.str());
74 return Mesh::Builder().AddPack(pack).Build();
75
76 }, [=](Entity& e) {
77
78 auto& transform = e.GetComponent<TransformComponent>();
79 transform.SetPosition({ -7.0f, 5.0f, 5.0f + i * 10.0f });
80 transform.SetRotation({ 0.0f, -90.0f, 0.0f });
81
82 });
83 }
84 }
85
86 // sphere
87 {
88 for(int i = 0; i < 4; i++) // range in albedo
89 {
90 for(int j = 0; j < 10; j++) // range in roughness
91 {
92 std::stringstream ss;
93 ss << "Sphere_" << 10 * i + j;
94
95 WorldFunctions::CreateMeshEntity(this, ss.str(), [=]() {
96
97 std::shared_ptr<SpherePack> pack = std::make_shared<SpherePack>(100, 100);
98
99 std::stringstream mss;
100 mss << "BasePassRenderer.Mesh." << 10 * i + j;
101
102 pack->SetMaterial(mss.str());
103 return Mesh::Builder().AddPack(pack).Build();
104
105 }, [=](Entity& e) {
106
107 auto& transform = e.GetComponent<TransformComponent>();
108 transform.SetPosition({ 3.0f * i, 0.0f, 3.0f * j });
109
110 });
111 }
112 }
113 }
114
115 // testsphere
116 /*{
117 for (int i = 0; i < 1; i++) // range in albedo
118 {
119 for (int j = 0; j < 100; j++) // range in roughness
120 {
121 for (int k = 0; k < 100; k++)
122 {
123 std::stringstream ss;
124 ss << "TestSphere_" << 10000 * i + 100 * j + k;
125
126 WorldFunctions::CreateMeshEntity(this, ss.str(), []() {
127
128 std::shared_ptr<PlanePack> pack = std::make_shared<PlanePack>(2, 2, false);
129
130 std::stringstream mss;
131 mss << "BasePassRenderer.Mesh.0";
132
133 pack->SetMaterial(mss.str());
134 return Mesh::Builder().AddPack(pack).Build();
135
136 }, [i, j, k](Entity& e) {
137
138 auto& transform = e.GetComponent<TransformComponent>();
139 transform.SetPosition({ 3.0f * i, 3.0f * k, 3.0f * j });
140
141 });
142 }
143 }
144 }
145 }*/
146
147 // ground
148 WorldFunctions::CreateMeshEntity(this, "Ground", []() {
149
150 std::shared_ptr<PlanePack> pack = std::make_shared<PlanePack>(1000, 1000);
151
152 pack->SetMaterial("BasePassRenderer.Mesh.ground");
153 return Mesh::Builder().AddPack(pack).Build();
154
155 }, [](Entity& e) {
156
157 auto& transform = e.GetComponent<TransformComponent>();
158 transform.SetPosition({ 0.0f, -1.1f, 15.0f });
159 transform.SetRotation({ 90.0f, 0.0f, 0.0f });
160 transform.SetScale({ 500.0f, 500.0f, 500.0f });
161
162 });
163
164 // pointlight
165 {
166 Entity plightentity = CreateEntity("PointLight");
167 PointLightComponent& plightComp = plightentity.AddComponent<PointLightComponent>();
168 plightComp.SetColor(glm::vec3(1.0f, 1.0f, 0.0f));
169 plightComp.SetIntensity(20.0f);
170 SpriteComponent& sprite = plightentity.AddComponent<SpriteComponent>();
171 sprite.SetMaterial("SpriteRenderer.Sprite.S_LightPoint");
172 TransformComponent& transformComp = plightentity.GetComponent<TransformComponent>();
173 transformComp.SetPosition({ -7.0f, 7.0f, 5.0f });
174 }
175 {
176 Entity plightentity = CreateEntity("PointLight");
177 PointLightComponent& plightComp = plightentity.AddComponent<PointLightComponent>();
178 plightComp.SetColor(glm::vec3(1.0f, 0.0f, 1.0f));
179 plightComp.SetIntensity(20.0f);
180 SpriteComponent& sprite = plightentity.AddComponent<SpriteComponent>();
181 sprite.SetMaterial("SpriteRenderer.Sprite.S_LightPoint");
182 TransformComponent& transformComp = plightentity.GetComponent<TransformComponent>();
183 transformComp.SetPosition({ -7.0f, 5.0f, 15.0f });
184 }
185 {
186 Entity plightentity = CreateEntity("PointLight");
187 PointLightComponent& plightComp = plightentity.AddComponent<PointLightComponent>();
188 plightComp.SetColor(glm::vec3(1.0f, 1.0f, 1.0f));
189 plightComp.SetIntensity(20.0f);
190 SpriteComponent& sprite = plightentity.AddComponent<SpriteComponent>();
191 sprite.SetMaterial("SpriteRenderer.Sprite.S_LightPoint");
192 TransformComponent& transformComp = plightentity.GetComponent<TransformComponent>();
193 transformComp.SetPosition({ -7.0f, 5.0f, 25.0f });
194 }
195
196 /*{
197 GltfCollection collection("E:/OpenGLProjects/ExtensionAssets/BoomBox/glTF/BoomBox.gltf");
198 collection.CreateEntity(this, "BoomBox");
199 }*/
200 }
#define SPICES_PROFILE_ZONE
virtual void OnPreActivate() override
This interface define the specific world behave before on activated.
static void RegistryResourceFolder(const std::string &folder)
Registry Resource Search Folder.
static void CreateMeshEntity(World *world, const std::string &name, std::function< std::shared_ptr< Mesh >()> onMeshCreated, std::function< void(Entity &)> onAdded=nullptr)
Create Entity with a Basic MeshComponent Async.
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::EditorWorld::OnPreActivate(), Spices::PointLightComponent::SetIntensity(), and Spices::SpriteComponent::SetMaterial().