mirror of https://github.com/AxioDL/metaforce.git
Merge branch 'master' of https://github.com/AxioDL/PathShagged
This commit is contained in:
commit
129dc11ecc
|
@ -1,14 +1,138 @@
|
||||||
#include "CDecalDataFactory.hpp"
|
#include "CDecalDataFactory.hpp"
|
||||||
#include "CDecalDescription.hpp"
|
#include "CDecalDescription.hpp"
|
||||||
|
#include "CParticleDataFactory.hpp"
|
||||||
#include "CSimplePool.hpp"
|
#include "CSimplePool.hpp"
|
||||||
|
#include "CRandom16.hpp"
|
||||||
|
|
||||||
namespace pshag
|
namespace pshag
|
||||||
{
|
{
|
||||||
|
static LogVisor::LogModule Log("pshag::CDecalDataFactory");
|
||||||
|
|
||||||
|
using CPF = CParticleDataFactory;
|
||||||
CDecalDescription* CDecalDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool)
|
CDecalDescription* CDecalDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool)
|
||||||
{
|
{
|
||||||
|
return CreateGeneratorDescription(in, resPool);
|
||||||
|
}
|
||||||
|
|
||||||
|
CDecalDescription* CDecalDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool)
|
||||||
|
{
|
||||||
|
FourCC clsId = CPF::GetClassID(in);
|
||||||
|
if (clsId == FOURCC('DPSM'))
|
||||||
|
{
|
||||||
|
CDecalDescription* desc = new CDecalDescription;
|
||||||
|
if (CreateDPSM(desc, in, resPool))
|
||||||
|
return desc;
|
||||||
|
else
|
||||||
|
delete desc;
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CDecalDataFactory::CreateDPSM(CDecalDescription* desc, CInputStream& in, CSimplePool* resPool)
|
||||||
|
{
|
||||||
|
CRandom16 rand{99};
|
||||||
|
CGlobalRandom gr{rand};
|
||||||
|
FourCC clsId = CPF::GetClassID(in);
|
||||||
|
|
||||||
|
while(clsId != SBIG('_END'))
|
||||||
|
{
|
||||||
|
bool loadFirstDesc = false;
|
||||||
|
switch(clsId)
|
||||||
|
{
|
||||||
|
case SBIG('1SZE'):
|
||||||
|
case SBIG('1LFT'):
|
||||||
|
case SBIG('1ROT'):
|
||||||
|
case SBIG('1OFF'):
|
||||||
|
case SBIG('1CLR'):
|
||||||
|
case SBIG('1TEX'):
|
||||||
|
case SBIG('1ADD'):
|
||||||
|
loadFirstDesc = true;
|
||||||
|
case SBIG('2LFT'):
|
||||||
|
case SBIG('2SZE'):
|
||||||
|
case SBIG('2ROT'):
|
||||||
|
case SBIG('2OFF'):
|
||||||
|
case SBIG('2CLR'):
|
||||||
|
case SBIG('2TEX'):
|
||||||
|
case SBIG('2ADD'):
|
||||||
|
if (loadFirstDesc)
|
||||||
|
GetQuadDecalInfo(in, resPool, clsId, desc->x0_Quad);
|
||||||
|
else
|
||||||
|
GetQuadDecalInfo(in, resPool, clsId, desc->x1c_Quad);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SBIG('DMDL'):
|
||||||
|
desc->x38_DMDL = CPF::GetModel(in, resPool);
|
||||||
|
break;
|
||||||
|
case SBIG('DFLT'):
|
||||||
|
desc->x48_DFLT.reset(CPF::GetIntElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('DMOP'):
|
||||||
|
desc->x4c_DMOP.reset(CPF::GetVectorElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('DMRT'):
|
||||||
|
desc->x50_DMRT.reset(CPF::GetVectorElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('DMSC'):
|
||||||
|
desc->x54_DMSC.reset(CPF::GetVectorElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('DMCL'):
|
||||||
|
desc->x58_DMCL.reset(CPF::GetColorElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('DMAB'):
|
||||||
|
desc->x5c_24_DMAB = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
case SBIG('DMOO'):
|
||||||
|
desc->x5c_25_DMOO = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
uint32_t clsName = clsId.toUint32();
|
||||||
|
Log.report(LogVisor::FatalError, "Unknown DPSC class %.4s @%" PRIi64, &clsName, in.position());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clsId = CPF::GetClassID(in);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDecalDataFactory::GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, FourCC clsId, SQuadDescr& quad)
|
||||||
|
{
|
||||||
|
switch(clsId)
|
||||||
|
{
|
||||||
|
case SBIG('1LFT'):
|
||||||
|
case SBIG('2LFT'):
|
||||||
|
quad.x0_LFT.reset(CPF::GetIntElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('1SZE'):
|
||||||
|
case SBIG('2SZE'):
|
||||||
|
quad.x4_SZE.reset(CPF::GetRealElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('1ROT'):
|
||||||
|
case SBIG('2ROT'):
|
||||||
|
quad.x8_ROT.reset(CPF::GetRealElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('1OFF'):
|
||||||
|
case SBIG('2OFF'):
|
||||||
|
quad.xc_OFF.reset(CPF::GetVectorElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('1CLR'):
|
||||||
|
case SBIG('2CLR'):
|
||||||
|
quad.x10_CLR.reset(CPF::GetColorElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('1TEX'):
|
||||||
|
case SBIG('2TEX'):
|
||||||
|
quad.x14_TEX.reset(CPF::GetTextureElement(in, resPool));
|
||||||
|
break;
|
||||||
|
case SBIG('1ADD'):
|
||||||
|
case SBIG('2ADD'):
|
||||||
|
quad.x18_ADD = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<IObj> FDecalDataFactory(const SObjectTag &tag, CInputStream &in, const CVParamTransfer &vparms)
|
std::unique_ptr<IObj> FDecalDataFactory(const SObjectTag &tag, CInputStream &in, const CVParamTransfer &vparms)
|
||||||
{
|
{
|
||||||
CSimplePool* sp = static_cast<CSimplePool*>(static_cast<TObjOwnerParam<IObjectStore*>*>(vparms.GetObj())->GetParam());
|
CSimplePool* sp = static_cast<CSimplePool*>(static_cast<TObjOwnerParam<IObjectStore*>*>(vparms.GetObj())->GetParam());
|
||||||
|
|
|
@ -9,15 +9,17 @@
|
||||||
|
|
||||||
namespace pshag
|
namespace pshag
|
||||||
{
|
{
|
||||||
|
struct SQuadDescr;
|
||||||
class CDecalDescription;
|
class CDecalDescription;
|
||||||
class CSimplePool;
|
class CSimplePool;
|
||||||
|
|
||||||
class CDecalDataFactory
|
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);
|
||||||
public:
|
public:
|
||||||
static CDecalDescription* GetGeneratorDesc(CInputStream& in,CSimplePool* resPool);
|
static CDecalDescription* GetGeneratorDesc(CInputStream& in,CSimplePool* resPool);
|
||||||
static CDecalDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool);
|
|
||||||
static bool CreateDPSM(CDecalDescription* desc,CInputStream& in,CSimplePool* resPool);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IObj> FDecalDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms);
|
std::unique_ptr<IObj> FDecalDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms);
|
||||||
|
|
|
@ -1,10 +1,42 @@
|
||||||
#ifndef __PSHAG_CDECALDESCRIPTION_HPP__
|
#ifndef __PSHAG_CDECALDESCRIPTION_HPP__
|
||||||
#define __PSHAG_CDECALDESCRIPTION_HPP__
|
#define __PSHAG_CDECALDESCRIPTION_HPP__
|
||||||
|
|
||||||
|
#include "CRealElement.hpp"
|
||||||
|
#include "CIntElement.hpp"
|
||||||
|
#include "CVectorElement.hpp"
|
||||||
|
#include "CColorElement.hpp"
|
||||||
|
#include "CUVElement.hpp"
|
||||||
|
#include "CParticleDataFactory.hpp"
|
||||||
|
|
||||||
namespace pshag
|
namespace pshag
|
||||||
{
|
{
|
||||||
|
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
|
class CDecalDescription
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
SQuadDescr x0_Quad;
|
||||||
|
SQuadDescr x1c_Quad;
|
||||||
|
SParticleModel x38_DMDL;
|
||||||
|
std::unique_ptr<CIntElement> x48_DFLT;
|
||||||
|
std::unique_ptr<CVectorElement> x4c_DMOP;
|
||||||
|
std::unique_ptr<CVectorElement> x50_DMRT;
|
||||||
|
std::unique_ptr<CVectorElement> x54_DMSC;
|
||||||
|
std::unique_ptr<CColorElement> x58_DMCL;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct { bool x5c_24_DMAB : 1; bool x5c_25_DMOO : 1;};
|
||||||
|
u8 dummy = 0;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,10 @@ CSwooshDescription*CParticleSwooshDataFactory::CreateGeneratorDescription(CInput
|
||||||
if (clsId == FOURCC('SWSH'))
|
if (clsId == FOURCC('SWSH'))
|
||||||
{
|
{
|
||||||
CSwooshDescription* desc = new CSwooshDescription;
|
CSwooshDescription* desc = new CSwooshDescription;
|
||||||
CreateWPSM(desc, in, resPool);
|
if (CreateWPSM(desc, in, resPool))
|
||||||
return desc;
|
return desc;
|
||||||
|
else
|
||||||
|
delete desc;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue