65 lines
1.8 KiB
C++
65 lines
1.8 KiB
C++
#include "xsurfacecollisiontree.h"
|
|
|
|
XSurfaceCollisionTree::XSurfaceCollisionTree()
|
|
: XAsset()
|
|
, mTrans()
|
|
, mScale()
|
|
, mNodeCount(0)
|
|
, mNodes()
|
|
, mLeafCount(0)
|
|
, mLeafs()
|
|
{
|
|
SetName("Surface Collision Tree");
|
|
}
|
|
|
|
void XSurfaceCollisionTree::ParseData(XDataStream *aStream)
|
|
{
|
|
mTrans.setX(aStream->ParseSingle(QString("%1 transformation x").arg(GetName())));
|
|
mTrans.setY(aStream->ParseSingle(QString("%1 transformation y").arg(GetName())));
|
|
mTrans.setZ(aStream->ParseSingle(QString("%1 transformation z").arg(GetName())));
|
|
|
|
mScale.setX(aStream->ParseSingle(QString("%1 scale x").arg(GetName())));
|
|
mScale.setY(aStream->ParseSingle(QString("%1 scale y").arg(GetName())));
|
|
mScale.setZ(aStream->ParseSingle(QString("%1 scale z").arg(GetName())));
|
|
|
|
mNodeCount = aStream->ParseUInt32(QString("%1 node count").arg(GetName()));
|
|
qint32 nodesPtr = aStream->ParseInt32(QString("%1 nodes ptr").arg(GetName()));
|
|
mLeafCount = aStream->ParseUInt32(QString("%1 leaf count").arg(GetName()));
|
|
qint32 leafsPtr = aStream->ParseInt32(QString("%1 leafs ptr").arg(GetName()));
|
|
|
|
if (nodesPtr)
|
|
{
|
|
for (quint32 i = 0; i < mNodeCount; i++)
|
|
{
|
|
XSurfaceCollisionNode newNode;
|
|
newNode.ParseData(aStream);
|
|
mNodes.push_back(newNode);
|
|
}
|
|
}
|
|
if (leafsPtr)
|
|
{
|
|
for (quint32 i = 0; i < mLeafCount; i++)
|
|
{
|
|
XSurfaceCollisionLeaf newLeaf;
|
|
newLeaf.ParseData(aStream);
|
|
mLeafs.push_back(newLeaf);
|
|
}
|
|
|
|
// TODO: Figure out if this is necessary
|
|
if (mLeafCount % 2 != 0)
|
|
{
|
|
//aStream->skipRawData(2);
|
|
}
|
|
}
|
|
}
|
|
|
|
void XSurfaceCollisionTree::Clear()
|
|
{
|
|
mTrans = QVector3D();
|
|
mScale = QVector3D();
|
|
mNodeCount = 0;
|
|
mNodes.clear();
|
|
mLeafCount = 0;
|
|
mLeafs.clear();
|
|
}
|