2025-09-03 13:25:58 -04:00
|
|
|
#include "xsurface.h"
|
|
|
|
|
|
|
|
|
|
XSurface::XSurface()
|
|
|
|
|
: XAsset()
|
|
|
|
|
, mTileMode(0)
|
|
|
|
|
, mDeformed(false)
|
|
|
|
|
, mVertCount(0)
|
|
|
|
|
, mTriCount(0)
|
2025-12-19 23:06:03 -05:00
|
|
|
, mTriIndices()
|
2025-09-03 13:25:58 -04:00
|
|
|
, mVertInfo()
|
2025-09-07 23:16:14 -04:00
|
|
|
, mVert()
|
2025-09-03 13:25:58 -04:00
|
|
|
, mVertListCount(0)
|
|
|
|
|
, mVertList()
|
2025-12-19 23:06:03 -05:00
|
|
|
, mPartBits()
|
2025-09-03 13:25:58 -04:00
|
|
|
{
|
2025-09-10 21:58:26 -04:00
|
|
|
SetName("Surface");
|
2025-09-03 13:25:58 -04:00
|
|
|
}
|
|
|
|
|
|
2025-09-10 21:58:26 -04:00
|
|
|
void XSurface::ParseData(XDataStream *aStream)
|
2025-09-03 13:25:58 -04:00
|
|
|
{
|
2025-12-19 23:06:03 -05:00
|
|
|
mTileMode = aStream->ParseUInt8(QString("%1 tile mode").arg(GetName()));
|
|
|
|
|
mDeformed = aStream->ParseUInt8(QString("%1 deformed").arg(GetName()));
|
2025-09-10 21:58:26 -04:00
|
|
|
|
2025-12-19 23:06:03 -05:00
|
|
|
mVertCount = aStream->ParseUInt16(QString("%1 vertex count").arg(GetName()));
|
|
|
|
|
mTriCount = aStream->ParseUInt16(QString("%1 tri count").arg(GetName()));
|
2025-09-10 21:58:26 -04:00
|
|
|
|
2025-12-19 23:06:03 -05:00
|
|
|
mZoneHandle = aStream->ParseInt8(QString("%1 zone handle").arg(GetName()));
|
2025-09-10 21:58:26 -04:00
|
|
|
|
2025-12-19 23:06:03 -05:00
|
|
|
aStream->skipRawData(1);
|
2025-09-07 23:16:14 -04:00
|
|
|
|
2025-12-19 23:06:03 -05:00
|
|
|
mBaseTriIndex = aStream->ParseUInt16(QString("%1 base tri index").arg(GetName()));
|
|
|
|
|
mBaseVertIndex = aStream->ParseUInt16(QString("%1 base vertex index").arg(GetName()));
|
2025-09-07 23:16:14 -04:00
|
|
|
|
2025-12-19 23:06:03 -05:00
|
|
|
mTriIndices.ParsePtr(aStream, false);
|
2025-09-07 23:16:14 -04:00
|
|
|
|
2025-09-10 21:58:26 -04:00
|
|
|
mVertInfo.ParseData(aStream);
|
2025-09-07 23:16:14 -04:00
|
|
|
mVert.ParsePtr(aStream, false);
|
|
|
|
|
|
2025-12-19 23:06:03 -05:00
|
|
|
mVertListCount = aStream->ParseUInt32(QString("%1 vertex list count").arg(GetName()));
|
2025-09-07 23:16:14 -04:00
|
|
|
|
2025-12-19 23:06:03 -05:00
|
|
|
qint32 vertListPtr = aStream->ParseInt32(QString("%1 vert list ptr").arg(GetName()));
|
2025-09-07 23:16:14 -04:00
|
|
|
|
2025-12-19 23:06:03 -05:00
|
|
|
for (int i = 0; i < 4; i++)
|
2025-09-10 21:58:26 -04:00
|
|
|
{
|
2025-12-19 23:06:03 -05:00
|
|
|
mPartBits.push_back(aStream->ParseInt32(QString("%1 part bits %2").arg(GetName()).arg(i)));
|
2025-09-10 21:58:26 -04:00
|
|
|
}
|
2025-09-07 23:16:14 -04:00
|
|
|
|
2025-12-19 23:06:03 -05:00
|
|
|
mVert.ParseDataSafe(aStream);
|
2025-09-07 23:16:14 -04:00
|
|
|
|
2025-12-19 23:06:03 -05:00
|
|
|
if (vertListPtr == -1)
|
2025-09-10 21:58:26 -04:00
|
|
|
{
|
2025-12-19 23:06:03 -05:00
|
|
|
for (int i = 0; i < mVertListCount; i++)
|
|
|
|
|
{
|
|
|
|
|
XRigidVertList newVertList;
|
|
|
|
|
newVertList.ParseData(aStream);
|
|
|
|
|
mVertList.push_back(newVertList);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < mVertList.size(); i++)
|
2025-09-10 21:58:26 -04:00
|
|
|
{
|
2025-12-19 23:06:03 -05:00
|
|
|
auto collTree = mVertList[i].CollisionTree();
|
|
|
|
|
collTree.ParseDataSafe(aStream);
|
|
|
|
|
mVertList[i].SetCollisionTree(collTree);
|
2025-09-10 21:58:26 -04:00
|
|
|
}
|
|
|
|
|
}
|
2025-12-19 23:06:03 -05:00
|
|
|
|
|
|
|
|
mTriIndices.ParseDataSafe(aStream);
|
2025-09-03 13:25:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XSurface::Clear()
|
|
|
|
|
{
|
2025-12-19 23:06:03 -05:00
|
|
|
mTileMode = 0;
|
|
|
|
|
mDeformed = false;
|
|
|
|
|
mVertCount = 0;
|
|
|
|
|
mTriCount = 0;
|
|
|
|
|
mZoneHandle = 0;
|
|
|
|
|
mBaseTriIndex = 0;
|
|
|
|
|
mBaseVertIndex = 0;
|
|
|
|
|
mTriIndices.Clear();
|
|
|
|
|
mVertInfo.Clear();
|
|
|
|
|
mVert.Clear();
|
|
|
|
|
mVertListCount = 0;
|
|
|
|
|
mVertList.clear();
|
|
|
|
|
mPartBits.clear();
|
2025-09-03 13:25:58 -04:00
|
|
|
}
|