2016-04-18 01:58:13 +00:00
|
|
|
#ifndef __URDE_CLIGHTPARAMETERS_HPP__
|
|
|
|
#define __URDE_CLIGHTPARAMETERS_HPP__
|
|
|
|
|
|
|
|
#include "RetroTypes.hpp"
|
|
|
|
#include "zeus/CColor.hpp"
|
2016-08-31 00:33:59 +00:00
|
|
|
#include "Character/CActorLights.hpp"
|
|
|
|
|
2016-04-18 01:58:13 +00:00
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
class CLightParameters
|
|
|
|
{
|
2017-11-24 08:23:28 +00:00
|
|
|
friend class CActor;
|
2016-08-31 00:33:59 +00:00
|
|
|
public:
|
|
|
|
enum class EShadowTesselation
|
|
|
|
{
|
|
|
|
Zero
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class EWorldLightingOptions
|
|
|
|
{
|
|
|
|
Zero,
|
|
|
|
NormalWorld,
|
2017-04-10 06:57:00 +00:00
|
|
|
NoShadowCast,
|
2016-08-31 00:33:59 +00:00
|
|
|
DisableWorld
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class ELightRecalculationOptions
|
|
|
|
{
|
2017-04-10 06:57:00 +00:00
|
|
|
LargeFrameCount,
|
|
|
|
EightFrames,
|
|
|
|
FourFrames,
|
|
|
|
OneFrame
|
2016-08-31 00:33:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2016-04-18 01:58:13 +00:00
|
|
|
bool x4_a = false;
|
|
|
|
float x8_b = 0.f;
|
2016-08-31 00:33:59 +00:00
|
|
|
EShadowTesselation xc_shadowTesselation = EShadowTesselation::Zero;
|
2016-04-18 01:58:13 +00:00
|
|
|
float x10_d = 0.f;
|
|
|
|
float x14_e = 0.f;
|
2017-04-10 06:57:00 +00:00
|
|
|
zeus::CColor x18_noLightsAmbient;
|
|
|
|
bool x1c_makeLights = false;
|
|
|
|
bool x1d_ambientChannelOverflow = false;
|
2016-08-31 00:33:59 +00:00
|
|
|
EWorldLightingOptions x20_worldLightingOptions = EWorldLightingOptions::Zero;
|
2017-04-10 06:57:00 +00:00
|
|
|
ELightRecalculationOptions x24_lightRecalcOpts = ELightRecalculationOptions::EightFrames;
|
|
|
|
s32 x28_layerIdx = 0;
|
|
|
|
zeus::CVector3f x2c_actorPosBias;
|
|
|
|
s32 x38_maxDynamicLights = 4;
|
|
|
|
s32 x3c_maxAreaLights = 4;
|
2016-04-18 01:58:13 +00:00
|
|
|
public:
|
|
|
|
CLightParameters() = default;
|
2017-04-10 06:57:00 +00:00
|
|
|
CLightParameters(bool a, float b, EShadowTesselation shadowTess, float d, float e, const zeus::CColor& noLightsAmbient,
|
|
|
|
bool makeLights, EWorldLightingOptions lightingOpts, ELightRecalculationOptions lightRecalcOpts,
|
|
|
|
const zeus::CVector3f& actorPosBias, s32 maxDynamicLights, s32 maxAreaLights, bool ambChannelOverflow, s32 layerIdx)
|
|
|
|
: x4_a(a), x8_b(b), xc_shadowTesselation(shadowTess), x10_d(d), x14_e(e), x18_noLightsAmbient(noLightsAmbient), x1c_makeLights(makeLights),
|
|
|
|
x1d_ambientChannelOverflow(ambChannelOverflow), x20_worldLightingOptions(lightingOpts), x24_lightRecalcOpts(lightRecalcOpts),
|
|
|
|
x28_layerIdx(layerIdx), x2c_actorPosBias(actorPosBias), x38_maxDynamicLights(maxDynamicLights), x3c_maxAreaLights(maxAreaLights)
|
2016-04-18 01:58:13 +00:00
|
|
|
{
|
2017-04-10 06:57:00 +00:00
|
|
|
if (x38_maxDynamicLights > 4 || x38_maxDynamicLights == -1)
|
|
|
|
x38_maxDynamicLights = 4;
|
|
|
|
if (x3c_maxAreaLights > 4 || x3c_maxAreaLights == -1)
|
|
|
|
x3c_maxAreaLights = 4;
|
2016-04-18 01:58:13 +00:00
|
|
|
}
|
|
|
|
static CLightParameters None() {return CLightParameters();}
|
2016-08-31 00:33:59 +00:00
|
|
|
|
|
|
|
static u32 GetFramesBetweenRecalculation(ELightRecalculationOptions opts)
|
|
|
|
{
|
2017-04-10 06:57:00 +00:00
|
|
|
if (opts == ELightRecalculationOptions::LargeFrameCount)
|
2016-08-31 00:33:59 +00:00
|
|
|
return 0x3FFFFFFF;
|
2017-04-10 06:57:00 +00:00
|
|
|
else if (opts == ELightRecalculationOptions::EightFrames)
|
2016-08-31 00:33:59 +00:00
|
|
|
return 8;
|
2017-04-10 06:57:00 +00:00
|
|
|
else if (opts == ELightRecalculationOptions::FourFrames)
|
2016-08-31 00:33:59 +00:00
|
|
|
return 4;
|
2017-04-10 06:57:00 +00:00
|
|
|
else if (opts == ELightRecalculationOptions::OneFrame)
|
2016-08-31 00:33:59 +00:00
|
|
|
return 1;
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<CActorLights> MakeActorLights() const
|
|
|
|
{
|
2017-04-10 06:57:00 +00:00
|
|
|
if (!x1c_makeLights)
|
2016-08-31 00:33:59 +00:00
|
|
|
return {};
|
|
|
|
|
|
|
|
u32 updateFrames = GetFramesBetweenRecalculation(x24_lightRecalcOpts);
|
2017-04-10 06:57:00 +00:00
|
|
|
CActorLights* lights = new CActorLights(updateFrames, x2c_actorPosBias, x38_maxDynamicLights,
|
|
|
|
x3c_maxAreaLights, x1d_ambientChannelOverflow, x28_layerIdx == 1,
|
|
|
|
x20_worldLightingOptions == EWorldLightingOptions::DisableWorld,
|
2016-08-31 00:33:59 +00:00
|
|
|
0.1f);
|
2017-04-10 06:57:00 +00:00
|
|
|
if (x20_worldLightingOptions == EWorldLightingOptions::NoShadowCast)
|
|
|
|
lights->SetCastShadows(false);
|
|
|
|
if (x3c_maxAreaLights == 0)
|
|
|
|
lights->SetAmbientColor(x18_noLightsAmbient);
|
|
|
|
return std::unique_ptr<CActorLights>(lights);
|
2016-08-31 00:33:59 +00:00
|
|
|
}
|
2016-04-18 01:58:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __URDE_CLIGHTPARAMETERS_HPP__
|