#include "xcstaticmodel.h"

XCStaticModel::XCStaticModel()
    : XAsset()
    , mWritable()
    , mModel()
    , mOrigin()
    , mInvScaledAxis()
    , mAbsmin()
    , mAbsmax()
{
    SetName("C Static Model");
}

XCStaticModel::~XCStaticModel()
{

}

void XCStaticModel::ParseData(XDataStream *aStream)
{
    if (GetPtr() == -1)
    {
        mWritable.ParseData(aStream);

        aStream->skipRawData(2);

        qint32 xModelPtr = aStream->ParseInt32(QString("%1 model ptr").arg(GetName()));

        mOrigin.setX(aStream->ParseSingle(QString("%1 origin x").arg(GetName())));
        mOrigin.setY(aStream->ParseSingle(QString("%1 origin y").arg(GetName())));
        mOrigin.setZ(aStream->ParseSingle(QString("%1 origin z").arg(GetName())));

        if (xModelPtr)
        {
            mModel.ParsePtr(aStream, false);
            mModel.ParseData(aStream);
        }

        for (int i = 0; i < 3; ++i)
        {
            mInvScaledAxis[i].setX(aStream->ParseSingle(QString("%1 inv scaled axis[%2] x").arg(GetName()).arg(i)));
            mInvScaledAxis[i].setY(aStream->ParseSingle(QString("%1 inv scaled axis[%2] y").arg(GetName()).arg(i)));
            mInvScaledAxis[i].setZ(aStream->ParseSingle(QString("%1 inv scaled axis[%2] z").arg(GetName()).arg(i)));
        }

        mAbsmin.setX(aStream->ParseSingle(QString("%1 absmin x").arg(GetName())));
        mAbsmin.setY(aStream->ParseSingle(QString("%1 absmin y").arg(GetName())));
        mAbsmin.setZ(aStream->ParseSingle(QString("%1 absmin z").arg(GetName())));

        mAbsmax.setX(aStream->ParseSingle(QString("%1 absmax x").arg(GetName())));
        mAbsmax.setY(aStream->ParseSingle(QString("%1 absmax y").arg(GetName())));
        mAbsmax.setZ(aStream->ParseSingle(QString("%1 absmax z").arg(GetName())));
    }
}

void XCStaticModel::Clear()
{

}
