Skip to content

Commit

Permalink
Merge pull request #22 from KTStephano/v0.9.2
Browse files Browse the repository at this point in the history
v0.9.2 -> Master
  • Loading branch information
KTStephano authored Mar 27, 2023
2 parents 22bdb30 + bcc487b commit 0a62ab2
Show file tree
Hide file tree
Showing 30 changed files with 563 additions and 242 deletions.
2 changes: 1 addition & 1 deletion Examples/Common/CameraController.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ struct CameraController : public stratus::InputHandler {
private:
stratus::CameraPtr _camera;
stratus::LightPtr _cameraLight;
bool _cameraLightEnabled = true;
bool _cameraLightEnabled = false;
bool _cameraMoveEnabled = true;
bool _cameraRotateEnabled = true;
glm::vec3 _cameraSpeed = glm::vec3(0.0f);
Expand Down
2 changes: 1 addition & 1 deletion Examples/Common/FrameRateController.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct FrameRateController : public stratus::InputHandler {
FrameRateController() {
//INSTANCE(RendererFrontend)->SetVsyncEnabled(true);
// 1000 fps is just to get the engine out of the way so SDL can control it with vsync
_frameRates = {1000, 55, 50, 45, 40, 35, 30};
_frameRates = {1000, 60, 55, 50, 45, 40, 35, 30};
INSTANCE(Engine)->SetMaxFrameRate(_frameRates[0]);
}

Expand Down
4 changes: 3 additions & 1 deletion Examples/Common/LightControllers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ struct LightDeleteController : public stratus::InputHandler {
break;
}
case SDL_SCANCODE_L: {
printLights = true;
if (released) {
printLights = true;
}
break;
}
}
Expand Down
4 changes: 4 additions & 0 deletions Examples/Common/WorldLightController.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ struct WorldLightController : public stratus::InputHandler {
INSTANCE(RendererFrontend)->ClearWorldLight();
}

void SetRotation(const stratus::Rotation& r) {
_worldLight->setRotation(r);
}

void HandleInput(const stratus::MouseState& mouse, const std::vector<SDL_Event>& input, const double deltaSeconds) {
const double lightRotationSpeed = _rotationSpeeds[_rotationIndex];
const double lightIncreaseSpeed = 5.0;
Expand Down
162 changes: 81 additions & 81 deletions Examples/ExampleEnv01/StratusGFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ class StratusGFX : public stratus::Application {
}

void PrintNodeHierarchy(const stratus::EntityPtr& p, const std::string& name, const std::string& prefix) {
auto rc = stratus::GetComponent<stratus::RenderComponent>(p);
std::cout << prefix << name << "{Meshes: " << (rc ? rc->GetMeshCount() : 0) << "}" << std::endl;
if (rc) {
for (size_t i = 0; i < rc->GetMeshCount(); ++i) {
std::cout << rc->GetMeshTransform(i) << std::endl;
}
}
for (auto& c : p->GetChildNodes()) {
PrintNodeHierarchy(c, name, prefix + "-> ");
}
// auto rc = stratus::GetComponent<stratus::RenderComponent>(p);
// std::cout << prefix << name << "{Meshes: " << (rc ? rc->GetMeshCount() : 0) << "}" << std::endl;
// if (rc) {
// for (size_t i = 0; i < rc->GetMeshCount(); ++i) {
// std::cout << rc->GetMeshTransform(i) << std::endl;
// }
// }
// for (auto& c : p->GetChildNodes()) {
// PrintNodeHierarchy(c, name, prefix + "-> ");
// }
}

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

// stratus::Async<stratus::Entity> e;
// e = Resources()->LoadModel("../Resources/resources/models/Latrine.fbx", stratus::ColorSpace::LINEAR);
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
// outhouse = e.GetPtr();
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(outhouse);
// transform->SetLocalScale(glm::vec3(15.0f));
// transform->SetLocalPosition(glm::vec3(-50.0f, -10.0f, -45.0f));
// INSTANCE(EntityManager)->AddEntity(outhouse);
// });

// e = Resources()->LoadModel("../Resources/resources/models/hromada_hlina_01_30k_f.FBX", stratus::ColorSpace::SRGB);
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
// clay = e.GetPtr();
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(clay);
// transform->SetLocalPosition(glm::vec3(100.0f, 0.0f, -50.0f));
// //transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-180.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
// INSTANCE(EntityManager)->AddEntity(clay);
// PrintNodeHierarchy(clay, "Clay", "");
// });

// e = Resources()->LoadModel("../Resources/resources/models/boubin_stump.FBX", stratus::ColorSpace::SRGB);
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
// stump = e.GetPtr();
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(stump);
// transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-180.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
// transform->SetLocalPosition(glm::vec3(0.0f, -15.0f, -20.0f));
// INSTANCE(EntityManager)->AddEntity(stump);
// PrintNodeHierarchy(stump, "Stump", "");
// });

// e = Resources()->LoadModel("../Resources/local/hintze-hall-1m.obj", stratus::ColorSpace::SRGB);
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
// hall = e.GetPtr();
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(hall);
// transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-90.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
// transform->SetLocalScale(glm::vec3(10.0f, 10.0f, 10.0f));
// transform->SetLocalPosition(glm::vec3(-250.0f, -30.0f, 0.0f));
// INSTANCE(EntityManager)->AddEntity(hall);
// PrintNodeHierarchy(hall, "Hall", "");
// });

// e = Resources()->LoadModel("../Resources/local/model.obj", stratus::ColorSpace::SRGB);
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
// ramparts = e.GetPtr();
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(ramparts);
// transform->SetLocalPosition(glm::vec3(300.0f, 0.0f, -100.0f));
// transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(90.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
// transform->SetLocalScale(glm::vec3(10.0f));
// INSTANCE(EntityManager)->AddEntity(ramparts);
// });

// e = Resources()->LoadModel("../Resources/local/Rock_Terrain_SF.obj", stratus::ColorSpace::SRGB);
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
// rocks = e.GetPtr();
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(rocks);
// transform->SetLocalPosition(glm::vec3(700.0f, -75.0f, -100.0f));
// transform->SetLocalScale(glm::vec3(15.0f));
// INSTANCE(EntityManager)->AddEntity(rocks);
// PrintNodeHierarchy(rocks, "Rocks", "");
// });

// // Disable culling for this model since there are some weird parts that seem to be reversed
// e = Resources()->LoadModel("../Resources/glTF-Sample-Models/2.0/Sponza/glTF/Sponza.gltf", stratus::ColorSpace::SRGB, stratus::RenderFaceCulling::CULLING_CCW);
// e.AddCallback([this](stratus::Async<stratus::Entity> e) {
// sponza = e.GetPtr();
// auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(sponza);
// transform->SetLocalPosition(glm::vec3(0.0f, -300.0f, -500.0f));
// transform->SetLocalScale(glm::vec3(15.0f));
// INSTANCE(EntityManager)->AddEntity(sponza);
// PrintNodeHierarchy(sponza, "Sponza", "");
// });
stratus::Async<stratus::Entity> e;
e = Resources()->LoadModel("../Resources/resources/models/Latrine.fbx", stratus::ColorSpace::LINEAR, true, stratus::RenderFaceCulling::CULLING_CCW);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
outhouse = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(outhouse);
transform->SetLocalScale(glm::vec3(15.0f));
transform->SetLocalPosition(glm::vec3(-50.0f, -10.0f, -45.0f));
INSTANCE(EntityManager)->AddEntity(outhouse);
});

