-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Worldmap classes (not yet enabled)
- Loading branch information
Showing
59 changed files
with
4,125 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#include "Poly.h" | ||
|
||
Poly::Poly(int count, const QList<Vertex> &vertices, | ||
const QList<Vertex> &normals, const QList<QRgb> &colors, | ||
const QList<TexCoord> &texCoords) : | ||
_count(count), _normals(normals) | ||
{ | ||
setVertices(vertices, colors, texCoords); | ||
} | ||
|
||
Poly::Poly(int count, const QList<Vertex> &vertices, | ||
const QList<Vertex> &normals, const QRgb &color, | ||
const QList<TexCoord> &texCoords) : | ||
_count(count), _normals(normals) | ||
{ | ||
setVertices(vertices, color, texCoords); | ||
} | ||
|
||
void Poly::setVertices(const QList<Vertex> &vertices, const QList<QRgb> &colors, | ||
const QList<TexCoord> &texCoords) | ||
{ | ||
_vertices = vertices; | ||
_colors = colors; | ||
_texCoords = texCoords; | ||
} | ||
|
||
void Poly::setVertices(const QList<Vertex> &vertices, const QRgb &color, | ||
const QList<TexCoord> &texCoords) | ||
{ | ||
_vertices = vertices; | ||
_colors.clear(); | ||
_colors.append(color); | ||
_texCoords = texCoords; | ||
} | ||
|
||
const Vertex &Poly::vertex(quint8 id) const | ||
{ | ||
return _vertices.at(id); | ||
} | ||
|
||
const Vertex &Poly::normal(quint8 id) const | ||
{ | ||
return _normals.at(id); | ||
} | ||
|
||
const QRgb &Poly::color() const | ||
{ | ||
return _colors.first(); | ||
} | ||
|
||
QRgb Poly::color(quint8 id) const | ||
{ | ||
return _colors.value(id, _colors.first()); | ||
} | ||
|
||
const TexCoord &Poly::texCoord(quint8 id) const | ||
{ | ||
return _texCoords.at(id); | ||
} | ||
|
||
void Poly::setTexCoord(quint8 id, const TexCoord &texCoord) | ||
{ | ||
_texCoords.replace(id, texCoord); | ||
} | ||
|
||
bool Poly::isMonochrome() const | ||
{ | ||
return _colors.size() == 1; | ||
} | ||
|
||
bool Poly::hasTexture() const | ||
{ | ||
return !_texCoords.isEmpty(); | ||
} | ||
|
||
QuadPoly::QuadPoly(const QList<Vertex> &vertices, | ||
const QList<Vertex> &normals, const QList<QRgb> &colors, | ||
const QList<TexCoord> &texCoords) : | ||
Poly(4, vertices, normals, colors, texCoords) | ||
{ | ||
// swapping the two last vertices for right OpenGL quad order | ||
|
||
_vertices.swapItemsAt(2, 3); | ||
_normals.swapItemsAt(2, 3); | ||
|
||
if(colors.size() == 4) { | ||
_colors.swapItemsAt(2, 3); | ||
} | ||
|
||
if(!texCoords.isEmpty()) { | ||
_texCoords.swapItemsAt(2, 3); | ||
} | ||
} | ||
|
||
QuadPoly::QuadPoly(const QList<Vertex> &vertices, | ||
const QList<Vertex> &normals, const QRgb &color, | ||
const QList<TexCoord> &texCoords) : | ||
Poly(4, vertices, normals, color, texCoords) | ||
{ | ||
// swapping the two last vertices for right OpenGL quad order | ||
|
||
_vertices.swapItemsAt(2, 3); | ||
_normals.swapItemsAt(2, 3); | ||
|
||
if(!texCoords.isEmpty()) { | ||
_texCoords.swapItemsAt(2, 3); | ||
} | ||
} | ||
|
||
TrianglePoly::TrianglePoly(const QList<Vertex> &vertices, | ||
const QList<Vertex> &normals, | ||
const QList<QRgb> &colors, | ||
const QList<TexCoord> &texCoords) : | ||
Poly(3, vertices, normals, colors, texCoords) | ||
{ | ||
} | ||
|
||
TrianglePoly::TrianglePoly(const QList<Vertex> &vertices, | ||
const QList<Vertex> &normals, const QRgb &color, | ||
const QList<TexCoord> &texCoords) : | ||
Poly(3, vertices, normals, color, texCoords) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/**************************************************************************** | ||
** Deling Final Fantasy VIII Field Editor | ||
** Copyright (C) 2009-2024 Arzel Jérôme <myst6re@gmail.com> | ||
** | ||
** This program is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** This program is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
****************************************************************************/ | ||
#pragma once | ||
|
||
#include <QtCore> | ||
#include <QRgb> | ||
|
||
struct Vertex { | ||
qint16 x, y, z; | ||
}; | ||
|
||
inline bool operator==(const Vertex &v1, const Vertex &v2) | ||
{ | ||
return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z; | ||
} | ||
|
||
inline size_t qHash(const Vertex &key, uint seed) | ||
{ | ||
return qHash(quint64(key.x | (key.y << 16)) | (quint64(key.z) << 32), seed); | ||
} | ||
|
||
struct TexCoord { | ||
quint8 x, y; | ||
}; | ||
|
||
class Poly | ||
{ | ||
public: | ||
Poly(int count, const QList<Vertex> &vertices, const QList<Vertex> &normals, | ||
const QList<QRgb> &colors, | ||
const QList<TexCoord> &texCoords=QList<TexCoord>()); | ||
Poly(int count, const QList<Vertex> &vertices, const QList<Vertex> &normals, | ||
const QRgb &color, | ||
const QList<TexCoord> &texCoords=QList<TexCoord>()); | ||
virtual ~Poly() {} | ||
void setVertices(const QList<Vertex> &vertices, const QList<QRgb> &colors, | ||
const QList<TexCoord> &texCoords=QList<TexCoord>()); | ||
void setVertices(const QList<Vertex> &vertices, const QRgb &color, | ||
const QList<TexCoord> &texCoords=QList<TexCoord>()); | ||
inline int count() const { | ||
return _count; | ||
} | ||
const Vertex &vertex(quint8 id) const; | ||
const Vertex &normal(quint8 id) const; | ||
inline const QList<Vertex> &vertices() const { | ||
return _vertices; | ||
} | ||
inline const QList<Vertex> &normals() const { | ||
return _normals; | ||
} | ||
const QRgb &color() const; | ||
QRgb color(quint8 id) const; | ||
const TexCoord &texCoord(quint8 id) const; | ||
void setTexCoord(quint8 id, const TexCoord &texCoord); | ||
inline const QList<TexCoord> &texCoords() const { | ||
return _texCoords; | ||
} | ||
bool isMonochrome() const; | ||
bool hasTexture() const; | ||
protected: | ||
int _count; | ||
QList<Vertex> _vertices, _normals; | ||
QList<QRgb> _colors; | ||
QList<TexCoord> _texCoords; | ||
}; | ||
|
||
class QuadPoly : public Poly | ||
{ | ||
public: | ||
QuadPoly(const QList<Vertex> &vertices, const QList<Vertex> &normals, | ||
const QList<QRgb> &colors, | ||
const QList<TexCoord> &texCoords=QList<TexCoord>()); | ||
QuadPoly(const QList<Vertex> &vertices, const QList<Vertex> &normals, | ||
const QRgb &color, | ||
const QList<TexCoord> &texCoords=QList<TexCoord>()); | ||
}; | ||
|
||
class TrianglePoly : public Poly | ||
{ | ||
public: | ||
TrianglePoly(const QList<Vertex> &vertices, const QList<Vertex> &normals, | ||
const QList<QRgb> &colors, | ||
const QList<TexCoord> &texCoords=QList<TexCoord>()); | ||
TrianglePoly(const QList<Vertex> &vertices, const QList<Vertex> &normals, | ||
const QRgb &color, | ||
const QList<TexCoord> &texCoords=QList<TexCoord>()); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.