#include "mainwindow.h" #include "ui_mainwindow.h" #include #include #include struct TBoneStruct { float v[3]; float q[4]; float len; QString parentBoneName; }; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QObject::connect(ui->ConvertAn1, SIGNAL(clicked()), this, SLOT(CallConvertAn1())); QObject::connect(ui->ConvertBn1, SIGNAL(clicked()), this, SLOT(CallConvertBn1())); } MainWindow::~MainWindow() { delete ui; } void MainWindow::CallConvertAn1() { QFileDialog dialog(this); dialog.setFileMode(QFileDialog::AnyFile); dialog.setAcceptMode(QFileDialog::AcceptOpen); if (dialog.exec()) { QMessageBox msgBox1; msgBox1.setText("Begin"); msgBox1.exec(); QFile file(dialog.selectedFiles()[0]); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox msgBox; msgBox.setText("Fail"); msgBox.exec(); return; } QFileDialog dialogSave(this); dialogSave.setFileMode(QFileDialog::AnyFile); dialogSave.setAcceptMode(QFileDialog::AcceptSave); if (!dialogSave.exec()) { return; } QByteArray saveArr; QFile saveFile(dialogSave.selectedFiles()[0]); if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { QMessageBox msgBox; msgBox.setText("Fail"); msgBox.exec(); return; } QTextStream in(&file); QString line; //======= Go file parsing saveArr.push_back('A'); saveArr.push_back('N'); saveArr.push_back((char)0); saveArr.push_back((char)1); line = in.readLine(); int frameCount = line.remove("Frames ").toInt(); line = in.readLine(); int boneCount = line.remove("Bones ").toInt(); saveArr.insert(saveArr.size(), (char*)&boneCount, 4); saveArr.insert(saveArr.size(), (char*)&frameCount, 4); QStringList splited; float v[3]; float q[4]; float len; for (int i=0; i boneNameMap; //======= Go file parsing line = in.readLine(); boneCount = line.remove("Bones ").toInt(); std::vector boneStructMap; for (int i=0; i