From 6669dd4367c760e6833b011f5d3a1fbcdf36dda6 Mon Sep 17 00:00:00 2001 From: parax0 Date: Sun, 31 Jan 2016 23:53:35 -0700 Subject: [PATCH] Added check for the World Lighting Options property in LightParameters when lighting script nodes --- src/Core/CLightParameters.cpp | 25 ---------- src/Core/CLightParameters.h | 50 +++++++++++++++++-- src/Core/Core.pro | 1 - src/Core/Scene/CScriptNode.cpp | 20 ++++++-- templates/dkcr/Properties.xml | 2 +- templates/dkcr/Structs/LightParameters.xml | 10 +++- templates/mp1/Structs/LightParameters.xml | 9 +++- templates/mp2/Properties.xml | 2 +- templates/mp2/Structs/LightParameters.xml | 10 +++- templates/mp2demo/Properties.xml | 2 +- templates/mp2demo/Structs/LightParameters.xml | 10 +++- templates/mp3/Properties.xml | 2 +- templates/mp3/Structs/LightParameters.xml | 10 +++- templates/mp3proto/Properties.xml | 2 +- .../mp3proto/Structs/LightParameters.xml | 10 +++- 15 files changed, 117 insertions(+), 48 deletions(-) delete mode 100644 src/Core/CLightParameters.cpp diff --git a/src/Core/CLightParameters.cpp b/src/Core/CLightParameters.cpp deleted file mode 100644 index de763227..00000000 --- a/src/Core/CLightParameters.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "CLightParameters.h" - -CLightParameters::CLightParameters(CPropertyStruct *pStruct, EGame game) - : mpStruct(pStruct), mGame(game) -{ -} - -CLightParameters::~CLightParameters() -{ -} - -int CLightParameters::LightLayerIndex() -{ - if (!mpStruct) return 0; - - TLongProperty *pParam; - - if (mGame <= ePrime) - pParam = (TLongProperty*) mpStruct->PropertyByIndex(0xD); - else - pParam = (TLongProperty*) mpStruct->PropertyByID(0x1F715FD3); - - if (!pParam) return 0; - else return pParam->Get(); -} diff --git a/src/Core/CLightParameters.h b/src/Core/CLightParameters.h index 849a3c61..3f77ed3b 100644 --- a/src/Core/CLightParameters.h +++ b/src/Core/CLightParameters.h @@ -4,15 +4,59 @@ #include "Core/Resource/CGameArea.h" #include "Core/Resource/Script/IProperty.h" +enum EWorldLightingOptions +{ + eUnknown1 = 0, + eNormalLighting = 1, + eUnknown2 = 2, + eDisableWorldLighting = 3 +}; + class CLightParameters { CPropertyStruct *mpStruct; EGame mGame; + TLongProperty *mpLightLayer; + TLongProperty *mpWorldLightingOptions; + public: - CLightParameters(CPropertyStruct *pStruct, EGame game); - ~CLightParameters(); - int LightLayerIndex(); + CLightParameters(CPropertyStruct *pStruct, EGame Game) + : mpStruct(pStruct) + , mGame(Game) + , mpLightLayer(nullptr) + , mpWorldLightingOptions(nullptr) + { + if (mpStruct) + { + if (mGame <= ePrime) + { + mpWorldLightingOptions = (TLongProperty*) mpStruct->PropertyByIndex(0x7); + mpLightLayer = (TLongProperty*) mpStruct->PropertyByIndex(0xD); + } + else + { + mpWorldLightingOptions = (TLongProperty*) mpStruct->PropertyByIndex(0x6B5E7509); + mpLightLayer = (TLongProperty*) mpStruct->PropertyByID(0x1F715FD3); + } + } + } + + inline int LightLayerIndex() const + { + if (!mpLightLayer) + return 0; + else + return mpLightLayer->Get(); + } + + inline EWorldLightingOptions WorldLightingOptions() const + { + if (mpWorldLightingOptions) + return (EWorldLightingOptions) mpWorldLightingOptions->Get(); + else + return eNormalLighting; + } }; #endif // CLIGHTPARAMETERS_H diff --git a/src/Core/Core.pro b/src/Core/Core.pro index 1832fe9a..62702aca 100644 --- a/src/Core/Core.pro +++ b/src/Core/Core.pro @@ -251,7 +251,6 @@ SOURCES += \ ScriptExtra/CSpacePirateExtra.cpp \ ScriptExtra/CWaypointExtra.cpp \ CAreaAttributes.cpp \ - CLightParameters.cpp \ CRayCollisionTester.cpp \ Log.cpp \ OpenGL/CDynamicVertexBuffer.cpp \ diff --git a/src/Core/Scene/CScriptNode.cpp b/src/Core/Scene/CScriptNode.cpp index cc07a862..ab0330b4 100644 --- a/src/Core/Scene/CScriptNode.cpp +++ b/src/Core/Scene/CScriptNode.cpp @@ -154,16 +154,30 @@ void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn // Draw model if (UsesModel()) { - CGraphics::SetupAmbientColor(); + EWorldLightingOptions LightingOptions = (mpLightParameters ? mpLightParameters->WorldLightingOptions() : eNormalLighting); + + if (CGraphics::sLightMode == CGraphics::eWorldLighting && LightingOptions == eDisableWorldLighting) + { + CGraphics::sNumLights = 0; + CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack; + CGraphics::sPixelBlock.LightmapMultiplier = 1.f; + CGraphics::UpdateLightBlock(); + } + + else + { + LoadLights(ViewInfo); + CGraphics::UpdateLightBlock(); + } + LoadModelMatrix(); - LoadLights(ViewInfo); - CGraphics::UpdateVertexBlock(); // Draw model if possible! if (mpActiveModel) { if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor(); else CGraphics::sPixelBlock.TevColor = CColor::skWhite; + CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo); CGraphics::UpdatePixelBlock(); diff --git a/templates/dkcr/Properties.xml b/templates/dkcr/Properties.xml index 5130e74e..b4579003 100644 --- a/templates/dkcr/Properties.xml +++ b/templates/dkcr/Properties.xml @@ -1701,7 +1701,7 @@ - + diff --git a/templates/dkcr/Structs/LightParameters.xml b/templates/dkcr/Structs/LightParameters.xml index c6bdb697..da90c281 100644 --- a/templates/dkcr/Structs/LightParameters.xml +++ b/templates/dkcr/Structs/LightParameters.xml @@ -4,9 +4,15 @@ 1.0, 1.0, 1.0, 1.0 - + 1 - + + + + + + + true diff --git a/templates/mp1/Structs/LightParameters.xml b/templates/mp1/Structs/LightParameters.xml index d988805c..6bd1db11 100644 --- a/templates/mp1/Structs/LightParameters.xml +++ b/templates/mp1/Structs/LightParameters.xml @@ -8,7 +8,14 @@ - + + + + + + + + diff --git a/templates/mp2/Properties.xml b/templates/mp2/Properties.xml index 62c66fee..42f14f55 100644 --- a/templates/mp2/Properties.xml +++ b/templates/mp2/Properties.xml @@ -3040,7 +3040,7 @@ - + diff --git a/templates/mp2/Structs/LightParameters.xml b/templates/mp2/Structs/LightParameters.xml index ace90e7c..7543cbc2 100644 --- a/templates/mp2/Structs/LightParameters.xml +++ b/templates/mp2/Structs/LightParameters.xml @@ -22,9 +22,15 @@ true - + 1 - + + + + + + + 1 diff --git a/templates/mp2demo/Properties.xml b/templates/mp2demo/Properties.xml index e0373900..7ebc5e36 100644 --- a/templates/mp2demo/Properties.xml +++ b/templates/mp2demo/Properties.xml @@ -2761,7 +2761,7 @@ - + diff --git a/templates/mp2demo/Structs/LightParameters.xml b/templates/mp2demo/Structs/LightParameters.xml index ace90e7c..7543cbc2 100644 --- a/templates/mp2demo/Structs/LightParameters.xml +++ b/templates/mp2demo/Structs/LightParameters.xml @@ -22,9 +22,15 @@ true - + 1 - + + + + + + + 1 diff --git a/templates/mp3/Properties.xml b/templates/mp3/Properties.xml index 013f828b..9a99c110 100644 --- a/templates/mp3/Properties.xml +++ b/templates/mp3/Properties.xml @@ -2302,7 +2302,7 @@ - + diff --git a/templates/mp3/Structs/LightParameters.xml b/templates/mp3/Structs/LightParameters.xml index 2ed010d5..463f21a8 100644 --- a/templates/mp3/Structs/LightParameters.xml +++ b/templates/mp3/Structs/LightParameters.xml @@ -10,9 +10,15 @@ true - + 1 - + + + + + + + true diff --git a/templates/mp3proto/Properties.xml b/templates/mp3proto/Properties.xml index f7af1107..1d46013e 100644 --- a/templates/mp3proto/Properties.xml +++ b/templates/mp3proto/Properties.xml @@ -886,7 +886,7 @@ - + diff --git a/templates/mp3proto/Structs/LightParameters.xml b/templates/mp3proto/Structs/LightParameters.xml index ace90e7c..7543cbc2 100644 --- a/templates/mp3proto/Structs/LightParameters.xml +++ b/templates/mp3proto/Structs/LightParameters.xml @@ -22,9 +22,15 @@ true - + 1 - + + + + + + + 1