Skip to content

Commit 0a62ab2

Browse files
authored
Merge pull request #22 from KTStephano/v0.9.2
v0.9.2 -> Master
2 parents 22bdb30 + bcc487b commit 0a62ab2

30 files changed

+563
-242
lines changed

Examples/Common/CameraController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct CameraController : public stratus::InputHandler {
148148
private:
149149
stratus::CameraPtr _camera;
150150
stratus::LightPtr _cameraLight;
151-
bool _cameraLightEnabled = true;
151+
bool _cameraLightEnabled = false;
152152
bool _cameraMoveEnabled = true;
153153
bool _cameraRotateEnabled = true;
154154
glm::vec3 _cameraSpeed = glm::vec3(0.0f);

Examples/Common/FrameRateController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct FrameRateController : public stratus::InputHandler {
1212
FrameRateController() {
1313
//INSTANCE(RendererFrontend)->SetVsyncEnabled(true);
1414
// 1000 fps is just to get the engine out of the way so SDL can control it with vsync
15-
_frameRates = {1000, 55, 50, 45, 40, 35, 30};
15+
_frameRates = {1000, 60, 55, 50, 45, 40, 35, 30};
1616
INSTANCE(Engine)->SetMaxFrameRate(_frameRates[0]);
1717
}
1818

Examples/Common/LightControllers.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ struct LightDeleteController : public stratus::InputHandler {
141141
break;
142142
}
143143
case SDL_SCANCODE_L: {
144-
printLights = true;
144+
if (released) {
145+
printLights = true;
146+
}
145147
break;
146148
}
147149
}

Examples/Common/WorldLightController.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ struct WorldLightController : public stratus::InputHandler {
2727
INSTANCE(RendererFrontend)->ClearWorldLight();
2828
}
2929

30+
void SetRotation(const stratus::Rotation& r) {
31+
_worldLight->setRotation(r);
32+
}
33+
3034
void HandleInput(const stratus::MouseState& mouse, const std::vector<SDL_Event>& input, const double deltaSeconds) {
3135
const double lightRotationSpeed = _rotationSpeeds[_rotationIndex];
3236
const double lightIncreaseSpeed = 5.0;

Examples/ExampleEnv01/StratusGFX.cpp

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ class StratusGFX : public stratus::Application {
3333
}
3434

3535
void PrintNodeHierarchy(const stratus::EntityPtr& p, const std::string& name, const std::string& prefix) {
36-
auto rc = stratus::GetComponent<stratus::RenderComponent>(p);
37-
std::cout << prefix << name << "{Meshes: " << (rc ? rc->GetMeshCount() : 0) << "}" << std::endl;
38-
if (rc) {
39-
for (size_t i = 0; i < rc->GetMeshCount(); ++i) {
40-
std::cout << rc->GetMeshTransform(i) << std::endl;
41-
}
42-
}
43-
for (auto& c : p->GetChildNodes()) {
44-
PrintNodeHierarchy(c, name, prefix + "-> ");
45-
}
36+
// auto rc = stratus::GetComponent<stratus::RenderComponent>(p);
37+
// std::cout << prefix << name << "{Meshes: " << (rc ? rc->GetMeshCount() : 0) << "}" << std::endl;
38+
// if (rc) {
39+
// for (size_t i = 0; i < rc->GetMeshCount(); ++i) {
40+
// std::cout << rc->GetMeshTransform(i) << std::endl;
41+
// }
42+
// }
43+
// for (auto& c : p->GetChildNodes()) {
44+
// PrintNodeHierarchy(c, name, prefix + "-> ");
45+
// }
4646
}
4747

4848
// Perform first-time initialization - true if success, false otherwise
@@ -89,77 +89,77 @@ class StratusGFX : public stratus::Application {
8989
environmentMaps.push_back(Resources()->LoadTexture("../Resources/resources/textures/Wood_Wall_003_ambientOcclusion.jpg", stratus::ColorSpace::SRGB));
9090
environmentMaps.push_back(Resources()->LoadTexture("../Resources/resources/textures/Rock_Moss_001_ambientOcclusion.jpg", stratus::ColorSpace::SRGB));
9191

92-
// stratus::Async<stratus::Entity> e;
93-
// e = Resources()->LoadModel("../Resources/resources/models/Latrine.fbx", stratus::ColorSpace::LINEAR);
94-
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
95-
// outhouse = e.GetPtr();
96-
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(outhouse);
97-
// transform->SetLocalScale(glm::vec3(15.0f));
98-
// transform->SetLocalPosition(glm::vec3(-50.0f, -10.0f, -45.0f));
99-
// INSTANCE(EntityManager)->AddEntity(outhouse);
100-
// });
101-
102-
// e = Resources()->LoadModel("../Resources/resources/models/hromada_hlina_01_30k_f.FBX", stratus::ColorSpace::SRGB);
103-
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
104-
// clay = e.GetPtr();
105-
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(clay);
106-
// transform->SetLocalPosition(glm::vec3(100.0f, 0.0f, -50.0f));
107-
// //transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-180.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
108-
// INSTANCE(EntityManager)->AddEntity(clay);
109-
// PrintNodeHierarchy(clay, "Clay", "");
110-
// });
111-
112-
// e = Resources()->LoadModel("../Resources/resources/models/boubin_stump.FBX", stratus::ColorSpace::SRGB);
113-
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
114-
// stump = e.GetPtr();
115-
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(stump);
116-
// transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-180.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
117-
// transform->SetLocalPosition(glm::vec3(0.0f, -15.0f, -20.0f));
118-
// INSTANCE(EntityManager)->AddEntity(stump);
119-
// PrintNodeHierarchy(stump, "Stump", "");
120-
// });
121-
122-
// e = Resources()->LoadModel("../Resources/local/hintze-hall-1m.obj", stratus::ColorSpace::SRGB);
123-
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
124-
// hall = e.GetPtr();
125-
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(hall);
126-
// transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-90.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
127-
// transform->SetLocalScale(glm::vec3(10.0f, 10.0f, 10.0f));
128-
// transform->SetLocalPosition(glm::vec3(-250.0f, -30.0f, 0.0f));
129-
// INSTANCE(EntityManager)->AddEntity(hall);
130-
// PrintNodeHierarchy(hall, "Hall", "");
131-
// });
132-
133-
// e = Resources()->LoadModel("../Resources/local/model.obj", stratus::ColorSpace::SRGB);
134-
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
135-
// ramparts = e.GetPtr();
136-
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(ramparts);
137-
// transform->SetLocalPosition(glm::vec3(300.0f, 0.0f, -100.0f));
138-
// transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(90.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
139-
// transform->SetLocalScale(glm::vec3(10.0f));
140-
// INSTANCE(EntityManager)->AddEntity(ramparts);
141-
// });
142-
143-
// e = Resources()->LoadModel("../Resources/local/Rock_Terrain_SF.obj", stratus::ColorSpace::SRGB);
144-
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
145-
// rocks = e.GetPtr();
146-
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(rocks);
147-
// transform->SetLocalPosition(glm::vec3(700.0f, -75.0f, -100.0f));
148-
// transform->SetLocalScale(glm::vec3(15.0f));
149-
// INSTANCE(EntityManager)->AddEntity(rocks);
150-
// PrintNodeHierarchy(rocks, "Rocks", "");
151-
// });
152-
153-
// // Disable culling for this model since there are some weird parts that seem to be reversed
154-
// e = Resources()->LoadModel("../Resources/glTF-Sample-Models/2.0/Sponza/glTF/Sponza.gltf", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_CCW);
155-
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
156-
// sponza = e.GetPtr();
157-
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(sponza);
158-
// transform->SetLocalPosition(glm::vec3(0.0f, -300.0f, -500.0f));
159-
// transform->SetLocalScale(glm::vec3(15.0f));
160-
// INSTANCE(EntityManager)->AddEntity(sponza);
161-
// PrintNodeHierarchy(sponza, "Sponza", "");
162-
// });
92+
stratus::Async<stratus::Entity> e;
93+
e = Resources()->LoadModel("../Resources/resources/models/Latrine.fbx", stratus::ColorSpace::LINEAR, true, stratus::RenderFaceCulling::CULLING_CCW);
94+
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
95+
outhouse = e.GetPtr();
96+
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(outhouse);
97+
transform->SetLocalScale(glm::vec3(15.0f));
98+
transform->SetLocalPosition(glm::vec3(-50.0f, -10.0f, -45.0f));
99+
INSTANCE(EntityManager)->AddEntity(outhouse);
100+
});
101+
102+
e = Resources()->LoadModel("../Resources/resources/models/hromada_hlina_01_30k_f.FBX", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
103+
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
104+
clay = e.GetPtr();
105+
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(clay);
106+
transform->SetLocalPosition(glm::vec3(100.0f, 0.0f, -50.0f));
107+
//transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-180.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
108+
INSTANCE(EntityManager)->AddEntity(clay);
109+
PrintNodeHierarchy(clay, "Clay", "");
110+
});
111+
112+
e = Resources()->LoadModel("../Resources/resources/models/boubin_stump.FBX", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
113+
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
114+
stump = e.GetPtr();
115+
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(stump);
116+
transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-180.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
117+
transform->SetLocalPosition(glm::vec3(0.0f, -15.0f, -20.0f));
118+
INSTANCE(EntityManager)->AddEntity(stump);
119+
PrintNodeHierarchy(stump, "Stump", "");
120+
});
121+
122+
e = Resources()->LoadModel("../Resources/local/hintze-hall-1m.obj", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
123+
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
124+
hall = e.GetPtr();
125+
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(hall);
126+
transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-90.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
127+
transform->SetLocalScale(glm::vec3(10.0f, 10.0f, 10.0f));
128+
transform->SetLocalPosition(glm::vec3(-250.0f, -30.0f, 0.0f));
129+
INSTANCE(EntityManager)->AddEntity(hall);
130+
PrintNodeHierarchy(hall, "Hall", "");
131+
});
132+
133+
e = Resources()->LoadModel("../Resources/local/model.obj", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
134+
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
135+
ramparts = e.GetPtr();
136+
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(ramparts);
137+
transform->SetLocalPosition(glm::vec3(300.0f, 0.0f, -100.0f));
138+
transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(90.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
139+
transform->SetLocalScale(glm::vec3(10.0f));
140+
INSTANCE(EntityManager)->AddEntity(ramparts);
141+
});
142+
143+
e = Resources()->LoadModel("../Resources/local/Rock_Terrain_SF.obj", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
144+
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
145+
rocks = e.GetPtr();
146+
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(rocks);
147+
transform->SetLocalPosition(glm::vec3(700.0f, -75.0f, -100.0f));
148+
transform->SetLocalScale(glm::vec3(15.0f));
149+
INSTANCE(EntityManager)->AddEntity(rocks);
150+
PrintNodeHierarchy(rocks, "Rocks", "");
151+
});
152+
153+
// Disable culling for this model since there are some weird parts that seem to be reversed
154+
e = Resources()->LoadModel("../Resources/glTF-Sample-Models/2.0/Sponza/glTF/Sponza.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
155+
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
156+
sponza = e.GetPtr();
157+
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(sponza);
158+
transform->SetLocalPosition(glm::vec3(0.0f, -300.0f, -500.0f));
159+
transform->SetLocalScale(glm::vec3(15.0f));
160+
INSTANCE(EntityManager)->AddEntity(sponza);
161+
PrintNodeHierarchy(sponza, "Sponza", "");
162+
});
163163

