#ifndef DUST3D_MESH_LOADER_H #define DUST3D_MESH_LOADER_H #include #include #include #include #include #include #include "outcome.h" #include "shadervertex.h" struct TriangulatedFace { int indices[3]; QColor color; }; class MeshLoader { public: MeshLoader(const std::vector &vertices, const std::vector> &triangles, const std::vector> &triangleVertexNormals, const QColor &color=Qt::white); MeshLoader(Outcome &outcome); MeshLoader(ShaderVertex *triangleVertices, int vertexNum); MeshLoader(const MeshLoader &mesh); MeshLoader(); ~MeshLoader(); ShaderVertex *triangleVertices(); int triangleVertexCount(); ShaderVertex *edgeVertices(); int edgeVertexCount(); ShaderVertex *toolVertices(); int toolVertexCount(); const std::vector &vertices(); const std::vector> &faces(); const std::vector &triangulatedVertices(); const std::vector &triangulatedFaces(); void setTextureImage(QImage *textureImage); const QImage *textureImage(); 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); void exportAsObj(QTextStream *textStream); private: ShaderVertex *m_triangleVertices = nullptr; int m_triangleVertexCount = 0; ShaderVertex *m_edgeVertices = nullptr; int m_edgeVertexCount = 0; ShaderVertex *m_toolVertices = nullptr; int m_toolVertexCount = 0; std::vector m_vertices; std::vector> m_faces; std::vector m_triangulatedVertices; std::vector m_triangulatedFaces; QImage *m_textureImage = nullptr; QImage *m_normalMapImage = nullptr; QImage *m_metalnessRoughnessAmbientOcclusionImage = nullptr; bool m_hasMetalnessInImage = false; bool m_hasRoughnessInImage = false; bool m_hasAmbientOcclusionInImage = false; }; #endif