first blood
This commit is contained in:
parent
78b528c0af
commit
91d5cabd26
163
AnimationBuilder/Animation.cpp
Normal file
163
AnimationBuilder/Animation.cpp
Normal file
@ -0,0 +1,163 @@
|
||||
#include "Animation.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
TAnimation::TAnimation(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void TAnimation::SetMainWindow(MainWindow* window)
|
||||
{
|
||||
Window = window;
|
||||
}
|
||||
|
||||
|
||||
void TAnimation::AddFrame(const TFrame& frame)
|
||||
{
|
||||
FrameList.push_back(frame);
|
||||
}
|
||||
|
||||
|
||||
TFrame& TAnimation::GetFrame(int i)
|
||||
{
|
||||
return FrameList[i];
|
||||
}
|
||||
|
||||
size_t TAnimation::GetFrameCount()
|
||||
{
|
||||
return FrameList.size();
|
||||
}
|
||||
|
||||
int TAnimation::GetMaxWidth()
|
||||
{
|
||||
int r = FrameList[0].Pixmap->width() + FrameList[0].ShiftX;
|
||||
|
||||
for (size_t i = 1; i < FrameList.size(); i++)
|
||||
{
|
||||
if (r < FrameList[i].Pixmap->width() + FrameList[i].ShiftX)
|
||||
{
|
||||
r = FrameList[i].Pixmap->width() + FrameList[i].ShiftX;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int TAnimation::GetMaxHeight()
|
||||
{
|
||||
int r = FrameList[0].Pixmap->height() + FrameList[0].ShiftY;
|
||||
|
||||
for (size_t i = 1; i < FrameList.size(); i++)
|
||||
{
|
||||
if (r < FrameList[i].Pixmap->height() + FrameList[i].ShiftY)
|
||||
{
|
||||
r = FrameList[i].Pixmap->height() + FrameList[i].ShiftY;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
void TAnimation::FillSheet(boost::shared_ptr<QPixmap> sheetPixmap, std::vector<TFrameData>& frameDataArr)
|
||||
{
|
||||
int maxFrameWidth = GetMaxWidth();
|
||||
int maxFrameHeight = GetMaxHeight();
|
||||
|
||||
int cursorX = 0;
|
||||
int cursorY = 0;
|
||||
|
||||
|
||||
|
||||
QPainter p;
|
||||
|
||||
|
||||
p.begin(&(*sheetPixmap));
|
||||
|
||||
|
||||
for (size_t i=0; i<FrameList.size(); i++)
|
||||
{
|
||||
int shiftX = FrameList[i].ShiftX;
|
||||
int shiftY = FrameList[i].ShiftY;
|
||||
|
||||
|
||||
TFrameData frameData;
|
||||
|
||||
frameData.TexCoordFromX = static_cast<float>(cursorX) / sheetPixmap->width();
|
||||
frameData.TexCoordFromY = 1.f - static_cast<float>(cursorY + maxFrameHeight) / sheetPixmap->height();
|
||||
|
||||
frameData.TexCoordToX = static_cast<float>(cursorX + maxFrameWidth) / sheetPixmap->width();
|
||||
frameData.TexCoordToY = 1.f - static_cast<float>(cursorY) / sheetPixmap->height();
|
||||
|
||||
frameData.TimeToPlay = FrameList[i].TimeToPlay;
|
||||
|
||||
frameDataArr.push_back(frameData);
|
||||
|
||||
|
||||
|
||||
|
||||
QPixmap& pixmapToDraw = *(FrameList[i].Pixmap);
|
||||
|
||||
p.drawPixmap(cursorX + shiftX, cursorY + shiftY, pixmapToDraw);
|
||||
|
||||
cursorX += maxFrameWidth;
|
||||
|
||||
if (cursorX + maxFrameWidth >= sheetPixmap->width())
|
||||
{
|
||||
cursorX = 0;
|
||||
cursorY += maxFrameHeight;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
p.end();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TAnimation::LoadFrame()
|
||||
{
|
||||
QFileDialog dialog(Window);
|
||||
|
||||
dialog.setFileMode(QFileDialog::ExistingFiles);
|
||||
|
||||
dialog.setNameFilter("PNG images (*.png)");
|
||||
|
||||
if (dialog.exec())
|
||||
{
|
||||
|
||||
QStringList fileNames = dialog.selectedFiles();
|
||||
|
||||
for (int i = 0; i < fileNames.count(); i++)
|
||||
{
|
||||
boost::shared_ptr<QPixmap> pixmap(new QPixmap(fileNames[i], "PNG"));
|
||||
|
||||
QFileInfo q;
|
||||
q.setFile(fileNames[i]);
|
||||
|
||||
QString fn = q.fileName();
|
||||
|
||||
std::string fileName = fn.toUtf8().constData();
|
||||
|
||||
AddFrame(TFrame(pixmap, 0, fileName));
|
||||
|
||||
Window->LoadFrame(fileName);
|
||||
}
|
||||
|
||||
//FontFileName = (dialog.selectedFiles())[0];
|
||||
//emit SetFontNameTextSignal(FontFileName);
|
||||
|
||||
//LoadFontFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
111
AnimationBuilder/Animation.h
Normal file
111
AnimationBuilder/Animation.h
Normal file
@ -0,0 +1,111 @@
|
||||
#ifndef ANIMATION_H
|
||||
#define ANIMATION_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QGraphicsScene>
|
||||
#include <QPicture>
|
||||
#include <QPainter>
|
||||
#include <QMainWindow>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include "boost/shared_ptr.hpp"
|
||||
|
||||
|
||||
struct TFrame
|
||||
{
|
||||
boost::shared_ptr<QPixmap> Pixmap;
|
||||
size_t TimeToPlay;
|
||||
std::string FrameName;
|
||||
int ShiftX;
|
||||
int ShiftY;
|
||||
|
||||
TFrame(boost::shared_ptr<QPixmap> pixmap, size_t timeToPlay, const std::string& frameName)
|
||||
: Pixmap(pixmap)
|
||||
, TimeToPlay(timeToPlay)
|
||||
, FrameName(frameName)
|
||||
, ShiftX(0)
|
||||
, ShiftY(0)
|
||||
{
|
||||
}
|
||||
|
||||
TFrame(const TFrame& frame)
|
||||
{
|
||||
Pixmap = frame.Pixmap;
|
||||
TimeToPlay = frame.TimeToPlay;
|
||||
FrameName = frame.FrameName;
|
||||
ShiftX = frame.ShiftX;
|
||||
ShiftY = frame.ShiftY;
|
||||
}
|
||||
|
||||
TFrame& operator=(const TFrame& frame)
|
||||
{
|
||||
if (&frame == this)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
Pixmap = frame.Pixmap;
|
||||
TimeToPlay = frame.TimeToPlay;
|
||||
FrameName = frame.FrameName;
|
||||
ShiftX = frame.ShiftX;
|
||||
ShiftY = frame.ShiftY;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TFrameData
|
||||
{
|
||||
float TexCoordFromX;
|
||||
float TexCoordFromY;
|
||||
float TexCoordToX;
|
||||
float TexCoordToY;
|
||||
size_t TimeToPlay;
|
||||
};
|
||||
|
||||
class MainWindow;
|
||||
|
||||
|
||||
|
||||
|
||||
class TAnimation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
|
||||
std::vector<TFrame> FrameList;
|
||||
|
||||
MainWindow* Window;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
explicit TAnimation(QObject *parent = 0);
|
||||
|
||||
void SetMainWindow(MainWindow* window);
|
||||
|
||||
void AddFrame(const TFrame& frame);
|
||||
|
||||
TFrame& GetFrame(int i);
|
||||
size_t GetFrameCount();
|
||||
|
||||
int GetMaxWidth();
|
||||
int GetMaxHeight();
|
||||
|
||||
void FillSheet(boost::shared_ptr<QPixmap> sheetPixmap, std::vector<TFrameData>& frameDataArr);
|
||||
|
||||
|
||||
public slots:
|
||||
void LoadFrame();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // ANIMATION_H
|
23
AnimationBuilder/AnimationBuilder.pro
Normal file
23
AnimationBuilder/AnimationBuilder.pro
Normal file
@ -0,0 +1,23 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2012-04-19T21:10:48
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
TARGET = AnimationBuilder
|
||||
TEMPLATE = app
|
||||
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
Animation.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
Animation.h
|
||||
|
||||
INCLUDEPATH += $$(LibsPath)/boost_1_47_0
|
||||
DEPENDPATH += $$(LibsPath)/boost_1_47_0
|
||||
|
||||
FORMS += mainwindow.ui
|
19
AnimationBuilder/main.cpp
Normal file
19
AnimationBuilder/main.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include <QtGui/QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
TAnimation Animation;
|
||||
|
||||
MainWindow w;
|
||||
|
||||
w.SetAnimation(&Animation);
|
||||
Animation.SetMainWindow(&w);
|
||||
|
||||
w.show();
|
||||
|
||||
|
||||
return a.exec();
|
||||
}
|
294
AnimationBuilder/mainwindow.cpp
Normal file
294
AnimationBuilder/mainwindow.cpp
Normal file
@ -0,0 +1,294 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
//Animation.SetMainWindow(this);
|
||||
|
||||
frameImageDefaultPosX = ui->FrameImage->pos().x();
|
||||
frameImageDefaultPosY = ui->FrameImage->pos().y();
|
||||
|
||||
//int sheetDefaultWidth = (ui->SheetWidth->text()).toInt();
|
||||
//int sheetDefaultHeight = (ui->SheetHeight->text()).toInt();
|
||||
|
||||
SheetPixmap = boost::shared_ptr<QPixmap>(new QPixmap(4, 4));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
int MainWindow::GetSelectedFrame()
|
||||
{
|
||||
QListWidgetItem * item = *(ui->FrameList->selectedItems().begin());
|
||||
|
||||
int it=0;
|
||||
|
||||
for (int i=0; i<ui->FrameList->count(); i++)
|
||||
{
|
||||
if (ui->FrameList->item(i) == item)
|
||||
{
|
||||
it = i;
|
||||
}
|
||||
}
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
void MainWindow::SetAnimation(TAnimation* animation)
|
||||
{
|
||||
Animation = animation;
|
||||
|
||||
QObject::connect(ui->LoadFrameButton, SIGNAL(pressed()), Animation, SLOT(LoadFrame()));
|
||||
QObject::connect(ui->FrameList, SIGNAL(itemSelectionChanged()), this, SLOT(ItemClicked()));
|
||||
QObject::connect(ui->ShiftX_spinBox, SIGNAL(valueChanged(int)), this, SLOT(ShiftXChanged(int)));
|
||||
QObject::connect(ui->ShiftY_spinBox, SIGNAL(valueChanged(int)), this, SLOT(ShiftYChanged(int)));
|
||||
QObject::connect(ui->TimeFrameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(TimeFrameChanged(const QString&)));
|
||||
QObject::connect(ui->GenerateTimeButton, SIGNAL(pressed()), this, SLOT(GenerateTimeFrameBy12Fps()));
|
||||
QObject::connect(ui->GenerateSheetButton, SIGNAL(pressed()), this, SLOT(GenerateSheet()));
|
||||
QObject::connect(ui->SaveSheetButton, SIGNAL(pressed()), this, SLOT(SaveSheet()));
|
||||
QObject::connect(ui->SaveAnimParamsButton, SIGNAL(pressed()), this, SLOT(SaveAnimationParams()));
|
||||
QObject::connect(ui->AnimateCheckBox, SIGNAL(stateChanged(int)), this, SLOT(AnimateCheckBoxStateChanged(int)));
|
||||
QObject::connect(&AnimTimer, SIGNAL(timeout()), this, SLOT(TimerTimeout()));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::ItemClicked()
|
||||
{
|
||||
SelectFrame(GetSelectedFrame());
|
||||
}
|
||||
|
||||
void MainWindow::ShiftXChanged(int val)
|
||||
{
|
||||
int i = GetSelectedFrame();
|
||||
|
||||
Animation->GetFrame(i).ShiftX = val;
|
||||
|
||||
ItemClicked();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::ShiftYChanged(int val)
|
||||
{
|
||||
int i = GetSelectedFrame();
|
||||
|
||||
Animation->GetFrame(i).ShiftY = val;
|
||||
|
||||
ItemClicked();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::TimeFrameChanged(const QString& str)
|
||||
{
|
||||
bool ok;
|
||||
|
||||
int timeFrame = str.toInt(&ok);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
int i = GetSelectedFrame();
|
||||
|
||||
Animation->GetFrame(i).TimeToPlay = timeFrame;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::GenerateTimeFrameBy12Fps()
|
||||
{
|
||||
float timeStep = 1000.f / 12.f;
|
||||
|
||||
int frameCount = ui->FrameList->count();
|
||||
|
||||
for (int i=0; i<frameCount; i++)
|
||||
{
|
||||
int totalTime = static_cast<int>(timeStep * (i + 1));
|
||||
|
||||
Animation->GetFrame(i).TimeToPlay = totalTime;
|
||||
|
||||
}
|
||||
|
||||
|
||||
ItemClicked();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::GenerateSheet()
|
||||
{
|
||||
int sheetWidth = (ui->SheetWidth->text()).toInt();
|
||||
int sheetHeight = (ui->SheetHeight->text()).toInt();
|
||||
|
||||
std::vector<TFrameData> frameDataArr;
|
||||
|
||||
SheetPixmap = boost::shared_ptr<QPixmap>(new QPixmap(sheetWidth, sheetHeight));
|
||||
|
||||
QColor transparentColor(0,0,0,0);
|
||||
|
||||
SheetPixmap->fill(transparentColor);
|
||||
|
||||
Animation->FillSheet(SheetPixmap, frameDataArr);
|
||||
|
||||
ui->PixmapSheet->setPixmap(*SheetPixmap);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ui->OutputXmlFile->clear();
|
||||
|
||||
AnimationParamsText = "<Animation>\n\t<Frames>\n";
|
||||
|
||||
for (size_t i = 0; i < frameDataArr.size(); i++)
|
||||
{
|
||||
AnimationParamsText += QString("\t\t<Frame><TexCoordFrom x='%1' y='%2'/><TexCoordTo x='%3' y='%4'/><TimePassed>%5</TimePassed></Frame>\n")
|
||||
.arg(QString::number(frameDataArr[i].TexCoordFromX))
|
||||
.arg(QString::number(frameDataArr[i].TexCoordFromY))
|
||||
.arg(QString::number(frameDataArr[i].TexCoordToX))
|
||||
.arg(QString::number(frameDataArr[i].TexCoordToY))
|
||||
.arg(QString::number(frameDataArr[i].TimeToPlay));
|
||||
}
|
||||
|
||||
AnimationParamsText += "\t</Frames>\n</Animation>";
|
||||
ui->OutputXmlFile->appendPlainText(AnimationParamsText);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::SaveSheet()
|
||||
{
|
||||
QFileDialog dialog(this);
|
||||
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
|
||||
dialog.setNameFilter("PNG images (*.png)");
|
||||
|
||||
dialog.setDefaultSuffix("png");
|
||||
|
||||
if (dialog.exec())
|
||||
{
|
||||
QString fileName = *(dialog.selectedFiles().begin());
|
||||
|
||||
SheetPixmap->save(fileName, "PNG");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::SaveAnimationParams()
|
||||
{
|
||||
QFileDialog dialog(this);
|
||||
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
|
||||
dialog.setNameFilter("XML files (*.xml)");
|
||||
|
||||
dialog.setDefaultSuffix("xml");
|
||||
|
||||
if (dialog.exec())
|
||||
{
|
||||
QString fileName = *(dialog.selectedFiles().begin());
|
||||
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
QTextStream outStream(&file);
|
||||
outStream << AnimationParamsText;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::AnimateCheckBoxStateChanged(int state)
|
||||
{
|
||||
if (state == Qt::Checked)
|
||||
{
|
||||
currentFrameOnTimer = 0;
|
||||
|
||||
|
||||
|
||||
AnimTimer.setInterval(Animation->GetFrame(currentFrameOnTimer).TimeToPlay);
|
||||
AnimTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
AnimTimer.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::TimerTimeout()
|
||||
{
|
||||
|
||||
|
||||
int prevFrameTime = Animation->GetFrame(currentFrameOnTimer).TimeToPlay;
|
||||
|
||||
currentFrameOnTimer++;
|
||||
|
||||
if (currentFrameOnTimer >= Animation->GetFrameCount())
|
||||
{
|
||||
currentFrameOnTimer = 0;
|
||||
}
|
||||
|
||||
TFrame& frame = Animation->GetFrame(currentFrameOnTimer);
|
||||
|
||||
int timeToPlay = frame.TimeToPlay - prevFrameTime;
|
||||
|
||||
if (timeToPlay < 0)
|
||||
{
|
||||
timeToPlay = 0;
|
||||
}
|
||||
|
||||
|
||||
int newPosX = frameImageDefaultPosX + frame.ShiftX;
|
||||
int newPosY = frameImageDefaultPosY + frame.ShiftY;
|
||||
|
||||
ui->FrameImage->move(newPosX, newPosY);
|
||||
ui->FrameImage->setPixmap(*(frame.Pixmap));
|
||||
|
||||
AnimTimer.setInterval(timeToPlay);
|
||||
AnimTimer.start();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::SelectFrame(int i)
|
||||
{
|
||||
TFrame& frame = Animation->GetFrame(i);
|
||||
|
||||
ui->FrameImage->setPixmap(*(frame.Pixmap));
|
||||
|
||||
int newPosX = frameImageDefaultPosX + frame.ShiftX;
|
||||
int newPosY = frameImageDefaultPosY + frame.ShiftY;
|
||||
|
||||
ui->FrameImage->move(newPosX, newPosY);
|
||||
|
||||
ui->ShiftX_spinBox->setValue(frame.ShiftX);
|
||||
ui->ShiftY_spinBox->setValue(frame.ShiftY);
|
||||
|
||||
ui->TimeFrameEdit->setText(QString::number(frame.TimeToPlay));
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::LoadFrame(const std::string& text)
|
||||
{
|
||||
ui->FrameList->addItem(QString(text.c_str()));
|
||||
|
||||
}
|
66
AnimationBuilder/mainwindow.h
Normal file
66
AnimationBuilder/mainwindow.h
Normal file
@ -0,0 +1,66 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QListWidget>
|
||||
#include <QTextStream>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
#include "Animation.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
void SetAnimation(TAnimation* animation);
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
void SelectFrame(int i);
|
||||
void LoadFrame(const std::string& text);
|
||||
void ItemClicked();
|
||||
|
||||
void ShiftXChanged(int val);
|
||||
void ShiftYChanged(int val);
|
||||
void TimeFrameChanged(const QString& str);
|
||||
|
||||
void GenerateTimeFrameBy12Fps();
|
||||
void GenerateSheet();
|
||||
|
||||
void SaveSheet();
|
||||
void SaveAnimationParams();
|
||||
|
||||
void AnimateCheckBoxStateChanged(int state);
|
||||
void TimerTimeout();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
TAnimation* Animation;
|
||||
|
||||
int frameImageDefaultPosX;
|
||||
int frameImageDefaultPosY;
|
||||
|
||||
boost::shared_ptr<QPixmap> SheetPixmap;
|
||||
QString AnimationParamsText;
|
||||
|
||||
QTimer AnimTimer;
|
||||
int currentFrameOnTimer;
|
||||
|
||||
int GetSelectedFrame();
|
||||
|
||||
//void SetTimerToNextFrame();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
390
AnimationBuilder/mainwindow.ui
Normal file
390
AnimationBuilder/mainwindow.ui
Normal file
@ -0,0 +1,390 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>700</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>631</width>
|
||||
<height>442</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>700</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>AnimationBuilder</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QPushButton" name="LoadFrameButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>111</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add frames...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>60</y>
|
||||
<width>171</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<widget class="QLabel" name="FrameImage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>151</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="FrameList">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>151</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="ShiftX_spinBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>490</x>
|
||||
<y>60</y>
|
||||
<width>42</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="ShiftY_spinBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>490</x>
|
||||
<y>90</y>
|
||||
<width>42</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>410</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>shift on X:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>410</x>
|
||||
<y>90</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>shift on Y:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="TimeFrameEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>490</x>
|
||||
<y>120</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>410</x>
|
||||
<y>120</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>time to play:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="SheetWidth">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>260</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>512</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="SheetHeight">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>290</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>256</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>260</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sheet width:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>290</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sheet height:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="GenerateSheetButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>320</y>
|
||||
<width>131</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Generate sheet</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="GenerateTimeButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<y>150</y>
|
||||
<width>141</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Generate by 12 fps</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="PixmapSheet">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>250</y>
|
||||
<width>512</width>
|
||||
<height>256</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>250</y>
|
||||
<width>511</width>
|
||||
<height>261</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPlainTextEdit" name="OutputXmlFile">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>350</y>
|
||||
<width>141</width>
|
||||
<height>121</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="SaveSheetButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>480</y>
|
||||
<width>131</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save sheet...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="SaveAnimParamsButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>510</y>
|
||||
<width>131</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save anim params...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="AnimateCheckBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>230</y>
|
||||
<width>70</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Animate</string>
|
||||
</property>
|
||||
</widget>
|
||||
<zorder>frame_2</zorder>
|
||||
<zorder>LoadFrameButton</zorder>
|
||||
<zorder>frame</zorder>
|
||||
<zorder>FrameList</zorder>
|
||||
<zorder>ShiftX_spinBox</zorder>
|
||||
<zorder>ShiftY_spinBox</zorder>
|
||||
<zorder>label</zorder>
|
||||
<zorder>label_2</zorder>
|
||||
<zorder>TimeFrameEdit</zorder>
|
||||
<zorder>label_3</zorder>
|
||||
<zorder>SheetWidth</zorder>
|
||||
<zorder>SheetHeight</zorder>
|
||||
<zorder>label_4</zorder>
|
||||
<zorder>label_5</zorder>
|
||||
<zorder>GenerateSheetButton</zorder>
|
||||
<zorder>GenerateTimeButton</zorder>
|
||||
<zorder>PixmapSheet</zorder>
|
||||
<zorder>OutputXmlFile</zorder>
|
||||
<zorder>SaveSheetButton</zorder>
|
||||
<zorder>SaveAnimParamsButton</zorder>
|
||||
<zorder>AnimateCheckBox</zorder>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>700</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
18
Bn1An1Converter/Bn1An1Converter.pro
Normal file
18
Bn1An1Converter/Bn1An1Converter.pro
Normal file
@ -0,0 +1,18 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2012-06-01T11:21:21
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
TARGET = Bn1An1Converter
|
||||
TEMPLATE = app
|
||||
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += mainwindow.h
|
||||
|
||||
FORMS += mainwindow.ui
|
11
Bn1An1Converter/main.cpp
Normal file
11
Bn1An1Converter/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <QtGui/QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
387
Bn1An1Converter/mainwindow.cpp
Normal file
387
Bn1An1Converter/mainwindow.cpp
Normal file
@ -0,0 +1,387 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QTextStream>
|
||||
|
||||
|
||||
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<frameCount; i++)
|
||||
{
|
||||
|
||||
line = in.readLine();
|
||||
|
||||
for (int j=0; j<boneCount; j++)
|
||||
{
|
||||
|
||||
line = in.readLine();
|
||||
splited = line.split(" ", QString::SkipEmptyParts);
|
||||
|
||||
v[0] = splited.at(0).toFloat()*0.1;
|
||||
v[1] = splited.at(2).toFloat()*0.1;
|
||||
v[2] = -splited.at(1).toFloat()*0.1;
|
||||
|
||||
line = in.readLine();
|
||||
splited = line.split(" ", QString::SkipEmptyParts);
|
||||
|
||||
q[0] = splited.at(0).toFloat();
|
||||
q[1] = splited.at(2).toFloat();
|
||||
q[2] = -splited.at(1).toFloat();
|
||||
q[3] = splited.at(3).toFloat();
|
||||
|
||||
line = in.readLine();
|
||||
len = line.toFloat()*0.1;
|
||||
|
||||
saveArr.insert(saveArr.size(), (char*)v, 12);
|
||||
saveArr.insert(saveArr.size(), (char*)q, 16);
|
||||
saveArr.insert(saveArr.size(), (char*)&len, 4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
saveFile.write(saveArr);
|
||||
|
||||
//======= End file parsing
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("End");
|
||||
msgBox.exec();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::CallConvertBn1()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
saveArr.push_back('B');
|
||||
saveArr.push_back('N');
|
||||
saveArr.push_back((char)0);
|
||||
saveArr.push_back((char)2);
|
||||
|
||||
|
||||
QTextStream in(&file);
|
||||
QString line;
|
||||
|
||||
int boneCount;
|
||||
|
||||
QString boneName;
|
||||
QString parentBoneName;
|
||||
|
||||
float v[3];
|
||||
float q[4];
|
||||
|
||||
float len;
|
||||
|
||||
QStringList splited;
|
||||
|
||||
std::map<QString, int> boneNameMap;
|
||||
|
||||
//======= Go file parsing
|
||||
|
||||
line = in.readLine();
|
||||
|
||||
boneCount = line.remove("Bones ").toInt();
|
||||
|
||||
std::vector<TBoneStruct> boneStructMap;
|
||||
|
||||
for (int i=0; i<boneCount; i++)
|
||||
{
|
||||
|
||||
TBoneStruct b;
|
||||
|
||||
line = in.readLine();
|
||||
boneName = line;
|
||||
|
||||
boneNameMap[boneName] = i;
|
||||
|
||||
line = in.readLine();
|
||||
splited = line.split(" ", QString::SkipEmptyParts);
|
||||
|
||||
b.v[0] = splited.at(0).toFloat()*0.1;
|
||||
b.v[1] = splited.at(2).toFloat()*0.1;
|
||||
b.v[2] = -splited.at(1).toFloat()*0.1;
|
||||
|
||||
line = in.readLine();
|
||||
splited = line.split(" ", QString::SkipEmptyParts);
|
||||
|
||||
b.q[0] = splited.at(0).toFloat();
|
||||
b.q[1] = splited.at(2).toFloat();
|
||||
b.q[2] = -splited.at(1).toFloat();
|
||||
b.q[3] = splited.at(3).toFloat();
|
||||
|
||||
line = in.readLine();
|
||||
b.len = line.toFloat()*0.1;
|
||||
|
||||
line = in.readLine();
|
||||
b.parentBoneName = line;
|
||||
|
||||
boneStructMap.push_back(b);
|
||||
|
||||
/*
|
||||
saveArr.insert(saveArr.size(), (char*)v, 12);
|
||||
saveArr.insert(saveArr.size(), (char*)q, 16);
|
||||
|
||||
saveArr.insert(saveArr.size(), (char*)&len, 4);
|
||||
|
||||
saveArr.insert(saveArr.size(), (char*)&len, 4);*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
line = in.readLine();
|
||||
|
||||
int vertexCount = line.remove("Vertices ").toInt();
|
||||
|
||||
saveArr.insert(saveArr.size(), (char*)&boneCount, 4);
|
||||
saveArr.insert(saveArr.size(), (char*)&vertexCount, 4);
|
||||
|
||||
for (int i=0; i<boneCount; i++)
|
||||
{
|
||||
|
||||
saveArr.insert(saveArr.size(), (char*)boneStructMap[i].v, 12);
|
||||
saveArr.insert(saveArr.size(), (char*)boneStructMap[i].q, 16);
|
||||
|
||||
saveArr.insert(saveArr.size(), (char*)&boneStructMap[i].len, 4);
|
||||
|
||||
int parentBoneIndex;
|
||||
if (boneNameMap.count(boneStructMap[i].parentBoneName) == 0)
|
||||
{
|
||||
parentBoneIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
parentBoneIndex = boneNameMap[boneStructMap[i].parentBoneName];
|
||||
}
|
||||
saveArr.insert(saveArr.size(), (char*)&parentBoneIndex, 4);
|
||||
}
|
||||
|
||||
int wcount;
|
||||
float weight;
|
||||
|
||||
for (int i=0; i<vertexCount; i++)
|
||||
{
|
||||
line = in.readLine();
|
||||
wcount = line.remove("WCount ").toInt();
|
||||
|
||||
saveArr.insert(saveArr.size(), (char*)&wcount, 4);
|
||||
|
||||
|
||||
for (int j=0; j<wcount; j++)
|
||||
{
|
||||
line = in.readLine();
|
||||
int lastSpacebarPos = line.lastIndexOf(" ");
|
||||
line[lastSpacebarPos] = '|';
|
||||
splited = line.split("|", QString::SkipEmptyParts);
|
||||
boneName = splited.at(0);
|
||||
weight = splited.at(1).toFloat();
|
||||
|
||||
int boneIndex = boneNameMap[boneName];
|
||||
|
||||
saveArr.insert(saveArr.size(), (char*)&boneIndex, 4);
|
||||
saveArr.insert(saveArr.size(), (char*)&weight, 4);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
line = in.readLine();
|
||||
|
||||
int frameCount = line.remove("Frames ").toInt();
|
||||
|
||||
line = in.readLine();
|
||||
|
||||
int boneCount = line.remove("Bones ").toInt();
|
||||
|
||||
QStringList splited;
|
||||
|
||||
float v[3];
|
||||
float q[4];
|
||||
|
||||
float len;
|
||||
|
||||
for (int i=0; i<frameCount; i++)
|
||||
{
|
||||
|
||||
line = in.readLine();
|
||||
|
||||
for (int j=0; j<boneCount; j++)
|
||||
{
|
||||
|
||||
line = in.readLine();
|
||||
splited = line.split(" ", QString::SkipEmptyParts);
|
||||
|
||||
v[0] = splited.at(0).toFloat();
|
||||
v[1] = splited.at(1).toFloat();
|
||||
v[2] = splited.at(2).toFloat();
|
||||
|
||||
line = in.readLine();
|
||||
splited = line.split(" ", QString::SkipEmptyParts);
|
||||
|
||||
q[0] = splited.at(0).toFloat();
|
||||
q[1] = splited.at(1).toFloat();
|
||||
q[2] = splited.at(2).toFloat();
|
||||
q[3] = splited.at(3).toFloat();
|
||||
|
||||
line = in.readLine();
|
||||
len = line.toFloat();
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
saveFile.write(saveArr);
|
||||
|
||||
//======= End file parsing
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("End");
|
||||
msgBox.exec();
|
||||
|
||||
|
||||
}
|
||||
}
|
26
Bn1An1Converter/mainwindow.h
Normal file
26
Bn1An1Converter/mainwindow.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void CallConvertAn1();
|
||||
void CallConvertBn1();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
67
Bn1An1Converter/mainwindow.ui
Normal file
67
Bn1An1Converter/mainwindow.ui
Normal file
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QPushButton" name="ConvertAn1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>121</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Convert An1</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ConvertBn1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>121</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Convert Bn1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
BIN
FreeTypeWorker-win/release/FreeTypeWorker.exe
Normal file
BIN
FreeTypeWorker-win/release/FreeTypeWorker.exe
Normal file
Binary file not shown.
BIN
FreeTypeWorker-win/release/QtCore4.dll
Normal file
BIN
FreeTypeWorker-win/release/QtCore4.dll
Normal file
Binary file not shown.