164164
for (size_t texIndex = 0; texIndex < textures.size(); ++texIndex) {
165165
auto cube = Resources()->CreateCube();

Examples/ExampleEnv02/Sponza.cpp

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ class Sponza : public stratus::Application {
4242

4343
const glm::vec3 warmMorningColor = glm::vec3(254.0f / 255.0f, 232.0f / 255.0f, 176.0f / 255.0f);
4444
const glm::vec3 defaultSunColor = glm::vec3(1.0f);
45-
controller = stratus::InputHandlerPtr(new WorldLightController(defaultSunColor, warmMorningColor, 5));
45+
auto wc = new WorldLightController(defaultSunColor, warmMorningColor, 5);
46+
wc->SetRotation(stratus::Rotation(stratus::Degrees(56.8385f), stratus::Degrees(10.0f), stratus::Degrees(0)));
47+
controller = stratus::InputHandlerPtr(wc);
4648
Input()->AddInputHandler(controller);
4749

4850
controller = stratus::InputHandlerPtr(new FrameRateController());
@@ -55,13 +57,14 @@ class Sponza : public stratus::Application {
5557
//INSTANCE(RendererFrontend)->SetAtmosphericShadowing(0.2f, 0.3f);
5658

5759
// Disable culling for this model since there are some weird parts that seem to be reversed
58-
//stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/glTF-Sample-Models/2.0/Sponza/glTF/Sponza.gltf", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_CCW);
60+
//stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/glTF-Sample-Models/2.0/Sponza/glTF/Sponza.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
5961
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/Sponza2022/scene.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
6062
stratus::Async<stratus::Entity> e2 = stratus::ResourceManager::Instance()->LoadModel("../Resources/local/Sponza2022/NewSponza_Curtains_glTF.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
6163
requested.push_back(e);
6264
requested.push_back(e2);
6365

6466
auto callback = [this](stratus::Async<stratus::Entity> e) {
67+
//STRATUS_LOG << "Adding\n";
6568
received.push_back(e.GetPtr());
6669
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(e.GetPtr());
6770
//transform->SetLocalPosition(glm::vec3(0.0f));
@@ -82,7 +85,7 @@ class Sponza : public stratus::Application {
8285
bool running = true;
8386

8487
// for (int i = 0; i < 64; ++i) {
85-
// float x = rand() % 600;gg
88+
// float x = rand() % 600;
8689
// float y = rand() % 600;
8790
// float z = rand() % 200;
8891
// stratus::VirtualPointLight * vpl = new stratus::VirtualPointLight();
@@ -180,32 +183,21 @@ class Sponza : public stratus::Application {
180183
}
181184

182185
if (requested.size() == received.size()) {
183-
received.clear();
184-
int spawned = 0;
185-
// for (int x = 45; x > 0; x -= 10) {
186-
// for (int y = 5; y < 270; y += 30) {
187-
// for (int z = -140; z < 180; z += 35) {
188-
// ++spawned;
189-
// LightCreator::CreateVirtualPointLight(
190-
// LightParams(glm::vec3(float(x), float(y), float(z)), glm::vec3(1.0f), 100.0f),
191-
// true
192-
// );
193-
// }
194-
// }
195-
// }
196-
for (int x = 60; x > 0; x -= 20) {
197-
for (int y = 15; y < 260; y += 40) {
198-
for (int z = -140; z < 180; z += 20) {
199-
++spawned;
200-
LightCreator::CreateVirtualPointLight(
201-
LightParams(glm::vec3(float(x), float(y), float(z)), glm::vec3(1.0f), 100.0f),
202-
false
203-
);
204-
}
205-
}
206-
}
207-
208-
STRATUS_LOG << "SPAWNED " << spawned << " VPLS\n";
186+
received.clear();
187+
int spawned = 0;
188+
for (int x = 60; x > 0; x -= 20) {
189+
for (int y = 15; y < 240; y += 40) {
190+
for (int z = -140; z < 180; z += 20) {
191+
++spawned;
192+
LightCreator::CreateVirtualPointLight(
193+
LightParams(glm::vec3(float(x), float(y), float(z)), glm::vec3(1.0f), 100.0f),
194+
false
195+
);
196+
}
197+
}
198+
}
199+
200+
STRATUS_LOG << "SPAWNED " << spawned << " VPLS\n";
209201
}
210202

211203
// worldLight->setRotation(glm::vec3(75.0f, 0.0f, 0.0f));

Examples/ExampleEnv03/Interrogation.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ class Interrogation : public stratus::Application {
6767
//transform->SetLocalPosition(glm::vec3(0.0f));
6868
transform->SetLocalScale(glm::vec3(15.0f));
6969
INSTANCE(EntityManager)->AddEntity(interrogationRoom);
70+
received.push_back(e.GetPtr());
7071
});
7172

73+
requested.push_back(e);
74+
7275
INSTANCE(RendererFrontend)->SetFogColor(glm::vec3(167.0f / 255.0f, 166.0f / 255.0f, 157.0f / 255.0f));
7376
INSTANCE(RendererFrontend)->SetFogDensity(0.00125);
7477

@@ -242,6 +245,23 @@ class Interrogation : public stratus::Application {
242245

243246
stratus::RendererFrontend::Instance()->SetClearColor(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
244247

248+
if (requested.size() == received.size()) {
249+
requested.clear();
250+
251+
LightCreator::CreateStationaryLight(
252+
LightParams(glm::vec3(-11.2298, 15.3294, 23.1447), glm::vec3(1, 1, 1), 1200, true),
253+
false
254+
);
255+
LightCreator::CreateStationaryLight(
256+
LightParams(glm::vec3(-17.5113, 15.3294, 19.8197), glm::vec3(1, 1, 1), 1200, true),
257+
false
258+
);
259+
LightCreator::CreateStationaryLight(
260+
LightParams(glm::vec3(-1.03776, 34.1635, -18.8183), glm::vec3(1, 1, 0.5), 1200, true),
261+
false
262+
);
263+
}
264+
245265
//renderer->addDrawable(rocks);
246266

247267
// Add the camera's light
@@ -267,6 +287,8 @@ class Interrogation : public stratus::Application {
267287

268288
private:
269289
stratus::EntityPtr interrogationRoom;
290+
std::vector<stratus::Async<stratus::Entity>> requested;
291+
std::vector<stratus::EntityPtr> received;
270292
};
271293

272294
STRATUS_ENTRY_POINT(Interrogation)

Examples/ExampleEnv04/SanMiguel.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class SanMiguel : public stratus::Application {
5252

5353
const glm::vec3 warmMorningColor = glm::vec3(254.0f / 255.0f, 232.0f / 255.0f, 176.0f / 255.0f);
5454
const glm::vec3 defaultSunColor = glm::vec3(1.0f);
55-
controller = stratus::InputHandlerPtr(new WorldLightController(defaultSunColor, warmMorningColor, 5));
55+
auto wc = new WorldLightController(defaultSunColor, warmMorningColor, 5);
56+
wc->SetRotation(stratus::Rotation(stratus::Degrees(100.961f), stratus::Degrees(10.0f), stratus::Degrees(0)));
57+
controller = stratus::InputHandlerPtr(wc);
5658
Input()->AddInputHandler(controller);
5759

5860
// Alpha testing doesn't work so well for this scene

0 commit comments

Comments
 (0)