2018-10-25 00:19:38 +00:00
|
|
|
#ifndef DUST3D_MESH_LOADER_H
|
|
|
|
#define DUST3D_MESH_LOADER_H
|
2018-03-10 06:57:14 +00:00
|
|
|
#include <QObject>
|
2018-03-20 07:56:49 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <QVector3D>
|
2018-04-26 02:23:22 +00:00
|
|
|
#include <QColor>
|
2018-05-10 09:16:22 +00:00
|
|
|
#include <QImage>
|
2019-03-20 11:04:37 +00:00
|
|
|
#include <QTextStream>
|
2018-10-25 00:19:38 +00:00
|
|
|
#include "outcome.h"
|
2019-07-04 09:36:50 +00:00
|
|
|
#include "shadervertex.h"
|
2019-07-07 06:27:58 +00:00
|
|
|
#include "toolmesh.h"
|
2018-03-10 06:57:14 +00:00
|
|
|
|
2018-04-26 02:23:22 +00:00
|
|
|
struct TriangulatedFace
|
|
|
|
{
|
2018-11-17 23:02:12 +00:00
|
|
|
int indices[3];
|
2018-04-26 02:23:22 +00:00
|
|
|
QColor color;
|
|
|
|
};
|
|
|
|
|
2018-05-07 17:16:58 +00:00
|
|
|
class MeshLoader
|
2018-03-10 06:57:14 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-02-18 12:57:18 +00:00
|
|
|
MeshLoader(const std::vector<QVector3D> &vertices, const std::vector<std::vector<size_t>> &triangles,
|
|
|
|
const std::vector<std::vector<QVector3D>> &triangleVertexNormals,
|
|
|
|
const QColor &color=Qt::white);
|
2018-10-25 00:19:38 +00:00
|
|
|
MeshLoader(Outcome &outcome);
|
2019-07-04 09:36:50 +00:00
|
|
|
MeshLoader(ShaderVertex *triangleVertices, int vertexNum);
|
2018-06-11 14:24:25 +00:00
|
|
|
MeshLoader(const MeshLoader &mesh);
|
2018-09-18 06:22:29 +00:00
|
|
|
MeshLoader();
|
2018-05-07 17:16:58 +00:00
|
|
|
~MeshLoader();
|
2019-07-04 09:36:50 +00:00
|
|
|
ShaderVertex *triangleVertices();
|
2018-03-19 13:56:10 +00:00
|
|
|
int triangleVertexCount();
|
2019-07-04 09:36:50 +00:00
|
|
|
ShaderVertex *edgeVertices();
|
2018-03-19 13:56:10 +00:00
|
|
|
int edgeVertexCount();
|
2019-07-04 09:36:50 +00:00
|
|
|
ShaderVertex *toolVertices();
|
|
|
|
int toolVertexCount();
|
2018-03-20 07:56:49 +00:00
|
|
|
const std::vector<QVector3D> &vertices();
|
2019-02-18 12:57:18 +00:00
|
|
|
const std::vector<std::vector<size_t>> &faces();
|
2018-04-26 02:23:22 +00:00
|
|
|
const std::vector<QVector3D> &triangulatedVertices();
|
|
|
|
const std::vector<TriangulatedFace> &triangulatedFaces();
|
2018-05-10 09:16:22 +00:00
|
|
|
void setTextureImage(QImage *textureImage);
|
|
|
|
const QImage *textureImage();
|
2018-10-09 02:19:12 +00:00
|
|
|
void setNormalMapImage(QImage *normalMapImage);
|
|
|
|
const QImage *normalMapImage();
|
|
|
|
const QImage *metalnessRoughnessAmbientOcclusionImage();
|
|
|
|
void setMetalnessRoughnessAmbientOcclusionImage(QImage *image);
|
|
|
|
bool hasMetalnessInImage();
|
|
|
|
void setHasMetalnessInImage(bool hasInImage);
|
|
|
|
bool hasRoughnessInImage();
|
|
|
|
void setHasRoughnessInImage(bool hasInImage);
|
|
|
|
bool hasAmbientOcclusionInImage();
|
|
|
|
void setHasAmbientOcclusionInImage(bool hasInImage);
|
|
|
|
static float m_defaultMetalness;
|
|
|
|
static float m_defaultRoughness;
|
|
|
|
void exportAsObj(const QString &filename);
|
2019-03-20 11:04:37 +00:00
|
|
|
void exportAsObj(QTextStream *textStream);
|
2019-07-07 06:27:58 +00:00
|
|
|
void updateTool(ShaderVertex *toolVertices, int vertexNum);
|
2018-03-10 06:57:14 +00:00
|
|
|
private:
|
2019-07-04 09:36:50 +00:00
|
|
|
ShaderVertex *m_triangleVertices = nullptr;
|
2018-09-18 06:22:29 +00:00
|
|
|
int m_triangleVertexCount = 0;
|
2019-07-04 09:36:50 +00:00
|
|
|
ShaderVertex *m_edgeVertices = nullptr;
|
2018-09-18 06:22:29 +00:00
|
|
|
int m_edgeVertexCount = 0;
|
2019-07-04 09:36:50 +00:00
|
|
|
ShaderVertex *m_toolVertices = nullptr;
|
|
|
|
int m_toolVertexCount = 0;
|
2018-03-20 07:56:49 +00:00
|
|
|
std::vector<QVector3D> m_vertices;
|
2019-02-18 12:57:18 +00:00
|
|
|
std::vector<std::vector<size_t>> m_faces;
|
2018-04-26 02:23:22 +00:00
|
|
|
std::vector<QVector3D> m_triangulatedVertices;
|
|
|
|
std::vector<TriangulatedFace> m_triangulatedFaces;
|
2018-09-18 06:22:29 +00:00
|
|
|
QImage *m_textureImage = nullptr;
|
2018-10-09 02:19:12 +00:00
|
|
|
QImage *m_normalMapImage = nullptr;
|
|
|
|
QImage *m_metalnessRoughnessAmbientOcclusionImage = nullptr;
|
|
|
|
bool m_hasMetalnessInImage = false;
|
|
|
|
bool m_hasRoughnessInImage = false;
|
|
|
|
bool m_hasAmbientOcclusionInImage = false;
|
2018-03-10 06:57:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|