diff --git a/DataSpec/DNACommon/TXTR.cpp b/DataSpec/DNACommon/TXTR.cpp index e6d310922..91f33ec95 100644 --- a/DataSpec/DNACommon/TXTR.cpp +++ b/DataSpec/DNACommon/TXTR.cpp @@ -619,7 +619,7 @@ static std::unique_ptr ReadPalette(png_structp png, png_infop info, s for (int i=0 ; iname, "GXPalette")) + if (!strncmp(palette->name, "GX_", 3)) { if (palette->nentries > 16) { diff --git a/Runtime/Collision/CCollisionPrimitive.cpp b/Runtime/Collision/CCollisionPrimitive.cpp index 753184c00..d4cf39814 100644 --- a/Runtime/Collision/CCollisionPrimitive.cpp +++ b/Runtime/Collision/CCollisionPrimitive.cpp @@ -9,6 +9,7 @@ std::unique_ptr> CCollisionPrimitive::sCo std::unique_ptr> CCollisionPrimitive::sTableOfCollidables; std::unique_ptr> CCollisionPrimitive::sTableOfBooleanCollidables; std::unique_ptr> CCollisionPrimitive::sTableOfMovingCollidables; +s32 CCollisionPrimitive::sNumTypes = 0; bool CCollisionPrimitive::sTypesAdded = false; bool CCollisionPrimitive::sTypesAdding = false; bool CCollisionPrimitive::sCollidersAdded = false; @@ -68,13 +69,29 @@ void CCollisionPrimitive::InitAddMovingCollider(const MovingComparisonFunc& cmp, InitAddMovingCollider({std::move(cmp), a, b}); } -void CCollisionPrimitive::InitAddCollider(const CCollisionPrimitive::Comparison& cmp) {} +void CCollisionPrimitive::InitAddCollider(const CCollisionPrimitive::Comparison& cmp) +{ +} void CCollisionPrimitive::InitAddCollider(const ComparisonFunc& cmp, const char* a, const char* b) { InitAddCollider({std::move(cmp), a, b}); } +void CCollisionPrimitive::InitEndColliders() +{ +} + +void CCollisionPrimitive::Unitialize() +{ + sCollidersAdding = false; + sTypesAdding = false; + sCollisionTypeList.reset(); + sTableOfCollidables.reset(); + sTableOfMovingCollidables.reset(); + sTableOfBooleanCollidables.reset(); +} + CCollisionPrimitive::Type::Type(const std::function& setter, const char* info) : x0_setter(setter), x4_info(info) { diff --git a/Runtime/Collision/CCollisionPrimitive.hpp b/Runtime/Collision/CCollisionPrimitive.hpp index 0f3b5b16f..934b7fb8b 100644 --- a/Runtime/Collision/CCollisionPrimitive.hpp +++ b/Runtime/Collision/CCollisionPrimitive.hpp @@ -94,6 +94,7 @@ private: static std::unique_ptr> sTableOfCollidables; static std::unique_ptr> sTableOfBooleanCollidables; static std::unique_ptr> sTableOfMovingCollidables; + static s32 sNumTypes; static bool sTypesAdded; static bool sTypesAdding; static bool sCollidersAdded; @@ -125,6 +126,8 @@ public: static void InitAddCollider(const Comparison& cmp); static void InitAddCollider(const ComparisonFunc&, const char*, const char*); static void InitEndColliders(); + + static void Unitialize(); }; } diff --git a/Runtime/GuiSys/CAuiEnergyBarT01.cpp b/Runtime/GuiSys/CAuiEnergyBarT01.cpp index cc5c60d38..8491e35d1 100644 --- a/Runtime/GuiSys/CAuiEnergyBarT01.cpp +++ b/Runtime/GuiSys/CAuiEnergyBarT01.cpp @@ -12,7 +12,9 @@ CAuiEnergyBarT01* CAuiEnergyBarT01::Create(CGuiFrame* frame, CInputStream& in, b { CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag); u32 a = in.readUint32Big(); - return new CAuiEnergyBarT01(parms, a); + CAuiEnergyBarT01* ret = new CAuiEnergyBarT01(parms, a); + ret->ParseBaseInfo(frame, in, parms); + return ret; } } diff --git a/Runtime/GuiSys/CAuiImagePane.cpp b/Runtime/GuiSys/CAuiImagePane.cpp index e69de29bb..499c9ef28 100644 --- a/Runtime/GuiSys/CAuiImagePane.cpp +++ b/Runtime/GuiSys/CAuiImagePane.cpp @@ -0,0 +1,32 @@ +#include "CAuiImagePane.hpp" + +namespace urde +{ + +CAuiImagePane::CAuiImagePane(const CGuiWidget::CGuiWidgetParms& parms, s32, s32, + const rstl::reserved_vector&, + const rstl::reserved_vector&, bool) +: CGuiWidget(parms) +{ +} + +CGuiWidget* CAuiImagePane::Create(CGuiFrame* frame, CInputStream& in, bool flag) +{ + CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag); + in.readUint32Big(); + in.readUint32Big(); + in.readUint32Big(); + rstl::reserved_vector coords; + u32 coordCount = in.readUint32Big(); + for (u32 i = 0; i < coordCount; ++i) + coords.push_back(in.readVec3fBig()); + rstl::reserved_vector uvs; + u32 uvCount = in.readUint32Big(); + for (u32 i = 0; i < uvCount; ++i) + uvs.push_back(in.readVec2fBig()); + + CAuiImagePane* ret = new CAuiImagePane(parms, -1, -1, coords, uvs, false); + ret->ParseBaseInfo(frame, in, parms); + return ret; +} +} diff --git a/Runtime/GuiSys/CAuiImagePane.hpp b/Runtime/GuiSys/CAuiImagePane.hpp index 5e35a2805..0488e7104 100644 --- a/Runtime/GuiSys/CAuiImagePane.hpp +++ b/Runtime/GuiSys/CAuiImagePane.hpp @@ -8,8 +8,12 @@ namespace urde class CAuiImagePane : public CGuiWidget { -}; +public: + CAuiImagePane(const CGuiWidgetParms&, s32, s32, const rstl::reserved_vector&, + const rstl::reserved_vector&, bool); + static CGuiWidget* Create(CGuiFrame *frame, CInputStream &in, bool); +}; } #endif // __URDE_CAUIIMAGEPANE_HPP__ diff --git a/Runtime/GuiSys/CGuiCamera.cpp b/Runtime/GuiSys/CGuiCamera.cpp index 9f2163db7..d664fa2bf 100644 --- a/Runtime/GuiSys/CGuiCamera.cpp +++ b/Runtime/GuiSys/CGuiCamera.cpp @@ -76,6 +76,7 @@ CGuiCamera* CGuiCamera::Create(CGuiFrame* frame, CInputStream& in, bool flag) break; } frame->SetFrameCamera(ret); + ret->ParseBaseInfo(frame, in, parms); return ret; } diff --git a/Runtime/GuiSys/CGuiFrame.cpp b/Runtime/GuiSys/CGuiFrame.cpp index 0e59528e6..be8cf3882 100644 --- a/Runtime/GuiSys/CGuiFrame.cpp +++ b/Runtime/GuiSys/CGuiFrame.cpp @@ -142,6 +142,7 @@ void CGuiFrame::LoadWidgetsInGame(CInputStream& in) { DataSpec::DNAFourCC type; type.read(in); + printf("%.4s\n", type.toString().c_str()); CGuiWidget* widget = CGuiSys::CreateWidgetInGame(type, in, this); type = widget->GetWidgetTypeID(); switch (type) diff --git a/Runtime/GuiSys/CGuiPane.cpp b/Runtime/GuiSys/CGuiPane.cpp index 8b2f408cc..ea99d0c37 100644 --- a/Runtime/GuiSys/CGuiPane.cpp +++ b/Runtime/GuiSys/CGuiPane.cpp @@ -57,7 +57,9 @@ CGuiPane* CGuiPane::Create(CGuiFrame* frame, CInputStream& in, bool flag) float z = in.readFloatBig(); zeus::CVector3f scaleCenter; scaleCenter.readBig(in); - return new CGuiPane(parms, x, z, scaleCenter); + CGuiPane* pane = new CGuiPane(parms, x, z, scaleCenter); + pane->ParseBaseInfo(frame, in, parms); + return pane; } } diff --git a/Runtime/GuiSys/CGuiTextPane.cpp b/Runtime/GuiSys/CGuiTextPane.cpp index cbf6ed214..6c24f626c 100644 --- a/Runtime/GuiSys/CGuiTextPane.cpp +++ b/Runtime/GuiSys/CGuiTextPane.cpp @@ -117,8 +117,12 @@ CGuiTextPane* CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, bool flag outlineCol.readRGBABig(in); int extentX = in.readFloatBig(); int extentY = in.readFloatBig(); - return new CGuiTextPane(parms, xDim, zDim, vec, fontId, props, + CGuiTextPane* ret = new CGuiTextPane(parms, xDim, zDim, vec, fontId, props, fontCol, outlineCol, extentX, extentY); + ret->ParseBaseInfo(frame, in, parms); + ret->InitializeBuffers(); + ret->TextSupport()->SetText("?\?(?\?)", false); + return ret; } } diff --git a/Runtime/GuiSys/CGuiWidget.cpp b/Runtime/GuiSys/CGuiWidget.cpp index 2c4132e55..303984e19 100644 --- a/Runtime/GuiSys/CGuiWidget.cpp +++ b/Runtime/GuiSys/CGuiWidget.cpp @@ -65,7 +65,7 @@ void CGuiWidget::ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWid ReapplyXform(); zeus::CVector3f rotCenter; rotCenter.readBig(in); - SetRotationCenter(rotCenter); + in.readUint32Big(); in.readUint16Big(); if (a) if (!parent->AddWorkerWidget(this)) diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index 8ae216f64..748fd80a8 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -146,6 +146,8 @@ public: float GetPitch() const; float GetYaw() const; const CModelData* GetModelData() const { return x64_modelData.get(); } + void EnsureRendered(const CStateManager&); + void EnsureRendered(const CStateManager&, const zeus::CVector3f&, const zeus::CVector3f&); }; } diff --git a/Runtime/World/CWorldLight.cpp b/Runtime/World/CWorldLight.cpp index b01d9f796..ccc8ff16e 100644 --- a/Runtime/World/CWorldLight.cpp +++ b/Runtime/World/CWorldLight.cpp @@ -3,45 +3,76 @@ namespace urde { CWorldLight::CWorldLight(CInputStream& in) - : x0_type(ELightType(in.readUint32Big())), - x4_color(zeus::CVector3f::ReadBig(in)), - x10_position(zeus::CVector3f::ReadBig(in)), - x1c_direction(zeus::CVector3f::ReadBig(in)), - x28_q(in.readFloatBig()), - x2c_cutoffAngle(in.readFloatBig()), - x34_castShadows(in.readBool()), - x38_(in.readFloatBig()), - x3c_falloff(EFalloffType(in.readUint32Big())), - x40_(in.readFloatBig()) +: x0_type(EWorldLightType(in.readUint32Big())) +, x4_color(zeus::CVector3f::ReadBig(in)) +, x10_position(zeus::CVector3f::ReadBig(in)) +, x1c_direction(zeus::CVector3f::ReadBig(in)) +, x28_q(in.readFloatBig()) +, x2c_cutoffAngle(in.readFloatBig()) +, x30_(in.readFloatBig()) +, x34_castShadows(in.readBool()) +, x38_(in.readFloatBig()) +, x3c_falloff(EFalloffType(in.readUint32Big())) +, x40_(in.readFloatBig()) { } +std::tuple CalculateLightFalloff(EFalloffType falloff, float q) +{ + float constant = 0.f; + float linear = 0.f; + float quadratic = 0.f; + + if (falloff == EFalloffType::Constant) + constant = 2.f / q; + else if (falloff == EFalloffType::Linear) + linear = 250.f / q; + else if (falloff == EFalloffType::Quadratic) + quadratic = 25000.f / q; + + return {constant, linear, quadratic}; +} + CLight CWorldLight::GetAsCGraphicsLight() const { - const float epsilon = 1.1920929e-7; - zeus::CVector3f tmpColor = x4_color; - zeus::CColor color(x4_color.x, x4_color.y, x4_color.z); - float tmp = x28_q; - if (epsilon < tmp) - tmp = 0.000001f; -/* - if (x0_type == ELightType::Spot) + zeus::CVector3f float_color = x4_color; + zeus::CColor tmpColor; + float q = x28_q; + if (q < FLT_EPSILON) + q = 0.000001f; + + if (x0_type == EWorldLightType::LocalAmbient) { - float f2 = tmpColor.x; - float f0 = tmpColor.y; - float f1 = tmpColor.z; - float f3 = f2 * tmp; - f2 = f0 * tmp; - f0 = 1.0f; - f1 *= tmp; - tmpColor.x = f3; - tmpColor.y = f2; - tmpColor.z = f1; + float_color *= q; + if (float_color.x >= 1.f) + float_color.x = 1.f; - if (f3 >= f0) + if (float_color.y >= 1.f) + float_color.y = 1.f; + + if (float_color.z >= 1.f) + float_color.z = 1.f; + + return CLight::BuildLocalAmbient(x10_position, zeus::CColor(float_color.x, float_color.y, float_color.z, 1.f)); } -*/ - return CLight::BuildPoint({}, {}); -} + else if (x0_type == EWorldLightType::Directional) + { + return CLight::BuildDirectional(x1c_direction, tmpColor); + } + else if (x0_type == EWorldLightType::Spot) + { + CLight light = CLight::BuildSpot(x10_position, x1c_direction.normalized(), tmpColor, x2c_cutoffAngle * .5f); + float c, l, q; + std::tie(c, l, q) = CalculateLightFalloff(x3c_falloff, x28_q); + + light.SetAttenuation(c, l, q); + return light; + } + float distC, distL, distQ; + std::tie(distC, distL, distQ) = CalculateLightFalloff(x3c_falloff, x28_q); + return CLight::BuildCustom(x10_position, zeus::CVector3f{0.f, 1.f, 0.f}, + zeus::CColor{x4_color.x, x4_color.y, x4_color.z, 1.f}, distC, distL, distQ, 1.f, 0.f, + 0.f); +} } diff --git a/Runtime/World/CWorldLight.hpp b/Runtime/World/CWorldLight.hpp index f01a4cc9d..061dc0513 100644 --- a/Runtime/World/CWorldLight.hpp +++ b/Runtime/World/CWorldLight.hpp @@ -7,7 +7,19 @@ namespace urde { class CWorldLight { - ELightType x0_type = ELightType::Custom; +public: + enum class EWorldLightType + { + LocalAmbient, + Directional, + Custom, + Spot, + Spot2, + LocalAmbient2, + }; + +private: + EWorldLightType x0_type = EWorldLightType::Spot2; zeus::CVector3f x4_color; zeus::CVector3f x10_position; zeus::CVector3f x1c_direction;