2022-09-23 15:54:49 +00:00
|
|
|
#ifndef DUST3D_APPLICATION_MODEL_MESH_H_
|
|
|
|
#define DUST3D_APPLICATION_MODEL_MESH_H_
|
2021-11-18 14:58:01 +00:00
|
|
|
|
2018-03-10 06:57:14 +00:00
|
|
|
#include <QObject>
|
2018-03-20 07:56:49 +00:00
|
|
|
#include <vector>
|
2018-05-10 09:16:22 +00:00
|
|
|
#include <QImage>
|
2019-03-20 11:04:37 +00:00
|
|
|
#include <QTextStream>
|
2021-11-18 14:58:01 +00:00
|
|
|
#include <dust3d/base/vector3.h>
|
|
|
|
#include <dust3d/base/color.h>
|
|
|
|
#include <dust3d/base/object.h>
|
2022-09-23 15:54:49 +00:00
|
|
|
#include "model_opengl_vertex.h"
|
2018-04-26 02:23:22 +00:00
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
class ModelMesh
|
2018-03-10 06:57:14 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-10-07 20:26:30 +00:00
|
|
|
ModelMesh(const std::vector<dust3d::Vector3> &vertices,
|
|
|
|
const std::vector<std::vector<size_t>> &triangles,
|
2021-11-18 14:58:01 +00:00
|
|
|
const std::vector<std::vector<dust3d::Vector3>> &triangleVertexNormals,
|
|
|
|
const dust3d::Color &color=dust3d::Color::createWhite(),
|
2020-10-18 05:52:15 +00:00
|
|
|
float metalness=0.0,
|
2022-10-07 20:26:30 +00:00
|
|
|
float roughness=0.0,
|
|
|
|
const std::vector<std::tuple<dust3d::Color, float/*metalness*/, float/*roughness*/>> *vertexProperties=nullptr);
|
2022-09-23 15:54:49 +00:00
|
|
|
ModelMesh(dust3d::Object &object);
|
2022-09-23 17:33:55 +00:00
|
|
|
ModelMesh(ModelOpenGLVertex *triangleVertices, int vertexNum);
|
2022-09-23 15:54:49 +00:00
|
|
|
ModelMesh(const ModelMesh &mesh);
|
|
|
|
ModelMesh();
|
|
|
|
~ModelMesh();
|
|
|
|
ModelOpenGLVertex *triangleVertices();
|
2018-03-19 13:56:10 +00:00
|
|
|
int triangleVertexCount();
|
2021-11-18 14:58:01 +00:00
|
|
|
const std::vector<dust3d::Vector3> &vertices();
|
2019-02-18 12:57:18 +00:00
|
|
|
const std::vector<std::vector<size_t>> &faces();
|
2021-11-18 14:58:01 +00:00
|
|
|
const std::vector<dust3d::Vector3> &triangulatedVertices();
|
2018-05-10 09:16:22 +00:00
|
|
|
void setTextureImage(QImage *textureImage);
|
|
|
|
const QImage *textureImage();
|
2022-09-24 13:31:49 +00:00
|
|
|
QImage *takeTextureImage();
|
2018-10-09 02:19:12 +00:00
|
|
|
void setNormalMapImage(QImage *normalMapImage);
|
|
|
|
const QImage *normalMapImage();
|
2022-09-24 13:31:49 +00:00
|
|
|
QImage *takeNormalMapImage();
|
|
|
|
const QImage *metalnessRoughnessAmbientOcclusionMapImage();
|
|
|
|
QImage *takeMetalnessRoughnessAmbientOcclusionMapImage();
|
|
|
|
void setMetalnessRoughnessAmbientOcclusionMapImage(QImage *image);
|
2018-10-09 02:19:12 +00:00
|
|
|
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);
|
2022-09-23 15:54:49 +00:00
|
|
|
void updateTriangleVertices(ModelOpenGLVertex *triangleVertices, int triangleVertexCount);
|
2019-07-10 12:09:46 +00:00
|
|
|
quint64 meshId() const;
|
|
|
|
void setMeshId(quint64 id);
|
2020-01-05 05:05:07 +00:00
|
|
|
void removeColor();
|
2018-03-10 06:57:14 +00:00
|
|
|
private:
|
2022-09-23 15:54:49 +00:00
|
|
|
ModelOpenGLVertex *m_triangleVertices = nullptr;
|
2018-09-18 06:22:29 +00:00
|
|
|
int m_triangleVertexCount = 0;
|
2021-11-18 14:58:01 +00:00
|
|
|
std::vector<dust3d::Vector3> m_vertices;
|
2019-02-18 12:57:18 +00:00
|
|
|
std::vector<std::vector<size_t>> m_faces;
|
2021-11-18 14:58:01 +00:00
|
|
|
std::vector<dust3d::Vector3> m_triangulatedVertices;
|
2018-09-18 06:22:29 +00:00
|
|
|
QImage *m_textureImage = nullptr;
|
2018-10-09 02:19:12 +00:00
|
|
|
QImage *m_normalMapImage = nullptr;
|
2022-09-24 13:31:49 +00:00
|
|
|
QImage *m_metalnessRoughnessAmbientOcclusionMapImage = nullptr;
|
2018-10-09 02:19:12 +00:00
|
|
|
bool m_hasMetalnessInImage = false;
|
|
|
|
bool m_hasRoughnessInImage = false;
|
|
|
|
bool m_hasAmbientOcclusionInImage = false;
|
2019-07-10 12:09:46 +00:00
|
|
|
quint64 m_meshId = 0;
|
2018-03-10 06:57:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|