2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 21:07:42 +00:00

More element classes

This commit is contained in:
Jack Andersen
2016-02-01 22:22:01 -10:00
parent dd75a37b66
commit 1402d68c01
2 changed files with 1030 additions and 27 deletions

View File

@@ -10,6 +10,11 @@ namespace DNAParticle
struct IElement : BigYAML
{
enum class ClassID : uint32_t
{
NONE = 'NONE',
CNST = 'CNST'
};
Delete _d;
virtual ~IElement() = default;
virtual const char* ClassName() const=0;
@@ -41,6 +46,47 @@ struct IntElementFactory : BigYAML
void write(Athena::io::IStreamWriter& w) const;
};
struct IVectorElement : IElement {Delete _d;};
struct VectorElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IVectorElement> m_elem;
void read(Athena::io::YAMLDocReader& r);
void write(Athena::io::YAMLDocWriter& w) const;
size_t binarySize(size_t __isz) const;
void read(Athena::io::IStreamReader& r);
void write(Athena::io::IStreamWriter& w) const;
};
struct IColorElement : IElement {Delete _d;};
struct ColorElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IColorElement> m_elem;
void read(Athena::io::YAMLDocReader& r);
void write(Athena::io::YAMLDocWriter& w) const;
size_t binarySize(size_t __isz) const;
void read(Athena::io::IStreamReader& r);
void write(Athena::io::IStreamWriter& w) const;
};
struct IModVectorElement : IElement {Delete _d;};
struct ModVectorElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IModVectorElement> m_elem;
void read(Athena::io::YAMLDocReader& r);
void write(Athena::io::YAMLDocWriter& w) const;
size_t binarySize(size_t __isz) const;
void read(Athena::io::IStreamReader& r);
void write(Athena::io::IStreamWriter& w) const;
};
struct IUVElement : IElement {Delete _d;};
struct RELifetimeTween : IRealElement
{
DECL_YAML
@@ -85,7 +131,7 @@ struct REClamp : IRealElement
struct REKeyframeEmitter : IRealElement
{
DECL_YAML
Value<atUint32> a;
Value<atUint32> percentage;
Value<atUint32> b;
Value<atUint8> c;
Value<atUint8> d;
@@ -93,7 +139,7 @@ struct REKeyframeEmitter : IRealElement
Value<atUint32> f;
Value<atUint32> count;
Vector<float, DNA_COUNT(count)> keys;
const char* ClassName() const {return "KEYE";}
const char* ClassName() const {return percentage ? "KEYP" : "KEYE";}
};
struct REInitialRandom : IRealElement
@@ -104,12 +150,6 @@ struct REInitialRandom : IRealElement
const char* ClassName() const {return "IRND";}
};
struct REKeyframeEmitterP : REKeyframeEmitter
{
Delete _d;
const char* ClassName() const {return "KEYP";}
};
struct RERandom : IRealElement
{
DECL_YAML
@@ -162,7 +202,7 @@ struct RESineWave : IRealElement
struct IEKeyframeEmitter : IIntElement
{
DECL_YAML
Value<atUint32> a;
Value<atUint32> percentage;
Value<atUint32> b;
Value<atUint8> c;
Value<atUint8> d;
@@ -170,7 +210,7 @@ struct IEKeyframeEmitter : IIntElement
Value<atUint32> f;
Value<atUint32> count;
Vector<atUint32, DNA_COUNT(count)> keys;
const char* ClassName() const {return "KEYE";}
const char* ClassName() const {return percentage ? "KEYP" : "KEYE";}
};
struct IEDeath : IIntElement
@@ -254,12 +294,6 @@ struct IEMultiply : IIntElement
const char* ClassName() const {return "MULT";}
};
struct IEKeyframeEmitterP : IEKeyframeEmitter
{
Delete _d;
const char* ClassName() const {return "KEYP";}
};
struct IESampleAndHold : IIntElement
{
DECL_YAML
@@ -284,6 +318,556 @@ struct IETimeScale : IIntElement
const char* ClassName() const {return "TSCL";}
};
struct VECone : IVectorElement
{
DECL_YAML
VectorElementFactory a;
RealElementFactory b;
const char* ClassName() const {return "CONE";}
};
struct VETimeChain : IVectorElement
{
DECL_YAML
VectorElementFactory a;
VectorElementFactory b;
IntElementFactory c;
const char* ClassName() const {return "CHAN";}
};
struct VEAngleCone : IVectorElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
RealElementFactory c;
RealElementFactory d;
RealElementFactory e;
const char* ClassName() const {return "ANGC";}
};
struct VEAdd : IVectorElement
{
DECL_YAML
VectorElementFactory a;
VectorElementFactory b;
const char* ClassName() const {return "ADD_";}
};
struct VECircleCluster : IVectorElement
{
DECL_YAML
VectorElementFactory a;
VectorElementFactory b;
IntElementFactory c;
RealElementFactory d;
const char* ClassName() const {return "CCLU";}
};
struct VEConstant : IVectorElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
RealElementFactory c;
const char* ClassName() const {return "CNST";}
};
struct VECircle : IVectorElement
{
DECL_YAML
VectorElementFactory a;
VectorElementFactory b;
RealElementFactory c;
RealElementFactory d;
RealElementFactory e;
const char* ClassName() const {return "CIRC";}
};
struct VEKeyframeEmitter : IVectorElement
{
DECL_YAML
Value<atUint32> percentage;
Value<atUint32> b;
Value<atUint8> c;
Value<atUint8> d;
Value<atUint32> e;
Value<atUint32> f;
Value<atUint32> count;
Vector<atVec3f, DNA_COUNT(count)> keys;
const char* ClassName() const {return percentage ? "KEYP" : "KEYE";}
};
struct VEMultiply : IVectorElement
{
DECL_YAML
VectorElementFactory a;
VectorElementFactory b;
const char* ClassName() const {return "MULT";}
};
struct VERealToVector : IVectorElement
{
DECL_YAML
RealElementFactory a;
const char* ClassName() const {return "RTOV";}
};
struct VEPulse : IVectorElement
{
DECL_YAML
IntElementFactory a;
IntElementFactory b;
VectorElementFactory c;
VectorElementFactory d;
const char* ClassName() const {return "PULS";}
};
struct CEKeyframeEmitter : IColorElement
{
DECL_YAML
Value<atUint32> percentage;
Value<atUint32> b;
Value<atUint8> c;
Value<atUint8> d;
Value<atUint32> e;
Value<atUint32> f;
Value<atUint32> count;
Vector<atVec4f, DNA_COUNT(count)> keys;
const char* ClassName() const {return percentage ? "KEYP" : "KEYE";}
};
struct CEConstant : IColorElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
RealElementFactory c;
RealElementFactory d;
const char* ClassName() const {return "CNST";}
};
struct CETimeChain : IColorElement
{
DECL_YAML
ColorElementFactory a;
ColorElementFactory b;
IntElementFactory c;
const char* ClassName() const {return "CHAN";}
};
struct CEFadeEnd : IColorElement
{
DECL_YAML
ColorElementFactory a;
ColorElementFactory b;
RealElementFactory c;
RealElementFactory d;
const char* ClassName() const {return "CFDE";}
};
struct CEFade : IColorElement
{
DECL_YAML
ColorElementFactory a;
ColorElementFactory b;
RealElementFactory c;
const char* ClassName() const {return "FADE";}
};
struct CEPulse : IColorElement
{
DECL_YAML
IntElementFactory a;
IntElementFactory b;
ColorElementFactory c;
ColorElementFactory d;
const char* ClassName() const {return "PULS";}
};
struct MVEImplosion : IModVectorElement
{
DECL_YAML
VectorElementFactory a;
RealElementFactory b;
RealElementFactory c;
RealElementFactory d;
Value<ClassID> boolCls = ClassID::CNST;
Value<bool> boolVal;
const char* ClassName() const {return "IMPL";}
};
struct MVEExponentialImplosion : IModVectorElement
{
DECL_YAML
VectorElementFactory a;
RealElementFactory b;
RealElementFactory c;
RealElementFactory d;
Value<ClassID> boolCls = ClassID::CNST;
Value<bool> boolVal;
const char* ClassName() const {return "EMPL";}
};
struct MVETimeChain : IModVectorElement
{
DECL_YAML
ModVectorElementFactory a;
ModVectorElementFactory b;
IntElementFactory c;
const char* ClassName() const {return "CHAN";}
};
struct MVEBounce : IModVectorElement
{
DECL_YAML
VectorElementFactory a;
VectorElementFactory b;
RealElementFactory c;
RealElementFactory d;
Value<ClassID> boolCls = ClassID::CNST;
Value<bool> boolVal;
const char* ClassName() const {return "BNCE";}
};
struct MVEConstant : IModVectorElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
RealElementFactory c;
const char* ClassName() const {return "CNST";}
};
struct MVEGravity : IModVectorElement
{
DECL_YAML
VectorElementFactory a;
const char* ClassName() const {return "GRAV";}
};
struct MVEExplode : IModVectorElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
const char* ClassName() const {return "EXPL";}
};
struct MVESetPosition : IModVectorElement
{
DECL_YAML
VectorElementFactory a;
const char* ClassName() const {return "SPOS";}
};
struct MVELinearImplosion : IModVectorElement
{
DECL_YAML
VectorElementFactory a;
RealElementFactory b;
RealElementFactory c;
RealElementFactory d;
Value<ClassID> boolCls = ClassID::CNST;
Value<bool> boolVal;
const char* ClassName() const {return "LMPL";}
};
struct MVEPulse : IModVectorElement
{
DECL_YAML
IntElementFactory a;
IntElementFactory b;
ModVectorElementFactory c;
ModVectorElementFactory d;
const char* ClassName() const {return "PULS";}
};
struct MVEWind : IModVectorElement
{
DECL_YAML
VectorElementFactory a;
RealElementFactory b;
const char* ClassName() const {return "WIND";}
};
struct MVESwirl : IModVectorElement
{
DECL_YAML
VectorElementFactory a;
VectorElementFactory b;
RealElementFactory c;
RealElementFactory d;
const char* ClassName() const {return "SWRL";}
};
template <class IDType>
struct UVEConstant : IUVElement
{
Delete _d;
IDType tex;
void read(Athena::io::YAMLDocReader& r)
{
tex.clear();
if (r.enterSubRecord("tex"))
{
if (r.enterSubRecord("CNST"))
{
tex.read(r);
r.leaveSubRecord();
}
r.leaveSubRecord();
}
}
void write(Athena::io::YAMLDocWriter& w) const
{
if (tex)
{
w.enterSubRecord("CNST");
tex.write(w);
w.leaveSubRecord();
}
}
size_t binarySize(size_t __isz) const
{
if (tex)
return __isz + 8;
else
return __isz + 4;
}
void read(Athena::io::IStreamReader& r)
{
tex.clear();
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('CNST'))
tex.read(r);
}
void write(Athena::io::IStreamWriter& w) const
{
if (tex)
{
w.writeBytes((atInt8*)"CNST", 4);
tex.write(w);
}
else
w.writeBytes((atInt8*)"NONE", 4);
}
};
template <class IDType>
struct UVEAnimTexture : IUVElement
{
Delete _d;
IDType tex;
IntElementFactory a;
IntElementFactory b;
IntElementFactory c;
IntElementFactory d;
IntElementFactory e;
Value<ClassID> boolCls = ClassID::CNST;
Value<bool> boolVal;
void read(Athena::io::YAMLDocReader& r)
{
tex.clear();
if (r.enterSubRecord("tex"))
{
if (r.enterSubRecord("CNST"))
{
tex.read(r);
r.leaveSubRecord();
}
r.leaveSubRecord();
}
if (r.enterSubRecord("a"))
{
a.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("b"))
{
b.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("c"))
{
c.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("d"))
{
d.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("e"))
{
e.read(r);
r.leaveSubRecord();
}
boolCls = ClassID::NONE;
if (r.enterSubRecord("bool"))
{
if (r.enterSubRecord("CNST"))
{
boolCls = ClassID::CNST;
boolVal = r.readBool(nullptr);
r.leaveSubRecord();
}
r.leaveSubRecord();
}
}
void write(Athena::io::YAMLDocWriter& w) const
{
if (tex)
{
w.enterSubRecord("CNST");
tex.write(w);
w.leaveSubRecord();
}
a.write(w);
b.write(w);
c.write(w);
d.write(w);
e.write(w);
w.enterSubRecord("bool");
if (boolCls == ClassID::CNST)
{
w.enterSubRecord("CNST");
w.writeBool(nullptr, boolVal);
w.leaveSubRecord();
}
w.leaveSubRecord();
}
size_t binarySize(size_t __isz) const
{
__isz += 8;
if (tex)
__isz += 4;
__isz = a.binarySize(__isz);
__isz = b.binarySize(__isz);
__isz = c.binarySize(__isz);
__isz = d.binarySize(__isz);
__isz = e.binarySize(__isz);
if (boolCls == ClassID::CNST)
__isz += 1;
return __isz;
}
void read(Athena::io::IStreamReader& r)
{
tex.clear();
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('CNST'))
tex.read(r);
a.read(r);
b.read(r);
c.read(r);
d.read(r);
e.read(r);
boolCls = ClassID::NONE;
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('CNST'))
{
boolCls = ClassID::CNST;
boolVal = r.readBool();
}
}
void write(Athena::io::IStreamWriter& w) const
{
if (tex)
{
w.writeBytes((atInt8*)"CNST", 4);
tex.write(w);
}
else
w.writeBytes((atInt8*)"NONE", 4);
a.write(w);
b.write(w);
c.write(w);
d.write(w);
e.write(w);
if (boolCls == ClassID::CNST)
{
w.writeBytes((atInt8*)"CNST", 4);
w.writeBool(boolVal);
}
else
w.writeBytes((atInt8*)"NONE", 4);
}
};
template <class IDType>
struct UVElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IUVElement> m_elem;
void read(Athena::io::YAMLDocReader& r)
{
if (r.enterSubRecord("CNST"))
{
m_elem.reset(new struct UVEConstant<IDType>);
m_elem->read(r);
r.leaveSubRecord();
}
else if (r.enterSubRecord("ATEX"))
{
m_elem.reset(new struct UVEAnimTexture<IDType>);
m_elem->read(r);
r.leaveSubRecord();
}
else
m_elem.reset();
}
void write(Athena::io::YAMLDocWriter& w) const
{
if (m_elem)
{
w.enterSubRecord(m_elem->ClassName());
m_elem->write(w);
w.leaveSubRecord();
}
}
size_t binarySize(size_t __isz) const
{
if (m_elem)
return m_elem->binarySize(__isz + 4);
else
return __isz + 4;
}
void read(Athena::io::IStreamReader& r)
{
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
switch (clsId)
{
case SBIG('CNST'):
m_elem.reset(new struct UVEConstant<IDType>);
break;
case SBIG('ATEX'):
m_elem.reset(new struct UVEAnimTexture<IDType>);
break;
default:
m_elem.reset();
return;
}
m_elem->read(r);
}
void write(Athena::io::IStreamWriter& w) const
{
if (m_elem)
{
w.writeBytes((atInt8*)m_elem->ClassName(), 4);
m_elem->write(w);
}
else
w.writeBytes((atInt8*)"NONE", 4);
}
};
template <class IDType>
struct ChildGeneratorDesc : BigYAML
@@ -318,18 +902,20 @@ struct ChildGeneratorDesc : BigYAML
void read(Athena::io::IStreamReader& r)
{
id.clear();
if (r.readUint32Big() == 'CNST')
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('CNST'))
id.read(r);
}
void write(Athena::io::IStreamWriter& w) const
{
if (id)
{
w.writeUint32Big('CNST');
w.writeBytes((atInt8*)"CNST", 4);
id.write(w);
}
else
w.writeUint32Big('NONE');
w.writeBytes((atInt8*)"NONE", 4);
}
};