e = Resources()->LoadModel("../Resources/resources/models/hromada_hlina_01_30k_f.FBX", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
clay = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(clay);
transform->SetLocalPosition(glm::vec3(100.0f, 0.0f, -50.0f));
//transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-180.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
INSTANCE(EntityManager)->AddEntity(clay);
PrintNodeHierarchy(clay, "Clay", "");
});

e = Resources()->LoadModel("../Resources/resources/models/boubin_stump.FBX", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
stump = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(stump);
transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-180.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
transform->SetLocalPosition(glm::vec3(0.0f, -15.0f, -20.0f));
INSTANCE(EntityManager)->AddEntity(stump);
PrintNodeHierarchy(stump, "Stump", "");
});

e = Resources()->LoadModel("../Resources/local/hintze-hall-1m.obj", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
hall = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(hall);
transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(-90.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
transform->SetLocalScale(glm::vec3(10.0f, 10.0f, 10.0f));
transform->SetLocalPosition(glm::vec3(-250.0f, -30.0f, 0.0f));
INSTANCE(EntityManager)->AddEntity(hall);
PrintNodeHierarchy(hall, "Hall", "");
});

e = Resources()->LoadModel("../Resources/local/model.obj", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
ramparts = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(ramparts);
transform->SetLocalPosition(glm::vec3(300.0f, 0.0f, -100.0f));
transform->SetLocalRotation(stratus::Rotation(stratus::Degrees(90.0f), stratus::Degrees(0.0f), stratus::Degrees(0.0f)));
transform->SetLocalScale(glm::vec3(10.0f));
INSTANCE(EntityManager)->AddEntity(ramparts);
});

e = Resources()->LoadModel("../Resources/local/Rock_Terrain_SF.obj", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
rocks = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(rocks);
transform->SetLocalPosition(glm::vec3(700.0f, -75.0f, -100.0f));
transform->SetLocalScale(glm::vec3(15.0f));
INSTANCE(EntityManager)->AddEntity(rocks);
PrintNodeHierarchy(rocks, "Rocks", "");
});

