prelim CDecal imps

This commit is contained in:
Phillip Stephens 2016-08-04 15:24:28 -07:00
parent 76a6b51d14
commit cedf3dba4e
8 changed files with 122 additions and 26 deletions

View File

@ -0,0 +1,43 @@
#include "CDecal.hpp"
namespace urde
{
CDecal::CDecal(const TToken<CDecalDescription>& 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;
}
}

View File

@ -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<CDecalDescription> 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<CDecalDescription>&, 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__

View File

@ -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)
{

View File

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

View File

@ -10,20 +10,20 @@
namespace urde
{
struct SQuadDescr
{
std::unique_ptr<CIntElement> x0_LFT;
std::unique_ptr<CRealElement> x4_SZE;
std::unique_ptr<CRealElement> x8_ROT;
std::unique_ptr<CVectorElement> xc_OFF;
std::unique_ptr<CColorElement> x10_CLR;
std::unique_ptr<CUVElement> x14_TEX;
bool x18_ADD = false;
};
class CDecalDescription
{
public:
struct SQuadDescr
{
std::unique_ptr<CIntElement> x0_LFT;
std::unique_ptr<CRealElement> x4_SZE;
std::unique_ptr<CRealElement> x8_ROT;
std::unique_ptr<CVectorElement> xc_OFF;
std::unique_ptr<CColorElement> x10_CLR;
std::unique_ptr<CUVElement> x14_TEX;
bool x18_ADD = false;
};
SQuadDescr x0_Quad;
SQuadDescr x1c_Quad;
SParticleModel x38_DMDL;

View File

@ -1,5 +1,6 @@
#include "CDecalManager.hpp"
#include "CDecalDescription.hpp"
#include "CDecal.hpp"
namespace urde
{

View File

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

View File

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