Skip to content

Commit

Permalink
move sky properties from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
fallahn committed Nov 9, 2024
1 parent 1c914a9 commit 8698d96
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 35 deletions.
4 changes: 2 additions & 2 deletions crogine.sln
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ Global
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|Any CPU.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|ARM.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|ARM64.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.ActiveCfg = ReleaseGNS|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.Build.0 = ReleaseGNS|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.ActiveCfg = Release|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.Build.0 = Release|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x86.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x86.Build.0 = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release-asan|Any CPU.ActiveCfg = Release-asan|Win32
Expand Down
2 changes: 1 addition & 1 deletion libsocial/include/Social.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Social final
{
SocialMessage = 10000,
StatsMessage,
LocationMesage
LocationMessage
};
};

Expand Down
42 changes: 11 additions & 31 deletions samples/golf/src/golf/MenuState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ namespace
#include "shaders/ShaderIncludes.inl"
#include "shaders/ShadowMapping.inl"

//constexpr glm::vec3 CameraBasePosition(-22.f, 4.9f, 22.2f);
constexpr std::array<MenuSky, TimeOfDay::Count> Skies =
{
MenuSky(glm::vec3(-0.2505335f, 0.62932f, 0.590418f), cro::Colour(0.396f, 0.404f, 0.698f, 1.f), cro::Colour(0.004f, 0.035f, 0.105f,1.f), cro::Colour(0.176f,0.239f,0.321f,1.f), 1.f),
MenuSky(glm::vec3(-0.505335f,0.600000f,0.590418f), cro::Colour(0.565738f,0.498943f,0.877451f,1.f), cro::Colour(0.817771f,0.716792f,0.931373f,1.f), cro::Colour(0.882353f,0.612660f,0.423875f,1.f), 0.252f),
MenuSky(glm::vec3(-0.2505335f, 1.62932f, 0.590418f), cro::Colour(1.f,1.f,1.f,1.f), cro::Colour(0.723f, 0.847f, 0.792f, 1.f), cro::Colour(1.f, 0.973f, 0.882f, 1.f), 0.f),
MenuSky(glm::vec3(0.505335f,0.629320f,0.590418f), cro::Colour(0.473237f,0.403427f,0.799020f,1.f), cro::Colour(0.710784f,0.546615f,0.400687f,1.f), cro::Colour(0.877451f,0.742618f,0.288182f,1.f), 0.252f)
};

bool checkCommandLine = true;

Expand Down Expand Up @@ -1795,11 +1801,11 @@ void MenuState::createScene()
if (spooky)
{
propFilePath = "spooky.bgd";
m_sharedData.menuSky = Skies[TimeOfDay::Night];
}
else
{
auto td = m_tod.getTimeOfDay();

switch (td)
{
default:
Expand All @@ -1816,44 +1822,18 @@ void MenuState::createScene()
propFilePath = "03.bgd";
break;
}
m_sharedData.menuSky = Skies[td];
}


cro::ConfigFile propFile;
if (propFile.loadFromFile("assets/golf/menu/" + propFilePath))
{
const auto& objs = propFile.getObjects();
for (const auto& obj : objs)
{
const auto& objName = obj.getName();
if (objName == "sky")
{
const auto& skyProps = obj.getProperties();
for (const auto& prop : skyProps)
{
const auto& propName = prop.getName();
if (propName == "top")
{
m_sharedData.menuSky.skyTop = prop.getValue<cro::Colour>();
}
else if (propName == "bottom")
{
m_sharedData.menuSky.skyBottom = prop.getValue<cro::Colour>();
}
else if (propName == "stars")
{
m_sharedData.menuSky.stars = std::clamp(prop.getValue<float>(), 0.f, 1.f);
}
else if (propName == "sun_position")
{
m_sharedData.menuSky.sunPos = prop.getValue<glm::vec3>();
}
else if (propName == "sun_colour")
{
m_sharedData.menuSky.sunColour = prop.getValue<cro::Colour>();
}
}
}
else if (objName == "prop")
if (objName == "prop")
{
glm::vec3 position(0.f);
float rotation = 0.f;
Expand Down
5 changes: 5 additions & 0 deletions samples/golf/src/golf/SharedStateData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ struct MenuSky final
cro::Colour skyTop = cro::Colour(0.723f, 0.847f, 0.792f, 1.f);
cro::Colour skyBottom = 0xfff8e1ff;
float stars = 0.f;

MenuSky() = default;

constexpr MenuSky(glm::vec3 sPos, cro::Colour sCol, cro::Colour top, cro::Colour bottom, float s)
: sunPos(sPos), sunColour(sCol), skyTop(top), skyBottom(bottom), stars(s) {}
};

struct ChatFonts final
Expand Down
4 changes: 3 additions & 1 deletion samples/golf/src/golf/TimeOfDay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class TimeOfDay final
enum
{
Night, Morning,
Day, Evening
Day, Evening,

Count
};

std::int32_t getTimeOfDay() const;
Expand Down

0 comments on commit 8698d96

Please sign in to comment.