// Disable culling for this model since there are some weird parts that seem to be reversed
e = Resources()->LoadModel("../Resources/glTF-Sample-Models/2.0/Sponza/glTF/Sponza.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
e.AddCallback([this](stratus::Async<stratus::Entity> e) {
sponza = e.GetPtr();
auto transform = stratus::GetComponent<stratus::LocalTransformComponent>(sponza);
transform->SetLocalPosition(glm::vec3(0.0f, -300.0f, -500.0f));
transform->SetLocalScale(glm::vec3(15.0f));
INSTANCE(EntityManager)->AddEntity(sponza);
PrintNodeHierarchy(sponza, "Sponza", "");
});

for (size_t texIndex = 0; texIndex < textures.size(); ++texIndex) {
auto cube = Resources()->CreateCube();
Expand Down
50 changes: 21 additions & 29 deletions Examples/ExampleEnv02/Sponza.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class Sponza : public stratus::Application {

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

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

// Disable culling for this model since there are some weird parts that seem to be reversed
//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);
//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);
stratus::Async<stratus::Entity> e = stratus::ResourceManager::Instance()->LoadModel("../Resources/Sponza2022/scene.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
stratus::Async<stratus::Entity> e2 = stratus::ResourceManager::Instance()->LoadModel("../Resources/local/Sponza2022/NewSponza_Curtains_glTF.gltf", stratus::ColorSpace::SRGB, true, stratus::RenderFaceCulling::CULLING_CCW);
requested.push_back(e);
requested.push_back(e2);

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

// for (int i = 0; i < 64; ++i) {
// float x = rand() % 600;gg
// float x = rand() % 600;
// float y = rand() % 600;
// float z = rand() % 200;
// stratus::VirtualPointLight * vpl = new stratus::VirtualPointLight();
Expand Down Expand Up @@ -180,32 +183,21 @@ class Sponza : public stratus::Application {
}

if (requested.size() == received.size()) {
received.clear();
int spawned = 0;
// for (int x = 45; x > 0; x -= 10) {
// for (int y = 5; y < 270; y += 30) {
// for (int z = -140; z < 180; z += 35) {
// ++spawned;
// LightCreator::CreateVirtualPointLight(
// LightParams(glm::vec3(float(x), float(y), float(z)), glm::vec3(1.0f), 100.0f),
// true
// );
// }
// }
// }
for (int x = 60; x > 0; x -= 20) {
for (int y = 15; y < 260; y += 40) {
for (int z = -140; z < 180; z += 20) {
++spawned;
LightCreator::CreateVirtualPointLight(
LightParams(glm::vec3(float(x), float(y), float(z)), glm::vec3(1.0f), 100.0f),
false
);
}
}
}

STRATUS_LOG << "SPAWNED " << spawned << " VPLS\n";
received.clear();
int spawned = 0;
for (int x = 60; x > 0; x -= 20) {
for (int y = 15; y < 240; y += 40) {
for (int z = -140; z < 180; z += 20) {
++spawned;
LightCreator::CreateVirtualPointLight(
LightParams(glm::vec3(float(x), float(y), float(z)), glm::vec3(1.0f), 100.0f),
false
);
}
}
}

STRATUS_LOG << "SPAWNED " << spawned << " VPLS\n";
}

// worldLight->setRotation(glm::vec3(75.0f, 0.0f, 0.0f));
Expand Down
22 changes: 22 additions & 0 deletions Examples/ExampleEnv03/Interrogation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ class Interrogation : public stratus::Application {
//transform->SetLocalPosition(glm::vec3(0.0f));
transform->SetLocalScale(glm::vec3(15.0f));
INSTANCE(EntityManager)->AddEntity(interrogationRoom);
received.push_back(e.GetPtr());
});

requested.push_back(e);

INSTANCE(RendererFrontend)->SetFogColor(glm::vec3(167.0f / 255.0f, 166.0f / 255.0f, 157.0f / 255.0f));
INSTANCE(RendererFrontend)->SetFogDensity(0.00125);

Expand Down Expand Up @@ -242,6 +245,23 @@ class Interrogation : public stratus::Application {

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

if (requested.size() == received.size()) {
requested.clear();

LightCreator::CreateStationaryLight(
LightParams(glm::vec3(-11.2298, 15.3294, 23.1447), glm::vec3(1, 1, 1), 1200, true),
false
);
LightCreator::CreateStationaryLight(
LightParams(glm::vec3(-17.5113, 15.3294, 19.8197), glm::vec3(1, 1, 1), 1200, true),
false
);
LightCreator::CreateStationaryLight(
LightParams(glm::vec3(-1.03776, 34.1635, -18.8183), glm::vec3(1, 1, 0.5), 1200, true),
false
);
}

//renderer->addDrawable(rocks);

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

private:
stratus::EntityPtr interrogationRoom;
std::vector<stratus::Async<stratus::Entity>> requested;
std::vector<stratus::EntityPtr> received;
};

STRATUS_ENTRY_POINT(Interrogation)
4 changes: 3 additions & 1 deletion Examples/ExampleEnv04/SanMiguel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class SanMiguel : public stratus::Application {

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

// Alpha testing doesn't work so well for this scene
Expand Down
Loading

0 comments on commit 0a62ab2

Please sign in to comment.