From cedf3dba4e6787ba04350a5b78caff0a8e7e9586 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 4 Aug 2016 15:24:28 -0700 Subject: [PATCH] prelim CDecal imps --- Runtime/Particle/CDecal.cpp | 43 ++++++++++++++++++ Runtime/Particle/CDecal.hpp | 61 ++++++++++++++++++++++++++ Runtime/Particle/CDecalDataFactory.cpp | 4 +- Runtime/Particle/CDecalDataFactory.hpp | 6 +-- Runtime/Particle/CDecalDescription.hpp | 22 +++++----- Runtime/Particle/CDecalManager.cpp | 1 + Runtime/Particle/CDecalManager.hpp | 10 +---- Runtime/Particle/CMakeLists.txt | 1 + 8 files changed, 122 insertions(+), 26 deletions(-) create mode 100644 Runtime/Particle/CDecal.cpp create mode 100644 Runtime/Particle/CDecal.hpp diff --git a/Runtime/Particle/CDecal.cpp b/Runtime/Particle/CDecal.cpp new file mode 100644 index 000000000..6a44316a2 --- /dev/null +++ b/Runtime/Particle/CDecal.cpp @@ -0,0 +1,43 @@ +#include "CDecal.hpp" + +namespace urde +{ + +CDecal::CDecal(const TToken& desc, const zeus::CTransform& xf) + : x0_description(desc), + xc_transform(xf), + x3c_decalQuad1(0, 0.f), + x48_decalQuad2(0, 0.f) +{ + CGlobalRandom gr(sDecalRandom); + + InitQuad(x3c_decalQuad1, x0_description.GetObj()->x0_Quad); + InitQuad(x48_decalQuad2, x0_description.GetObj()->x1c_Quad); +} + +void CDecal::InitQuad(CDecal::CQuadDecal& quad, const CDecalDescription::SQuadDescr& desc) +{ + if (desc.x14_TEX) + { + if (desc.x0_LFT) + desc.x0_LFT->GetValue(0, quad.x4_lifetime); + else + quad.x4_lifetime = 0x7FFFFF; + if (desc.x8_ROT) + { + desc.x8_ROT->GetValue(0, quad.x8_rotation); + u32 r0 = (quad._dummy >> 25) & 1; + r0 &= desc.x8_ROT->IsConstant(); + quad._dummy = (quad._dummy & ~0x80) | ((r0 << 7) & 0x80); + } + + if (desc.x4_SZE) + { + + } + } + else + quad.x0_24_ = false; +} + +} diff --git a/Runtime/Particle/CDecal.hpp b/Runtime/Particle/CDecal.hpp new file mode 100644 index 000000000..59f63ff03 --- /dev/null +++ b/Runtime/Particle/CDecal.hpp @@ -0,0 +1,61 @@ +#ifndef __URDE_CDECAL_HPP__ +#define __URDE_CDECAL_HPP__ + +#include "RetroTypes.hpp" +#include "CToken.hpp" +#include "zeus/CTransform.hpp" +#include "CDecalDescription.hpp" +#include "CRandom16.hpp" + +namespace urde +{ +class CDecal +{ +public: + struct CQuadDecal + { + union + { + struct + { + bool x0_24_ : 1; + }; + u32 _dummy = 0; + }; + s32 x4_lifetime = 0; + float x8_rotation = 0.f; + CQuadDecal(s32 i, float f) + : x4_lifetime(i), + x8_rotation(f) + { + x0_24_ = true; + } + }; +private: + static bool sMoveRedToAphaBuffer; + static CRandom16 sDecalRandom; + + TLockedToken x0_description; + zeus::CTransform xc_transform; + CQuadDecal x3c_decalQuad1; + CQuadDecal x48_decalQuad2; + u32 x54_ = 0; + u32 x58_ = 0; + u32 x5c_ = 0; + zeus::CVector3f x60_; + void InitQuad(CQuadDecal&, const CDecalDescription::SQuadDescr&); +public: + CDecal(const TToken&, const zeus::CTransform&); + bool IsDone() const; + void RenderQuad(CQuadDecal&, const CDecalDescription::SQuadDescr&) const; + void RenderMdl() const; + void ProcessQuad(CQuadDecal&, const CDecalDescription::SQuadDescr&, s32) const; + void Update(float); + void CheckTime(s32, s32); + + static void SetGlobalSeed(u16); + static void SetMoveRedToAlphaBuffer(bool); +}; +} + +#endif // __URDE_CDECAL_HPP__ diff --git a/Runtime/Particle/CDecalDataFactory.cpp b/Runtime/Particle/CDecalDataFactory.cpp index 525589ad8..f00509e1c 100644 --- a/Runtime/Particle/CDecalDataFactory.cpp +++ b/Runtime/Particle/CDecalDataFactory.cpp @@ -1,5 +1,4 @@ #include "CDecalDataFactory.hpp" -#include "CDecalDescription.hpp" #include "CGenDescription.hpp" #include "CSwooshDescription.hpp" #include "CElectricDescription.hpp" @@ -102,7 +101,8 @@ bool CDecalDataFactory::CreateDPSM(CDecalDescription* desc, CInputStream& in, CS return true; } -void CDecalDataFactory::GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, FourCC clsId, SQuadDescr& quad) +void CDecalDataFactory::GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, FourCC clsId, + CDecalDescription::SQuadDescr& quad) { switch (clsId) { diff --git a/Runtime/Particle/CDecalDataFactory.hpp b/Runtime/Particle/CDecalDataFactory.hpp index 96324cd92..590a22e7f 100644 --- a/Runtime/Particle/CDecalDataFactory.hpp +++ b/Runtime/Particle/CDecalDataFactory.hpp @@ -6,19 +6,17 @@ #include "IObj.hpp" #include "CToken.hpp" #include "IOStreams.hpp" - +#include "CDecalDescription.hpp" namespace urde { -struct SQuadDescr; -class CDecalDescription; class CSimplePool; class CDecalDataFactory { static bool CreateDPSM(CDecalDescription* desc,CInputStream& in,CSimplePool* resPool); static CDecalDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool); - static void GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, FourCC clsId, SQuadDescr& quad); + static void GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, FourCC clsId, CDecalDescription::SQuadDescr& quad); public: static CDecalDescription* GetGeneratorDesc(CInputStream& in,CSimplePool* resPool); }; diff --git a/Runtime/Particle/CDecalDescription.hpp b/Runtime/Particle/CDecalDescription.hpp index 9acf7e157..24e9cff3b 100644 --- a/Runtime/Particle/CDecalDescription.hpp +++ b/Runtime/Particle/CDecalDescription.hpp @@ -10,20 +10,20 @@ namespace urde { -struct SQuadDescr -{ - std::unique_ptr x0_LFT; - std::unique_ptr x4_SZE; - std::unique_ptr x8_ROT; - std::unique_ptr xc_OFF; - std::unique_ptr x10_CLR; - std::unique_ptr x14_TEX; - bool x18_ADD = false; -}; - class CDecalDescription { public: + struct SQuadDescr + { + std::unique_ptr x0_LFT; + std::unique_ptr x4_SZE; + std::unique_ptr x8_ROT; + std::unique_ptr xc_OFF; + std::unique_ptr x10_CLR; + std::unique_ptr x14_TEX; + bool x18_ADD = false; + }; + SQuadDescr x0_Quad; SQuadDescr x1c_Quad; SParticleModel x38_DMDL; diff --git a/Runtime/Particle/CDecalManager.cpp b/Runtime/Particle/CDecalManager.cpp index b6b619fee..419b82d49 100644 --- a/Runtime/Particle/CDecalManager.cpp +++ b/Runtime/Particle/CDecalManager.cpp @@ -1,5 +1,6 @@ #include "CDecalManager.hpp" #include "CDecalDescription.hpp" +#include "CDecal.hpp" namespace urde { diff --git a/Runtime/Particle/CDecalManager.hpp b/Runtime/Particle/CDecalManager.hpp index 7c521e401..22bf84169 100644 --- a/Runtime/Particle/CDecalManager.hpp +++ b/Runtime/Particle/CDecalManager.hpp @@ -5,18 +5,10 @@ #include "rstl.hpp" #include "optional.hpp" #include "CToken.hpp" +#include "CDecal.hpp" namespace urde { - -class CDecal -{ -public: - class CQuadDecal - { - }; -}; - class CDecalManager { struct SDecal diff --git a/Runtime/Particle/CMakeLists.txt b/Runtime/Particle/CMakeLists.txt index 8c32ef2eb..cb8bfd89d 100644 --- a/Runtime/Particle/CMakeLists.txt +++ b/Runtime/Particle/CMakeLists.txt @@ -27,6 +27,7 @@ set(PARTICLE_SOURCES CParticleElectric.hpp CParticleElectric.cpp CParticleGen.hpp CParticleGen.cpp CProjectileWeaponDataFactory.hpp CProjectileWeaponDataFactory.cpp + CDecal.hpp CDecal.cpp CDecalManager.hpp CDecalManager.cpp CSpawnSystemKeyframeData.hpp CSpawnSystemKeyframeData.cpp CWarp.hpp CWarp.cpp