mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-22 15:48:09 -05:00
Implement/match LegoBackgroundColor::SetLightColor and related (#758)
This commit is contained in:
parent
369f3fba22
commit
ed9e9efdab
6 changed files with 61 additions and 17 deletions
|
@ -10,8 +10,8 @@ class LegoBackgroundColor : public MxVariable {
|
|||
LegoBackgroundColor(const char* p_key, const char* p_value);
|
||||
|
||||
void SetValue(const char* p_colorString) override;
|
||||
void SetLights(float p_r, float p_g, float p_b);
|
||||
void SetLights();
|
||||
void SetLightColor(float p_r, float p_g, float p_b);
|
||||
void SetLightColor();
|
||||
void ToggleDayNight(MxBool);
|
||||
void ToggleSkyColor();
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ void LegoBackgroundColor::ToggleDayNight(MxBool p_sun)
|
|||
float convertedR, convertedG, convertedB;
|
||||
ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
|
||||
VideoManager()->SetSkyColor(convertedR, convertedG, convertedB);
|
||||
SetLights(convertedR, convertedG, convertedB);
|
||||
SetLightColor(convertedR, convertedG, convertedB);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1003c330
|
||||
|
@ -110,18 +110,39 @@ void LegoBackgroundColor::ToggleSkyColor()
|
|||
float convertedR, convertedG, convertedB;
|
||||
ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
|
||||
VideoManager()->SetSkyColor(convertedR, convertedG, convertedB);
|
||||
SetLights(convertedR, convertedG, convertedB);
|
||||
SetLightColor(convertedR, convertedG, convertedB);
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1003c400
|
||||
void LegoBackgroundColor::SetLights(float p_r, float p_g, float p_b)
|
||||
// FUNCTION: LEGO1 0x1003c400
|
||||
void LegoBackgroundColor::SetLightColor(float p_r, float p_g, float p_b)
|
||||
{
|
||||
if (!VideoManager()->GetVideoParam().Flags().GetF2bit0()) {
|
||||
// TODO: Computed constants based on what?
|
||||
p_r *= 4.3478260869565215;
|
||||
p_g *= 1.5873015873015872;
|
||||
p_b *= 1.1764705882352942;
|
||||
|
||||
if (p_r > 1.0) {
|
||||
p_r = 1.0;
|
||||
}
|
||||
|
||||
if (p_g > 1.0) {
|
||||
p_g = 1.0;
|
||||
}
|
||||
|
||||
if (p_b > 1.0) {
|
||||
p_b = 1.0;
|
||||
}
|
||||
|
||||
VideoManager()->Get3DManager()->GetLego3DView()->SetLightColor(FALSE, p_r, p_g, p_b);
|
||||
VideoManager()->Get3DManager()->GetLego3DView()->SetLightColor(TRUE, p_r, p_g, p_b);
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1003c4b0
|
||||
void LegoBackgroundColor::SetLights()
|
||||
void LegoBackgroundColor::SetLightColor()
|
||||
{
|
||||
float convertedR, convertedG, convertedB;
|
||||
ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
|
||||
SetLights(convertedR, convertedG, convertedB);
|
||||
SetLightColor(convertedR, convertedG, convertedB);
|
||||
}
|
||||
|
|
|
@ -350,7 +350,7 @@ MxResult LegoGameState::Load(MxULong p_slot)
|
|||
}
|
||||
} while (status != 2);
|
||||
|
||||
m_backgroundColor->SetLights();
|
||||
m_backgroundColor->SetLightColor();
|
||||
lightPosition = VariableTable()->GetVariable("lightposition");
|
||||
|
||||
if (lightPosition) {
|
||||
|
@ -1072,7 +1072,7 @@ void LegoGameState::RegisterState(LegoState* p_state)
|
|||
void LegoGameState::Init()
|
||||
{
|
||||
m_backgroundColor->SetValue("set 56 54 68");
|
||||
m_backgroundColor->SetLights();
|
||||
m_backgroundColor->SetLightColor();
|
||||
m_tempBackgroundColor->SetValue("set 56 54 68");
|
||||
VariableTable()->SetVariable("lightposition", "2");
|
||||
SetLightPosition(2);
|
||||
|
|
|
@ -403,8 +403,8 @@ void SetLightPosition(MxS32 p_index)
|
|||
CalcLocalTransform(position, direction, up, transform);
|
||||
SETMAT4(in, transform);
|
||||
|
||||
VideoManager()->Get3DManager()->GetLego3DView()->SetLight(FALSE, matrix);
|
||||
VideoManager()->Get3DManager()->GetLego3DView()->SetLight(TRUE, matrix);
|
||||
VideoManager()->Get3DManager()->GetLego3DView()->SetLightTransform(FALSE, matrix);
|
||||
VideoManager()->Get3DManager()->GetLego3DView()->SetLightTransform(TRUE, matrix);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1003f3b0
|
||||
|
|
|
@ -184,7 +184,7 @@ void LegoView1::Destroy()
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100abb60
|
||||
void LegoView1::SetLight(BOOL bDirectionalLight, Tgl::FloatMatrix4& rMatrix)
|
||||
void LegoView1::SetLightTransform(BOOL bDirectionalLight, Tgl::FloatMatrix4& rMatrix)
|
||||
{
|
||||
Tgl::Light* pLight;
|
||||
|
||||
|
@ -195,11 +195,32 @@ void LegoView1::SetLight(BOOL bDirectionalLight, Tgl::FloatMatrix4& rMatrix)
|
|||
pLight = m_pDirectionalLight;
|
||||
}
|
||||
|
||||
SetLight(pLight, rMatrix);
|
||||
SetLightTransform(pLight, rMatrix);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100abb80
|
||||
void LegoView1::SetLight(Tgl::Light* pLight, Tgl::FloatMatrix4& rMatrix)
|
||||
void LegoView1::SetLightTransform(Tgl::Light* pLight, Tgl::FloatMatrix4& rMatrix)
|
||||
{
|
||||
pLight->SetTransformation(rMatrix);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100abba0
|
||||
void LegoView1::SetLightColor(BOOL bDirectionalLight, float red, float green, float blue)
|
||||
{
|
||||
Tgl::Light* pLight;
|
||||
|
||||
if (bDirectionalLight == FALSE) {
|
||||
pLight = m_pSunLight;
|
||||
}
|
||||
else {
|
||||
pLight = m_pDirectionalLight;
|
||||
}
|
||||
|
||||
SetLightColor(pLight, red, green, blue);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100abbd0
|
||||
void LegoView1::SetLightColor(Tgl::Light* pLight, float red, float green, float blue)
|
||||
{
|
||||
pLight->SetColor(red, green, blue);
|
||||
}
|
||||
|
|
|
@ -65,10 +65,12 @@ class LegoView1 : public LegoView {
|
|||
BOOL Create(const TglSurface::CreateStruct&, Tgl::Renderer*);
|
||||
void Destroy() override; // vtable+0x08
|
||||
|
||||
void SetLight(BOOL bDirectionalLight, Tgl::FloatMatrix4& rMatrix);
|
||||
void SetLightTransform(BOOL bDirectionalLight, Tgl::FloatMatrix4& rMatrix);
|
||||
void SetLightColor(BOOL bDirectionalLight, float red, float green, float blue);
|
||||
|
||||
private:
|
||||
void SetLight(Tgl::Light* pLight, Tgl::FloatMatrix4& rMatrix);
|
||||
void SetLightTransform(Tgl::Light* pLight, Tgl::FloatMatrix4& rMatrix);
|
||||
void SetLightColor(Tgl::Light* pLight, float red, float green, float blue);
|
||||
|
||||
Tgl::Light* m_pSunLight; // 0x78
|
||||
Tgl::Light* m_pDirectionalLight; // 0x7c
|
||||
|
|
Loading…
Reference in a new issue