diff --git a/include/Kyoto/Graphics/CGraphics.hpp b/include/Kyoto/Graphics/CGraphics.hpp index 6a239ddb..adea86d2 100644 --- a/include/Kyoto/Graphics/CGraphics.hpp +++ b/include/Kyoto/Graphics/CGraphics.hpp @@ -58,6 +58,7 @@ public: static float GetSecondsMod900(); static void SetExternalTimeProvider(CTimeProvider* provider); + static void DisableAllLights(); private: static CTransform4f mViewMatrix; diff --git a/include/Kyoto/Particles/CParticleGlobals.hpp b/include/Kyoto/Particles/CParticleGlobals.hpp new file mode 100644 index 00000000..264f550e --- /dev/null +++ b/include/Kyoto/Particles/CParticleGlobals.hpp @@ -0,0 +1,11 @@ +#ifndef __CPARTICLEGLOBALS_HPP__ +#define __CPARTICLEGLOBALS_HPP__ + +class CParticleGlobals { +public: + static void SetEmitterTime(int time); + static void SetParticleLifetime(int lifetime); + static void UpdateParticleLifetimeTweenValues(int time); +}; + +#endif // __CPARTICLEGLOBALS_HPP__ diff --git a/include/Weapons/CDecal.hpp b/include/Weapons/CDecal.hpp new file mode 100644 index 00000000..95ada9d9 --- /dev/null +++ b/include/Weapons/CDecal.hpp @@ -0,0 +1,55 @@ +#ifndef __CDECAL_HPP__ +#define __CDECAL_HPP__ + +#include "Kyoto/CRandom16.hpp" +#include "Kyoto/Math/CTransform4f.hpp" +#include "Kyoto/TToken.hpp" +#include "Weapons/CDecalDescription.hpp" + +#include + +class CDecalDescription; +class CDecal { + static CRandom16 sDecalRandom; + static bool sMoveRedToAlpha; + +public: + class CQuadDecal { + public: + CQuadDecal() : x0_24_invalid(true), x4_lifetime(0), x8_rotation(0.f) {} + CQuadDecal(int lifetime, float rotation) + : x0_24_invalid(true), x4_lifetime(lifetime), x8_rotation(rotation) {} + + inline bool IsInvalid() const { return x0_24_invalid; } + inline void SetInvalid(bool invalid) { x0_24_invalid = invalid; } + + inline int GetLifetime() const { return x4_lifetime; } + inline void SetLifetime(int lifetime) { x4_lifetime = lifetime; } + + inline float GetRotation() const { return x8_rotation; } + inline void SetRotation(float rotation) { x8_rotation = rotation; } + private: + bool x0_24_invalid : 1; + int x4_lifetime; + float x8_rotation; + }; + + static void SetGlobalSeed(u16 seed); + CDecal(const TToken< CDecalDescription >& desc, const CTransform4f& xf); + + void RenderQuad(CQuadDecal& quad, const CDecalDescription::SQuadDescr& quadDesc) const; + void RenderMdl() const; + void Render() const; + void Update(float dt); + +private: + TLockedToken x0_description; + CTransform4f xc_transform; + CQuadDecal x3c_quad1; + CQuadDecal x48_quad2; + int x54_modelLifetime; + int x58_frameIdx; + int x5c_flags; + CVector3f x60_rotation; +}; +#endif // __CDECAL_HPP__ diff --git a/include/Weapons/CDecalDescription.hpp b/include/Weapons/CDecalDescription.hpp new file mode 100644 index 00000000..d1758083 --- /dev/null +++ b/include/Weapons/CDecalDescription.hpp @@ -0,0 +1,13 @@ +#ifndef __CDECALDESCRIPTION_HPP__ +#define __CDECALDESCRIPTION_HPP__ + + +class CDecalDescription { +public: + struct SQuadDescr { + }; + +private: +}; + +#endif //__CDECALDESCRIPTION_HPP__ diff --git a/src/Kyoto/Math/RMathUtils.cpp b/src/Kyoto/Math/RMathUtils.cpp new file mode 100644 index 00000000..e37bcdf4 --- /dev/null +++ b/src/Kyoto/Math/RMathUtils.cpp @@ -0,0 +1,10 @@ +#include "Kyoto/Math/CMath.hpp" + + +float CMath::SqrtF(float x) { + return 0.f; +} + +double CMath::SqrtD(double x) { + return 0.0; +} diff --git a/src/Weapons/CDecal.cpp b/src/Weapons/CDecal.cpp new file mode 100644 index 00000000..5b9aa6ed --- /dev/null +++ b/src/Weapons/CDecal.cpp @@ -0,0 +1,44 @@ +#include "Weapons/CDecal.hpp" +#include "Kyoto/Graphics/CGraphics.hpp" +#include "Kyoto/Particles/CParticleGlobals.hpp" + +CRandom16 CDecal::sDecalRandom(99); +bool CDecal::sMoveRedToAlpha = false; + +void CDecal::SetGlobalSeed(u16 seed) { sDecalRandom.SetSeed(seed); } + +CDecal::CDecal(const TToken< CDecalDescription >& desc, const CTransform4f& xf) +: x0_description(desc) +, xc_transform(xf) +, x54_modelLifetime(0) +, x58_frameIdx(0) +, x5c_flags(0) +, x60_rotation(CVector3f::Zero()) { + CGlobalRandom gr(sDecalRandom); +} + +void CDecal::RenderQuad(CQuadDecal& quad, const CDecalDescription::SQuadDescr& quadDesc) const {} +void CDecal::RenderMdl() const {} +void CDecal::Render() const { + CGlobalRandom gr(sDecalRandom); + if (x5c_flags == 7) { + return; + } + CGraphics::DisableAllLights(); + CParticleGlobals::SetEmitterTime(x58_frameIdx); +} +void CDecal::Update(float dt) { + if (x58_frameIdx >= x3c_quad1.GetLifetime()) { + x5c_flags |= 1; + } + + if (x58_frameIdx >= x48_quad2.GetLifetime()) { + x5c_flags |= 2; + } + + if (x58_frameIdx >= x54_modelLifetime) { + x5c_flags |= 4; + } + + ++x58_frameIdx; +}