From 362fb6b00d38d6011db07db1403645650bf70a70 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 20 Jan 2017 22:03:37 -0800 Subject: [PATCH 1/7] Implement CParticleGenInfoGeneric --- DataSpec/DNACommon/CMakeLists.txt | 4 +- DataSpec/DNACommon/Tweaks/ITweak.hpp | 13 ++ DataSpec/DNACommon/Tweaks/ITweakGame.hpp | 4 +- DataSpec/DNACommon/Tweaks/ITweakGui.hpp | 4 +- DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp | 4 +- DataSpec/DNACommon/Tweaks/ITweakParticle.hpp | 4 +- DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp | 4 +- .../DNACommon/Tweaks/ITweakPlayerControl.hpp | 4 +- DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp | 4 +- DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp | 4 +- DataSpec/DNACommon/Tweaks/ITweakSlideShow.hpp | 4 +- DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp | 12 ++ DataSpec/DNAMP1/CMakeLists.txt | 6 +- DataSpec/DNAMP1/Tweaks/CTweakTargeting.cpp | 0 DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp | 16 ++ Runtime/Character/CParticleGenInfo.cpp | 158 +++++++++++------- Runtime/Character/CParticleGenInfo.hpp | 77 +++++---- Runtime/Graphics/CBooRenderer.cpp | 8 +- Runtime/MP1/MP1.hpp | 4 +- Runtime/Particle/CElementGen.cpp | 30 ++-- Runtime/Particle/CElementGen.hpp | 2 +- Runtime/Particle/CParticleElectric.cpp | 4 +- Runtime/Particle/CParticleElectric.hpp | 2 +- Runtime/Particle/CParticleGen.hpp | 2 +- Runtime/Particle/CParticleSwoosh.cpp | 4 +- Runtime/Particle/CParticleSwoosh.hpp | 2 +- Runtime/World/CActor.cpp | 8 + Runtime/World/CActor.hpp | 1 + Runtime/World/CGameLight.cpp | 18 +- Runtime/World/CGameLight.hpp | 3 +- Runtime/World/CWorldLight.cpp | 2 +- specter | 2 +- 32 files changed, 268 insertions(+), 146 deletions(-) create mode 100644 DataSpec/DNACommon/Tweaks/ITweak.hpp create mode 100644 DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp create mode 100644 DataSpec/DNAMP1/Tweaks/CTweakTargeting.cpp create mode 100644 DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp diff --git a/DataSpec/DNACommon/CMakeLists.txt b/DataSpec/DNACommon/CMakeLists.txt index bf24e777a..731a76125 100644 --- a/DataSpec/DNACommon/CMakeLists.txt +++ b/DataSpec/DNACommon/CMakeLists.txt @@ -31,6 +31,7 @@ set(DNACOMMON_SOURCES BabeDead.hpp BabeDead.cpp RigInverter.hpp RigInverter.cpp AROTBuilder.hpp AROTBuilder.cpp + Tweaks/ITweak.hpp Tweaks/TweakWriter.hpp Tweaks/ITweakGame.hpp Tweaks/ITweakParticle.hpp @@ -40,7 +41,8 @@ set(DNACOMMON_SOURCES Tweaks/ITweakGunRes.hpp Tweaks/ITweakPlayerRes.hpp Tweaks/ITweakGui.hpp - Tweaks/ITweakSlideShow.hpp) + Tweaks/ITweakSlideShow.hpp + Tweaks/ITweakTargeting.hpp) dataspec_add_list(DNACommon DNACOMMON_SOURCES) list(APPEND DNACOMMON_SOURCES ${liblist}) diff --git a/DataSpec/DNACommon/Tweaks/ITweak.hpp b/DataSpec/DNACommon/Tweaks/ITweak.hpp new file mode 100644 index 000000000..80549caa0 --- /dev/null +++ b/DataSpec/DNACommon/Tweaks/ITweak.hpp @@ -0,0 +1,13 @@ +#ifndef __DNACOMMON_ITWEAK_HPP__ +#define __DNACOMMON_ITWEAK_HPP__ + +#include "../DNACommon.hpp" + +namespace DataSpec +{ +struct ITweak : BigYAML +{ +}; +} + +#endif // __DNACOMMON_ITWEAK_HPP__ diff --git a/DataSpec/DNACommon/Tweaks/ITweakGame.hpp b/DataSpec/DNACommon/Tweaks/ITweakGame.hpp index b07636b6c..8f6dc8b80 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGame.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGame.hpp @@ -1,12 +1,12 @@ #ifndef __DNACOMMON_ITWEAKGAME_HPP__ #define __DNACOMMON_ITWEAKGAME_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" namespace DataSpec { -struct ITweakGame : BigYAML +struct ITweakGame : ITweak { virtual const std::string& GetWorldPrefix() const = 0; virtual bool GetSplashScreensDisabled() const = 0; diff --git a/DataSpec/DNACommon/Tweaks/ITweakGui.hpp b/DataSpec/DNACommon/Tweaks/ITweakGui.hpp index d11ad5a27..d0293e59a 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGui.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGui.hpp @@ -1,13 +1,13 @@ #ifndef __DNACOMMON_ITWEAKGUI_HPP__ #define __DNACOMMON_ITWEAKGUI_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" #include "zeus/CVector2f.hpp" namespace DataSpec { -struct ITweakGui : BigYAML +struct ITweakGui : ITweak { virtual float GetScanSpeed(int idx) const=0; virtual float GetXrayBlurScaleLinear() const=0; diff --git a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp index d1ef1093d..3fe91543f 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp @@ -1,13 +1,13 @@ #ifndef __DNACOMMON_ITWEAKGUNRES_HPP__ #define __DNACOMMON_ITWEAKGUNRES_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" #include "Runtime/IFactory.hpp" namespace DataSpec { -struct ITweakGunRes : BigYAML +struct ITweakGunRes : ITweak { using ResId = int64_t; enum class EBeamId diff --git a/DataSpec/DNACommon/Tweaks/ITweakParticle.hpp b/DataSpec/DNACommon/Tweaks/ITweakParticle.hpp index 027ec8d48..d5f038768 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakParticle.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakParticle.hpp @@ -1,12 +1,12 @@ #ifndef __DNACOMMON_ITWEAKPARTICLE_HPP__ #define __DNACOMMON_ITWEAKPARTICLE_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" namespace DataSpec { -struct ITweakParticle : BigYAML +struct ITweakParticle : ITweak { }; diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp index 01a86b016..ca825c353 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp @@ -1,13 +1,13 @@ #ifndef __DNACOMMON_ITWEAKPLAYER_HPP__ #define __DNACOMMON_ITWEAKPLAYER_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" #include "zeus/CAABox.hpp" namespace DataSpec { -struct ITweakPlayer : BigYAML +struct ITweakPlayer : ITweak { virtual float GetX50() const=0; virtual float GetX54() const=0; diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp index c25f1faec..d8634cb6f 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp @@ -1,12 +1,12 @@ #ifndef __DNACOMMON_ITWEAKPLAYERCONTROL_HPP__ #define __DNACOMMON_ITWEAKPLAYERCONTROL_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" namespace DataSpec { -struct ITweakPlayerControl : BigYAML +struct ITweakPlayerControl : ITweak { virtual atUint32 GetMapping(atUint32) const=0; }; diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp index 4a4daa40c..939c37f42 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp @@ -1,13 +1,13 @@ #ifndef __DNACOMMON_ITWEAKPLAYERGUN_HPP__ #define __DNACOMMON_ITWEAKPLAYERGUN_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" #include "zeus/CAABox.hpp" namespace DataSpec { -struct ITweakPlayerGun : BigYAML +struct ITweakPlayerGun : ITweak { virtual float GetSomething1() const=0; // x24 virtual float GetSomething2() const=0; // x28 diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp index 6899ddb07..2719e3ea8 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp @@ -1,13 +1,13 @@ #ifndef __DNACOMMON_ITWEAKPLAYERRES_HPP__ #define __DNACOMMON_ITWEAKPLAYERRES_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" #include "Runtime/IFactory.hpp" namespace DataSpec { -struct ITweakPlayerRes : BigYAML +struct ITweakPlayerRes : ITweak { using ResId = int64_t; enum class EBeamId diff --git a/DataSpec/DNACommon/Tweaks/ITweakSlideShow.hpp b/DataSpec/DNACommon/Tweaks/ITweakSlideShow.hpp index ceed62f3c..b90e9bf72 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakSlideShow.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakSlideShow.hpp @@ -1,12 +1,12 @@ #ifndef __DNACOMMON_ITWEAKSLIDESHOW_HPP__ #define __DNACOMMON_ITWEAKSLIDESHOW_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" namespace DataSpec { -struct ITweakSlideShow : BigYAML +struct ITweakSlideShow : ITweak { virtual const std::string& GetFont() const=0; virtual const zeus::CColor& GetFontColor() const=0; diff --git a/DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp b/DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp new file mode 100644 index 000000000..392959ce6 --- /dev/null +++ b/DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp @@ -0,0 +1,12 @@ +#ifndef __DNACOMMON_ITWEAKTARGETING_HPP__ +#define __DNACOMMON_ITWEAKTARGETING_HPP__ + +#include "ITweak.hpp" +namespace DataSpec +{ +struct ITweakTargeting : public ITweak +{ +}; +} + +#endif // __DNACOMMON_ITWEAKTARGETING_HPP__ diff --git a/DataSpec/DNAMP1/CMakeLists.txt b/DataSpec/DNAMP1/CMakeLists.txt index f926da02b..631e93233 100644 --- a/DataSpec/DNAMP1/CMakeLists.txt +++ b/DataSpec/DNAMP1/CMakeLists.txt @@ -28,7 +28,8 @@ make_dnalist(liblist DNAMP1 Tweaks/CTweakPlayerRes Tweaks/CTweakGui Tweaks/CTweakSlideShow - Tweaks/CTweakCameraBob) + Tweaks/CTweakCameraBob + Tweaks/CTweakTargeting) set(DNAMP1_SOURCES DNAMP1.hpp DNAMP1.cpp @@ -48,7 +49,8 @@ set(DNAMP1_SOURCES SCLY.hpp SCLY.cpp FRME.cpp DeafBabe.cpp - Tweaks/CTweakPlayer.cpp) + Tweaks/CTweakPlayer.cpp + Tweaks/CTweakTargeting.cpp) dataspec_add_list(DNAMP1 DNAMP1_SOURCES) list(APPEND DNAMP1_SOURCES ${liblist}) diff --git a/DataSpec/DNAMP1/Tweaks/CTweakTargeting.cpp b/DataSpec/DNAMP1/Tweaks/CTweakTargeting.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp b/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp new file mode 100644 index 000000000..b79e87f6e --- /dev/null +++ b/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp @@ -0,0 +1,16 @@ +#ifndef _DNAMP1_CTWEAKTARGETING_HPP_ +#define _DNAMP1_CTWEAKTARGETING_HPP_ + +#include "../../DNACommon/Tweaks/ITweakTargeting.hpp" + +namespace DataSpec +{ +namespace DNAMP1 +{ +struct CTweakTargeting : public ITweakTargeting +{ + DECL_YAML +}; +} +} +#endif // _DNAMP1_CTWEAKTARGETING_HPP_ diff --git a/Runtime/Character/CParticleGenInfo.cpp b/Runtime/Character/CParticleGenInfo.cpp index 71e0169ea..580747ceb 100644 --- a/Runtime/Character/CParticleGenInfo.cpp +++ b/Runtime/Character/CParticleGenInfo.cpp @@ -1,108 +1,148 @@ #include "CParticleGenInfo.hpp" +#include "Graphics/IRenderer.hpp" #include "Particle/CParticleGen.hpp" +#include "GameGlobalObjects.hpp" +#include "World/CGameLight.hpp" +#include "CStateManager.hpp" +#include "Graphics/CBooRenderer.hpp" +#include "TCastTo.hpp" namespace urde { CParticleGenInfo::CParticleGenInfo(const SObjectTag& part, int frameCount, const std::string& boneName, - const zeus::CVector3f& scale, CParticleData::EParentedMode parentMode, - int a) -: x4_part(part), xc_seconds(frameCount / 60.f), x10_boneName(boneName), x28_parentMode(parentMode), - x2c_a(a), x30_particleScale(scale) -{} - -static TUniqueId _initializeLight(const std::weak_ptr& system, - CStateManager& stateMgr, int lightId) + const zeus::CVector3f& scale, CParticleData::EParentedMode parentMode, int a, int b) +: x4_part(part) +, xc_seconds(frameCount / 60.f) +, x10_boneName(boneName) +, x28_parentMode(parentMode) +, x2c_a(a) +, x30_particleScale(scale) +, x80_(b) { +} + +static TUniqueId _initializeLight(const std::weak_ptr& system, CStateManager& stateMgr, TAreaId areaId, + int lightId) +{ + TUniqueId ret = kInvalidUniqueId; std::shared_ptr systemRef = system.lock(); if (systemRef->SystemHasLight()) { - + ret = stateMgr.AllocateUniqueId(); + stateMgr.AddObject( + new CGameLight(ret, areaId, false, "ParticleLight", + zeus::CTransform(systemRef->GetOrientation().buildMatrix3f(), systemRef->GetTranslation()), + kInvalidUniqueId, systemRef->GetLight(), lightId, 0, 0.f)); } - return kInvalidUniqueId; + return ret; } -CParticleGenInfoGeneric::CParticleGenInfoGeneric(const SObjectTag& part, - const std::weak_ptr& system, +CParticleGenInfoGeneric::CParticleGenInfoGeneric(const SObjectTag& part, const std::weak_ptr& system, int frameCount, const std::string& boneName, - const zeus::CVector3f& scale, - CParticleData::EParentedMode parentMode, - int a, CStateManager& stateMgr, int lightId) -: CParticleGenInfo(part, frameCount, boneName, scale, parentMode, a), x80_system(system) + const zeus::CVector3f& scale, CParticleData::EParentedMode parentMode, + int a, CStateManager& stateMgr, TAreaId areaId, int lightId, int b) +: CParticleGenInfo(part, frameCount, boneName, scale, parentMode, a, b), x84_system(system) { if (lightId == -1) - x84_lightId = kInvalidUniqueId; + x88_lightId = kInvalidUniqueId; else - x84_lightId = _initializeLight(system, stateMgr, lightId); + x88_lightId = _initializeLight(system, stateMgr, lightId, areaId); } -void CParticleGenInfoGeneric::AddToRenderer() -{ -} +void CParticleGenInfoGeneric::AddToRenderer() { g_Renderer->AddParticleGen(*x84_system.get()); } -void CParticleGenInfoGeneric::Render() -{ -} +void CParticleGenInfoGeneric::Render() { x84_system->Render(); } void CParticleGenInfoGeneric::Update(float dt, CStateManager& stateMgr) { + x84_system->Update(dt); + + if (x88_lightId != kInvalidUniqueId) + { + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + if (gl) + gl->SetLight(x84_system->GetLight()); + } } void CParticleGenInfoGeneric::SetOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) { + x84_system->SetOrientation(xf); + + if (x88_lightId != kInvalidUniqueId) + { + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + if (gl) + gl->SetRotation(zeus::CQuaternion(xf.buildMatrix3f())); + } } void CParticleGenInfoGeneric::SetTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) { + x84_system->SetTranslation(trans); + + if (x88_lightId != kInvalidUniqueId) + { + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + if (gl) + gl->SetTranslation(trans); + } } void CParticleGenInfoGeneric::SetGlobalOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) { + x84_system->SetGlobalOrientation(xf); + + if (x88_lightId != kInvalidUniqueId) + { + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + if (gl) + gl->SetRotation(zeus::CQuaternion(xf.buildMatrix3f())); + } } void CParticleGenInfoGeneric::SetGlobalTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) { + x84_system->SetGlobalTranslation(trans); + + if (x88_lightId != kInvalidUniqueId) + { + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + if (gl) + gl->SetTranslation(trans); + } } -void CParticleGenInfoGeneric::SetGlobalScale(const zeus::CVector3f& scale) +void CParticleGenInfoGeneric::SetGlobalScale(const zeus::CVector3f& scale) { x84_system->SetGlobalScale(scale); } + +void CParticleGenInfoGeneric::SetParticleEmission(bool emission, CStateManager& stateMgr) { + x84_system->SetParticleEmission(emission); + + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + + if (gl) + gl->SetActive(emission); } -void CParticleGenInfoGeneric::SetParticleEmission(bool, CStateManager& stateMgr) -{ -} - -bool CParticleGenInfoGeneric::IsSystemDeletable() const -{ - return false; -} - -zeus::CAABox CParticleGenInfoGeneric::GetBounds() const -{ - return {}; -} - -bool CParticleGenInfoGeneric::HasActiveParticles() const -{ - return false; -} - -void CParticleGenInfoGeneric::DestroyParticles() -{ -} - -bool CParticleGenInfoGeneric::HasLight() const -{ - return false; -} - -TUniqueId CParticleGenInfoGeneric::GetLightId() const -{ - return kInvalidUniqueId; -} - -void CParticleGenInfoGeneric::SetModulationColor(const zeus::CColor& color) +bool CParticleGenInfoGeneric::IsSystemDeletable() const { return x84_system->IsSystemDeletable(); } + +rstl::optional_object CParticleGenInfoGeneric::GetBounds() const { return x84_system->GetBounds(); } + +bool CParticleGenInfoGeneric::HasActiveParticles() const { return x84_system->GetParticleCount() != 0; } + +void CParticleGenInfoGeneric::DestroyParticles() { x84_system->DestroyParticles(); } + +bool CParticleGenInfoGeneric::HasLight() const { return x84_system->SystemHasLight(); } + +TUniqueId CParticleGenInfoGeneric::GetLightId() const { return x88_lightId; } + +void CParticleGenInfoGeneric::DeleteLight(CStateManager& mgr) { + if (x88_lightId != kInvalidUniqueId) + mgr.DeleteObjectRequest(x88_lightId); } +void CParticleGenInfoGeneric::SetModulationColor(const zeus::CColor& color) { x84_system->SetModulationColor(color); } } diff --git a/Runtime/Character/CParticleGenInfo.hpp b/Runtime/Character/CParticleGenInfo.hpp index 4616a7f1c..deaba6e25 100644 --- a/Runtime/Character/CParticleGenInfo.hpp +++ b/Runtime/Character/CParticleGenInfo.hpp @@ -24,40 +24,61 @@ class CParticleGenInfo zeus::CVector3f x30_particleScale; float x3c_ = 0.f; bool x40_ = false; - zeus::CTransform x44_; - zeus::CVector3f x74_; + zeus::CTransform x44_transform; + zeus::CVector3f x74_offset; + s32 x80_; + public: - CParticleGenInfo(const SObjectTag& part, int frameCount, const std::string& boneName, - const zeus::CVector3f&, CParticleData::EParentedMode parentMode, int a); + CParticleGenInfo(const SObjectTag& part, int frameCount, const std::string& boneName, const zeus::CVector3f&, + CParticleData::EParentedMode parentMode, int a, int b); virtual ~CParticleGenInfo() = default; - virtual void AddToRenderer()=0; - virtual void Render()=0; - virtual void Update(float dt, CStateManager& stateMgr)=0; - virtual void SetOrientation(const zeus::CTransform& xf, CStateManager& stateMgr)=0; - virtual void SetTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr)=0; - virtual void SetGlobalOrientation(const zeus::CTransform& xf, CStateManager& stateMgr)=0; - virtual void SetGlobalTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr)=0; - virtual void SetGlobalScale(const zeus::CVector3f& scale)=0; - virtual void SetParticleEmission(bool, CStateManager& stateMgr)=0; - virtual bool IsSystemDeletable() const=0; - virtual zeus::CAABox GetBounds() const=0; - virtual bool HasActiveParticles() const=0; - virtual void DestroyParticles()=0; - virtual bool HasLight() const=0; - virtual TUniqueId GetLightId() const=0; - virtual void SetModulationColor(const zeus::CColor& color)=0; + virtual void AddToRenderer() = 0; + virtual void Render() = 0; + virtual void Update(float dt, CStateManager& stateMgr) = 0; + virtual void SetOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) = 0; + virtual void SetTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) = 0; + virtual void SetGlobalOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) = 0; + virtual void SetGlobalTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) = 0; + virtual void SetGlobalScale(const zeus::CVector3f& scale) = 0; + virtual void SetParticleEmission(bool, CStateManager& stateMgr) = 0; + virtual bool IsSystemDeletable() const = 0; + virtual rstl::optional_object GetBounds() const = 0; + virtual bool HasActiveParticles() const = 0; + virtual void DestroyParticles() = 0; + virtual bool HasLight() const = 0; + virtual TUniqueId GetLightId() const = 0; + virtual void DeleteLight(CStateManager&) const = 0; + virtual void SetModulationColor(const zeus::CColor& color) = 0; + + void SetFlags(s32); + s32 GetFlags() const; + void SetIsGrabInitialData(bool); + bool GetIsGrabInitialData() const; + bool GetIsActive() const; + bool SetIsActive(bool); + void OffsetTime(float); + void SetCurOffset(const zeus::CVector3f& offset) { x74_offset = offset; } + void SetCurTransform(const zeus::CTransform& xf) { x44_transform = xf; } + void SetInactiveStartTime(float); + float GetInactiveStartTime() const; + float GetFinishTime() const; + float GetCurrentTime() const; + + CParticleData::EParentedMode GetParentedMode() const { return x28_parentMode; } + const std::string& GetLocatorName() const { return x10_boneName; } }; class CParticleGenInfoGeneric : public CParticleGenInfo { - std::shared_ptr x80_system; - TUniqueId x84_lightId; + std::shared_ptr x84_system; + TUniqueId x88_lightId; + public: - CParticleGenInfoGeneric(const SObjectTag& part, const std::weak_ptr& system, - int, const std::string& boneName, const zeus::CVector3f& scale, - CParticleData::EParentedMode parentMode, int a, CStateManager& stateMgr, - int lightId); + CParticleGenInfoGeneric(const SObjectTag& part, const std::weak_ptr& system, int, + const std::string& boneName, const zeus::CVector3f& scale, + CParticleData::EParentedMode parentMode, int a, CStateManager& stateMgr, TAreaId, + int lightId, int b); void AddToRenderer(); void Render(); @@ -69,14 +90,14 @@ public: void SetGlobalScale(const zeus::CVector3f& scale); void SetParticleEmission(bool, CStateManager& stateMgr); bool IsSystemDeletable() const; - zeus::CAABox GetBounds() const; + rstl::optional_object GetBounds() const; bool HasActiveParticles() const; void DestroyParticles(); bool HasLight() const; TUniqueId GetLightId() const; + void DeleteLight(CStateManager&); void SetModulationColor(const zeus::CColor& color); }; - } #endif // __URDE_CPARTICLEGENINFO_HPP__ diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index 9178f795b..6be14092b 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -483,11 +483,11 @@ void CBooRenderer::PostRenderFogs() void CBooRenderer::AddParticleGen(const CParticleGen& gen) { - std::pair bounds = gen.GetBounds(); - if (bounds.second) + auto bounds = gen.GetBounds(); + if (bounds) { - zeus::CVector3f pt = bounds.first.closestPointAlongVector(xb0_viewPlane.vec); - Buckets::Insert(pt, bounds.first, EDrawableType::Particle, &gen, xb0_viewPlane, 0); + zeus::CVector3f pt = bounds.value().closestPointAlongVector(xb0_viewPlane.vec); + Buckets::Insert(pt, bounds.value(), EDrawableType::Particle, &gen, xb0_viewPlane, 0); } } diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index 6a25c319c..1a0e2f5da 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -58,14 +58,14 @@ class CGameGlobalObjects std::unique_ptr x134_gameState; TLockedToken x13c_mainStringTable; CInGameTweakManager x150_tweakManager; - std::unique_ptr m_renderer; + std::unique_ptr m_renderer; void LoadStringTable() { x13c_mainStringTable = g_SimplePool->GetObj("STRG_Main"); g_MainStringTable = x13c_mainStringTable.GetObj(); } - static CBooRenderer* + static IRenderer* AllocateRenderer(IObjectStore& store, IFactory& resFactory) { g_Renderer = new CBooRenderer(store, resFactory); diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index fd504d7dd..96799ba04 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -1152,41 +1152,41 @@ void CElementGen::BuildParticleSystemBounds() for (std::unique_ptr& ch : x234_activePartChildren) { - std::pair chBounds = ch->GetBounds(); - if (chBounds.second) + auto chBounds = ch->GetBounds(); + if (chBounds) { accumulated = true; - aabb.accumulateBounds(chBounds.first); + aabb.accumulateBounds(chBounds.value()); } } for (std::unique_ptr& ch : x248_finishPartChildren) { - std::pair chBounds = ch->GetBounds(); - if (chBounds.second) + auto chBounds = ch->GetBounds(); + if (chBounds) { accumulated = true; - aabb.accumulateBounds(chBounds.first); + aabb.accumulateBounds(chBounds.value()); } } for (std::unique_ptr& ch : x260_swhcChildren) { - std::pair chBounds = ch->GetBounds(); - if (chBounds.second) + auto chBounds = ch->GetBounds(); + if (chBounds) { accumulated = true; - aabb.accumulateBounds(chBounds.first); + aabb.accumulateBounds(chBounds.value()); } } for (std::unique_ptr& ch : x280_elscChildren) { - std::pair chBounds = ch->GetBounds(); - if (chBounds.second) + auto chBounds = ch->GetBounds(); + if (chBounds) { accumulated = true; - aabb.accumulateBounds(chBounds.first); + aabb.accumulateBounds(chBounds.value()); } } @@ -2245,12 +2245,12 @@ bool CElementGen::IsSystemDeletable() const return false; } -std::pair CElementGen::GetBounds() const +rstl::optional_object CElementGen::GetBounds() const { if (GetParticleCountAll() == 0) - return {zeus::CAABox(), false}; + return {zeus::CAABox()}; else - return {x2c4_systemBounds, true}; + return {x2c4_systemBounds}; } u32 CElementGen::GetParticleCount() const diff --git a/Runtime/Particle/CElementGen.hpp b/Runtime/Particle/CElementGen.hpp index c001ff83d..20caf3b18 100644 --- a/Runtime/Particle/CElementGen.hpp +++ b/Runtime/Particle/CElementGen.hpp @@ -232,7 +232,7 @@ public: const zeus::CVector3f& GetGlobalScale() const; const zeus::CColor& GetModulationColor() const; bool IsSystemDeletable() const; - std::pair GetBounds() const; + rstl::optional_object GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/Particle/CParticleElectric.cpp b/Runtime/Particle/CParticleElectric.cpp index cf343d1da..ee7084846 100644 --- a/Runtime/Particle/CParticleElectric.cpp +++ b/Runtime/Particle/CParticleElectric.cpp @@ -185,9 +185,9 @@ bool CParticleElectric::IsSystemDeletable() const return false; } -std::pair CParticleElectric::GetBounds() const +rstl::optional_object CParticleElectric::GetBounds() const { - return std::make_pair(zeus::CAABox(), false); + return {}; } u32 CParticleElectric::GetParticleCount() const diff --git a/Runtime/Particle/CParticleElectric.hpp b/Runtime/Particle/CParticleElectric.hpp index 080c4da67..d0de50d42 100644 --- a/Runtime/Particle/CParticleElectric.hpp +++ b/Runtime/Particle/CParticleElectric.hpp @@ -97,7 +97,7 @@ public: const zeus::CVector3f& GetGlobalScale() const; const zeus::CColor& GetModulationColor() const; bool IsSystemDeletable() const; - std::pair GetBounds() const; + rstl::optional_object GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/Particle/CParticleGen.hpp b/Runtime/Particle/CParticleGen.hpp index a3294b863..eaf4aa05e 100644 --- a/Runtime/Particle/CParticleGen.hpp +++ b/Runtime/Particle/CParticleGen.hpp @@ -36,7 +36,7 @@ public: virtual const zeus::CVector3f& GetGlobalScale() const=0; virtual const zeus::CColor& GetModulationColor() const=0; virtual bool IsSystemDeletable() const=0; - virtual std::pair GetBounds() const=0; + virtual rstl::optional_object GetBounds() const=0; virtual u32 GetParticleCount() const=0; virtual bool SystemHasLight() const=0; virtual CLight GetLight() const=0; diff --git a/Runtime/Particle/CParticleSwoosh.cpp b/Runtime/Particle/CParticleSwoosh.cpp index 7d21d48d3..21280dd15 100644 --- a/Runtime/Particle/CParticleSwoosh.cpp +++ b/Runtime/Particle/CParticleSwoosh.cpp @@ -88,9 +88,9 @@ bool CParticleSwoosh::IsSystemDeletable() const return false; } -std::pair CParticleSwoosh::GetBounds() const +rstl::optional_object CParticleSwoosh::GetBounds() const { - return std::make_pair(zeus::CAABox(), false); + return {}; } u32 CParticleSwoosh::GetParticleCount() const diff --git a/Runtime/Particle/CParticleSwoosh.hpp b/Runtime/Particle/CParticleSwoosh.hpp index d1f7e0b2b..c7a4cfa6b 100644 --- a/Runtime/Particle/CParticleSwoosh.hpp +++ b/Runtime/Particle/CParticleSwoosh.hpp @@ -30,7 +30,7 @@ public: const zeus::CVector3f& GetGlobalScale() const; const zeus::CColor& GetModulationColor() const; bool IsSystemDeletable() const; - std::pair GetBounds() const; + rstl::optional_object GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index b85d935ba..a0ca702e0 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -253,6 +253,14 @@ void CActor::SetSfxPitchBend(s32 val) CSfxManager::PitchBend(*x8c_sfxHandle.get(), val); } +void CActor::SetRotation(const zeus::CQuaternion &q) +{ + x34_transform = q.toTransform(x34_transform.origin); + xe4_27_ = true; + xe4_28_ = true; + xe4_29_ = true; +} + void CActor::SetTranslation(const zeus::CVector3f& tr) { x34_transform.origin = tr; diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index a79157c4f..8ae216f64 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -140,6 +140,7 @@ public: bool HasModelData() const; const CSfxHandle* GetSfxHandle() const; void SetSfxPitchBend(s32); + void SetRotation(const zeus::CQuaternion& q); void SetTranslation(const zeus::CVector3f& tr); void SetAddedToken(u32 tok); float GetPitch() const; diff --git a/Runtime/World/CGameLight.cpp b/Runtime/World/CGameLight.cpp index 217714ec8..9dc294be0 100644 --- a/Runtime/World/CGameLight.cpp +++ b/Runtime/World/CGameLight.cpp @@ -1,6 +1,7 @@ -#include "CGameLight.hpp" -#include "CActorParameters.hpp" +#include "World/CGameLight.hpp" +#include "World/CActorParameters.hpp" #include "CStateManager.hpp" +#include "TCastTo.hpp" namespace urde { @@ -9,20 +10,25 @@ CGameLight::CGameLight(TUniqueId uid, TAreaId aid, bool active, const std::strin TUniqueId parentId, const CLight& light, u32 w1, u32 w2, float f1) : CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId), - xe8_parentId(parentId), xec_light(light), x13c_(w1), x140_(w2), x144_(f1) + xe8_parentId(parentId), xec_light(light), x13c_(w1), x140_(w2), x144_lifeTime(f1) { xec_light.GetRadius(); xec_light.GetIntensity(); SetLightPriorityAndId(); } +void CGameLight::Accept(IVisitor &visitor) +{ + visitor.Visit(this); +} + void CGameLight::Think(float dt, CStateManager& mgr) { - if (x144_ <= 0.f) + if (x144_lifeTime <= 0.f) return; - x144_ -= dt; + x144_lifeTime -= dt; - if (x144_ <= 0.f) + if (x144_lifeTime <= 0.f) mgr.RemoveActor(GetUniqueId()); } diff --git a/Runtime/World/CGameLight.hpp b/Runtime/World/CGameLight.hpp index 3b1ed8c8c..a79aafe10 100644 --- a/Runtime/World/CGameLight.hpp +++ b/Runtime/World/CGameLight.hpp @@ -11,12 +11,13 @@ class CGameLight : public CActor CLight xec_light; u32 x13c_; u32 x140_; - float x144_; + float x144_lifeTime; public: CGameLight(TUniqueId, TAreaId, bool, const std::string&, const zeus::CTransform&, TUniqueId, const CLight&, u32, u32, float); + void Accept(IVisitor &visitor); void Think(float, CStateManager&); void SetLightPriorityAndId(); void SetLight(const CLight&); diff --git a/Runtime/World/CWorldLight.cpp b/Runtime/World/CWorldLight.cpp index 18efb7b83..b01d9f796 100644 --- a/Runtime/World/CWorldLight.cpp +++ b/Runtime/World/CWorldLight.cpp @@ -23,7 +23,7 @@ CLight CWorldLight::GetAsCGraphicsLight() const zeus::CColor color(x4_color.x, x4_color.y, x4_color.z); float tmp = x28_q; if (epsilon < tmp) - tmp = 0.0000011920929f; + tmp = 0.000001f; /* if (x0_type == ELightType::Spot) { diff --git a/specter b/specter index 03e7124c5..a47613503 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 03e7124c5f576033c10ad2d0a116e4a331c0381d +Subproject commit a4761350329459605dfb98d7eb27d453e6da2d29 From a1911e8262c9fc974edf8956638a856aabd4d649 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 20 Jan 2017 22:21:33 -0800 Subject: [PATCH 2/7] Update Specter --- specter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specter b/specter index a47613503..e9db96fa0 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit a4761350329459605dfb98d7eb27d453e6da2d29 +Subproject commit e9db96fa08cf9ca3f1dc6dfaea6c2c4e952627a0 From 4a7a3bea2fe29015c104b0ab07f5156974f9468c Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 21 Jan 2017 07:46:51 -0800 Subject: [PATCH 3/7] FRME Fixes --- DataSpec/DNACommon/TXTR.cpp | 2 +- Runtime/Collision/CCollisionPrimitive.cpp | 19 ++++- Runtime/Collision/CCollisionPrimitive.hpp | 3 + Runtime/GuiSys/CAuiEnergyBarT01.cpp | 4 +- Runtime/GuiSys/CAuiImagePane.cpp | 32 ++++++++ Runtime/GuiSys/CAuiImagePane.hpp | 6 +- Runtime/GuiSys/CGuiCamera.cpp | 1 + Runtime/GuiSys/CGuiFrame.cpp | 1 + Runtime/GuiSys/CGuiPane.cpp | 4 +- Runtime/GuiSys/CGuiTextPane.cpp | 6 +- Runtime/GuiSys/CGuiWidget.cpp | 2 +- Runtime/World/CActor.hpp | 2 + Runtime/World/CWorldLight.cpp | 95 +++++++++++++++-------- Runtime/World/CWorldLight.hpp | 14 +++- 14 files changed, 151 insertions(+), 40 deletions(-) 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; From 49839bbd6d0eb115c88a0947a28201d0c947c6b8 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 21 Jan 2017 07:49:31 -0800 Subject: [PATCH 4/7] Remove dbug printf --- Runtime/GuiSys/CGuiFrame.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Runtime/GuiSys/CGuiFrame.cpp b/Runtime/GuiSys/CGuiFrame.cpp index be8cf3882..0e59528e6 100644 --- a/Runtime/GuiSys/CGuiFrame.cpp +++ b/Runtime/GuiSys/CGuiFrame.cpp @@ -142,7 +142,6 @@ 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) From 02d9c7199ae41e9abf858561f4a14fe4ad13d6da Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 21 Jan 2017 08:58:43 -0800 Subject: [PATCH 5/7] Unfuck my fuckup --- Runtime/GuiSys/CStringTable.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Runtime/GuiSys/CStringTable.cpp b/Runtime/GuiSys/CStringTable.cpp index a0fab8aa1..62b3eefa1 100644 --- a/Runtime/GuiSys/CStringTable.cpp +++ b/Runtime/GuiSys/CStringTable.cpp @@ -5,13 +5,13 @@ namespace urde { const std::vector CStringTable::skLanguages = { - 'ENGL', - 'FREN', - 'GERM', - 'SPAN', - 'ITAL', - 'DUTC', - 'JAPN' + FOURCC('ENGL'), + FOURCC('FREN'), + FOURCC('GERM'), + FOURCC('SPAN'), + FOURCC('ITAL'), + FOURCC('DUTC'), + FOURCC('JAPN') }; FourCC CStringTable::mCurrentLanguage = CStringTable::skLanguages[0]; @@ -58,7 +58,7 @@ void CStringTable::LoadStringTable(CInputStream &in) m_bufLen = dataLen; x4_data.reset(new u8[dataLen]); in.readUBytesToBuf(x4_data.get(), dataLen); - for (u32 i = 0 ; i(x4_data.get() + i); *off = hecl::SBig(*off); @@ -75,7 +75,7 @@ std::wstring CStringTable::GetString(s32 str) const if (str < 0 || u32(str) >= x0_stringCount) return L"Invalid"; - u32 off = *(reinterpret_cast(x4_data.get() + str * 4)); + u32 off = *(reinterpret_cast(x4_data.get() + (str * 4))); CMemoryInStream tmp(x4_data.get() + off, m_bufLen - off); return tmp.readWString(); } From 9c96bf8c54a3103770384c2a183f9ce7d5358f9b Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 21 Jan 2017 14:26:07 -0800 Subject: [PATCH 6/7] Add CTweakTargeting --- DataSpec/DNAMP1/DNAMP1.cpp | 3 + DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp | 137 +++++++++++++++++++++ 2 files changed, 140 insertions(+) diff --git a/DataSpec/DNAMP1/DNAMP1.cpp b/DataSpec/DNAMP1/DNAMP1.cpp index 900e4dbed..96834c58a 100644 --- a/DataSpec/DNAMP1/DNAMP1.cpp +++ b/DataSpec/DNAMP1/DNAMP1.cpp @@ -33,6 +33,7 @@ #include "Tweaks/CTweakCameraBob.hpp" #include "Tweaks/CTweakSlideShow.hpp" #include "Tweaks/CTweakGame.hpp" +#include "Tweaks/CTweakTargeting.hpp" namespace DataSpec { @@ -385,6 +386,8 @@ ResExtractor PAKBridge::LookupExtractor(const PAK& pak, const PAK::En return {ExtractTweak, {_S(".yaml")}}; if (!name.compare("Game")) return {ExtractTweak, {_S(".yaml")}}; + if (!name.compare("Targeting")) + return {ExtractTweak, {_S(".yaml")}}; } break; } diff --git a/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp b/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp index b79e87f6e..f157942f0 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp @@ -10,6 +10,143 @@ namespace DNAMP1 struct CTweakTargeting : public ITweakTargeting { DECL_YAML + Value x4_; + Value x8_; + Value xc_; + Value x10_; + Value x14_; + Value x18_; + Value x1c_; + Value x20_; + Value x24_; + Value x28_; + Value x2c_; + Value x30_; + Value x3c_; + Value x48_; + Value x4c_; + Value x50_; + Value x54_; + Value x58_; + Value x5c_; + Value x60_; + Value x6c_; + Value x78_; + Value x84_; + Value x90_; + Value x94_; + Value x98_; + Value x9c_; + Value xa0_; + Value xa4_; + Value xa8_; + Value xac_; + Value xb0_; + Value xb4_; + Value xb8_; + Value xbc_; + Value xc0_; + Value xc4_; + Value xc8_; + Value xcc_; + Value xd0_; + Value xd4_; + Value xd8_; + Value xdc_; + Value xe0_; + Value xe4_; + Value xe8_; + Value xec_; + Value xf0_; + Value xf4_; + Value xf8_entryCount; + struct UnkVec : BigYAML + { + DECL_YAML + Value count; + Vector floats; + }; + Vector xf8_; + Value x108_entryCount; + Vector x108_; + Value x118_; + Value x11c_; + Value x120_; + Value x124_; + Value x128_; + Value x12c_; + Value x130_; + Value x134_; + Value x138_; + Value x13c_; + Value x140_; + Value x144_; + Value x148_; + Value x14c_; + Value x150_; + Value x154_; + Value x158_; + Value x15c_; + Value x160_; + Value x164_; + Value x168_; + Value x16c_; + Value x170_; + Value x174_; + Value x178_; + Value x17c_; + Value x180_; + Value x184_; + Value x188_; + Value x18c_; + Value x190_; + Value x194_; + Value x198_; + Value x19c_; + Value x1a0_; + Value x1a4_; + Value x1a8_; + Value x1ac_; + Value x1b0_; + Value x1b4_; + Value x1b8_; + Value x1bc_; + Value x1c0_; + Value x1c4_; + Value x1c8_; + Value x1cc_; + Value x1d0_; + Value x1d4_; + Value x1d8_; + Value x1dc_; + Value x1e0_; + Value x1e4_; + Value x1e8_; + Value x1ec_; + Value x1f0_; + Value x1f4_; + Value x1f8_; + Value x1fc_; + Value x200_; + Value x204_; + Value x208_; + Value x20c_; + Value x210_; + Value x214_; + Value x218_; + Value x21c_; + Value x220_; + Value x224_; + + CTweakTargeting() = default; + CTweakTargeting(athena::io::IStreamReader& r) + { + this->read(r); + x124_ = -1.f * ((2 * M_PIF) * (0.003f * x124_)); + x140_ = (2.f * M_PIF) * (0.003f * x140_); + x144_ = (2.f * M_PIF) * (0.003f * x144_); + x208_ = (2.f * M_PIF) * (0.003f * x208_); + } }; } } From cc9a0f2bbc08806daa8c4db512f58ceab9897a0e Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 21 Jan 2017 15:05:42 -0800 Subject: [PATCH 7/7] Clean up CWorldLight --- Runtime/World/CWorldLight.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Runtime/World/CWorldLight.cpp b/Runtime/World/CWorldLight.cpp index ccc8ff16e..117ea1b38 100644 --- a/Runtime/World/CWorldLight.cpp +++ b/Runtime/World/CWorldLight.cpp @@ -36,7 +36,6 @@ std::tuple CalculateLightFalloff(EFalloffType falloff, floa CLight CWorldLight::GetAsCGraphicsLight() const { zeus::CVector3f float_color = x4_color; - zeus::CColor tmpColor; float q = x28_q; if (q < FLT_EPSILON) q = 0.000001f; @@ -57,11 +56,12 @@ CLight CWorldLight::GetAsCGraphicsLight() const } else if (x0_type == EWorldLightType::Directional) { - return CLight::BuildDirectional(x1c_direction, tmpColor); + return CLight::BuildDirectional(x1c_direction, zeus::CColor{x4_color.x, x4_color.y, x4_color.z, 1.f}); } else if (x0_type == EWorldLightType::Spot) { - CLight light = CLight::BuildSpot(x10_position, x1c_direction.normalized(), tmpColor, x2c_cutoffAngle * .5f); + CLight light = CLight::BuildSpot(x10_position, x1c_direction.normalized(), + zeus::CColor{x4_color.x, x4_color.y, x4_color.z, 1.f}, x2c_cutoffAngle * .5f); float c, l, q; std::tie(c, l, q) = CalculateLightFalloff(x3c_falloff, x28_q);