예제 #1
0
bool Anm2DAsm::makeFromEditData2Inc(EditData &rEditData, QString qsFname)
{
    qsFname = QFileInfo(qsFname).baseName().toUpper();
    m_pModel = rEditData.getObjectModel();
    if (m_bFlat)
    {
        ObjectModel *p = new ObjectModel();
        p->copy(m_pModel);
        p->flat();
        m_pModel = p;
    }

    ObjectItem *pRoot = m_pModel->getItemFromIndex(QModelIndex());
    //	ObjectItem	*pObj = pRoot->child(0);

    addString("; このファイルはAnimationCreatorにより生成されました。\n");
    addString("\n");
    for (int i = 0; i < pRoot->childCount(); i++)
    {
        ObjectItem *pObj = pRoot->child(i);
        addString("%define\t\tACO_" + qsFname + "__" + pObj->getName().replace(" ", "_").toUpper().toUtf8() + QString("\t\t%1").arg(i) + "\n");
    }
    addString("\n");
    for (int i = 0; i < pRoot->childCount(); i++)
    {
        ObjectItem *pObj = pRoot->child(i);
        QVector4D qv4AreaMin = QVector4D(FLT_MAX, FLT_MAX, FLT_MAX, 0);
        QVector4D qv4AreaMax = QVector4D(FLT_MIN, FLT_MIN, FLT_MIN, 0);
        QString qsLabel = "ACL_" + qsFname + "__" + pObj->getName().replace(" ", "_").toUpper().toUtf8() + "__";
        addString("%define\t\t" + qsLabel + "ROOT\t\t0\n");
        makeFromEditDataArea(pObj, &qv4AreaMin, &qv4AreaMax, true);
        addString("\t\t; Area:" + QString("(%1, %2, %3)-(%4, %5, %6) size:(%7, %8, %9)").arg(qv4AreaMin.x(), 0, 'f').arg(qv4AreaMin.y(), 0, 'f').arg(qv4AreaMin.z(), 0, 'f').arg(qv4AreaMax.x(), 0, 'f').arg(qv4AreaMax.y(), 0, 'f').arg(qv4AreaMax.z(), 0, 'f').arg(qv4AreaMax.x() - qv4AreaMin.x(), 0, 'f').arg(qv4AreaMax.y() - qv4AreaMin.y(), 0, 'f').arg(qv4AreaMax.z() - qv4AreaMin.z(), 0, 'f') + "\n");
        m_nCnt = 1;
        for (int j = 0; j < pObj->childCount(); j++)
        {
            ObjectItem *pChild = pObj->child(j);
            makeFromEditData2IncTip(qsLabel, pChild);
        }
        addString("\n");
    }

    return true;
}
예제 #2
0
bool Anm2DAsm::makeFromEditData(EditData &rEditData)
{
    m_pModel = rEditData.getObjectModel();
    if (m_bFlat)
    {
        ObjectModel *p = new ObjectModel();
        p->copy(m_pModel);
        p->flat();
        m_pModel = p;
    }

    ObjectItem *pRoot = m_pModel->getItemFromIndex(QModelIndex());

    // 画像をラベル化
    // 未使用画像をスキップするテーブル構築
    int nVram = 0;
    {
        for (int i = 0; i < rEditData.getImageDataListSize(); i++)
        {
            if (i >= KM_VRAM_MAX)
            {
                return false;
            }
            EditData::ImageData *p = rEditData.getImageData(i);
            if (!p)
                continue;
            QFileInfo fi(p->fileName);
            QString sImageLabel = fi.fileName();
            sImageLabel = QString("ID_") + sImageLabel.replace(".", "_").toUpper();
            sImageLabel = sImageLabel.toUtf8();
            m_aqsVramID[i] = sImageLabel;
            m_bUnused[i] = true;
        }
        for (int i = 0; i < pRoot->childCount(); i++)
        {
            ObjectItem *pObj = pRoot->child(i);
            for (int j = 0; j < pObj->childCount(); j++)
            {
                ObjectItem *pChild = pObj->child(j);
                subUnusedVramSkip(pChild);
            }
        }
        for (int i = 0; i < rEditData.getImageDataListSize(); i++)
        {
            if (m_bUnused[i] == false)
                nVram++;
        }
    }

    addString(";----------------------------------------------------------------\n");
    addString("; @kamefile\t" + pRoot->getName().toUtf8() + "\n");
    addString(";---------------------------------------------------------------- HEADER\n");
    addString("\t\t\%include\t\"../imageid.inc\"\n");
    addString("\n");
    addString(";---------------------------------------------------------------- DATA\n");
    addString("%define\t\tNO_READ\t\t0\n");
    addString("%define\t\tF32(f32)\t\t__float32__(f32)\n");
    addString("data:\n");
    addString(";---------------------------------------------------------------- ANM_HEAD\n");
    addString("\t\t\tdb\t\t'ANM0'\t\t; ANM0\n");
    addString("\t\t\tdd\t\t00000003h\t\t; uVersion\n");
    addString("\t\t\tdd\t\t" + QString("%1").arg(/*rEditData.getImageDataListSize()*/ nVram) + "\t\t; nVram\n");
    addString("\t\t\tdd\t\t.vram\t\t; pauVram\n");
    addString("\t\t\tdd\t\t" + QString("%1").arg(pRoot->childCount()) + "\t\t; nObject\n");
    addString("\t\t\tdd\t\t.object\t\t; paObj\n");
    addString("\t\n");
    addString("\t.vram:\n");
    for (int i = 0; i < rEditData.getImageDataListSize(); i++)
    {
        if (i >= KM_VRAM_MAX)
        {
            return false;
        }
        if (m_bUnused[i])
            continue;
        EditData::ImageData *p = rEditData.getImageData(i);
        if (!p)
            continue;
        QFileInfo fi(p->fileName);
        QString sImageLabel = fi.fileName();
        sImageLabel = QString("ID_") + sImageLabel.replace(".", "_").toUpper();
        sImageLabel = sImageLabel.toUtf8();
        m_aqsVramID[i] = sImageLabel;
        addString("\t\t\tdd\t\t" + m_aqsVramID[i] + "\n");
    }
    addString("\t\n");
    addString("\t.object:\n");
    for (int i = 0; i < pRoot->childCount(); i++)
    {
        addString("\t\t\tdd\t\tanmobj" + QString("%1").arg(i) + "\n");
    }
    addString("\n");
    for (int i = 0; i < pRoot->childCount(); i++)
    {
        ObjectItem *pObj = pRoot->child(i);
        QVector4D qv4AreaMin = QVector4D(FLT_MAX, FLT_MAX, FLT_MAX, 0);
        QVector4D qv4AreaMax = QVector4D(FLT_MIN, FLT_MIN, FLT_MIN, 0);
        addString(";---------------------------------------------------------------- ANM_OBJ\n");
        addString("; " + QString(pObj->getName().toUtf8()) + "\n");
        addString("anmobj" + QString("%1").arg(i) + ":\n");
        if (pObj->childCount())
        {
            if (pObj->getLoop())
            {
                addString("\t\t\tdd\t\t00000001h\t\t; bFlag\n");
            }
            else
            {
                addString("\t\t\tdd\t\t00000000h\t\t; bFlag\n");
            }
            // 最小矩形算出
            for (int j = 0; j < pObj->childCount(); j++)
            {
                ObjectItem *pChild = pObj->child(j);
                makeFromEditDataArea(pChild, &qv4AreaMin, &qv4AreaMax, true);
            }
            addString("\t\t\tdd\t\t" + QString("F32(%1), F32(%2), F32(%3), F32(%4)").arg(qv4AreaMin.x(), 0, 'f').arg(qv4AreaMin.y(), 0, 'f').arg(qv4AreaMax.x(), 0, 'f').arg(qv4AreaMax.y(), 0, 'f') + "\t\t; fvArea\n");
            addString("\t\t\tdd\t\t" + QString("%1").arg(pObj->childCount()) + "\t\t; nTip\n");
            addString("\t\t\tdd\t\t.tips\t\t; papTip\n");
            addString("\t\n");
            addString("\t.tips:\n");
            for (int j = 0; j < pObj->childCount(); j++)
            {
                addString("\t\t\tdd\t\tobj" + QString("%1").arg(i) + "tip" + QString("%1").arg(j) + "\n");
            }
            addString("\n");
            for (int j = 0; j < pObj->childCount(); j++)
            {
                QString qsLabel = "obj" + QString("%1").arg(i) + "tip" + QString("%1").arg(j);
                ObjectItem *pChild = pObj->child(j);
                if (!makeFromEditDataTip(qsLabel, pChild))
                {
                    return false;
                }
            }
        }
        else
        {
            addString("\t\t\tdd\t\t00000000h\t\t; bFlag\n");
            addString("\t\t\tdd\t\t0, 0, 0, 0\t\t; fvArea\n");
            addString("\t\t\tdd\t\t" + QString("%1").arg(pObj->childCount()) + "\t\t; nTip\n");
            addString("\t\t\tdd\t\tNO_READ\t\t; papTip\n");
        }
    }
    addString("\n");

    return true;
}