Initial pass at CDecal classes

Former-commit-id: 4b24bba57e
This commit is contained in:
Phillip Stephens 2022-10-04 12:58:17 -07:00
parent 2ef9d69288
commit f8688e02e3
6 changed files with 134 additions and 0 deletions

View File

@ -58,6 +58,7 @@ public:
static float GetSecondsMod900();
static void SetExternalTimeProvider(CTimeProvider* provider);
static void DisableAllLights();
private:
static CTransform4f mViewMatrix;

View File

@ -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__

View File

@ -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 <types.h>
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<CDecalDescription> 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__

View File

@ -0,0 +1,13 @@
#ifndef __CDECALDESCRIPTION_HPP__
#define __CDECALDESCRIPTION_HPP__
class CDecalDescription {
public:
struct SQuadDescr {
};
private:
};
#endif //__CDECALDESCRIPTION_HPP__

View File

@ -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;
}

44
src/Weapons/CDecal.cpp Normal file
View File

@ -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;
}