#ifndef DUST3D_APPLICATION_MODEL_MESH_H_ #define DUST3D_APPLICATION_MODEL_MESH_H_ #include #include #include #include #include #include #include #include "model_opengl_vertex.h" class ModelMesh { public: ModelMesh(const std::vector &vertices, const std::vector> &triangles, const std::vector> &triangleVertexNormals, const dust3d::Color &color=dust3d::Color::createWhite(), float metalness=0.0, float roughness=1.0, const std::vector> *vertexProperties=nullptr); ModelMesh(dust3d::Object &object); ModelMesh(ModelOpenGLVertex *triangleVertices, int vertexNum); ModelMesh(const ModelMesh &mesh); ModelMesh(); ~ModelMesh(); ModelOpenGLVertex *triangleVertices(); int triangleVertexCount(); const std::vector &vertices(); const std::vector> &faces(); const std::vector &triangulatedVertices(); void setTextureImage(QImage *textureImage); const QImage *textureImage(); QImage *takeTextureImage(); void setNormalMapImage(QImage *normalMapImage); const QImage *normalMapImage(); QImage *takeNormalMapImage(); const QImage *metalnessRoughnessAmbientOcclusionMapImage(); QImage *takeMetalnessRoughnessAmbientOcclusionMapImage(); void setMetalnessRoughnessAmbientOcclusionMapImage(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); void updateTriangleVertices(ModelOpenGLVertex *triangleVertices, int triangleVertexCount); quint64 meshId() const; void setMeshId(quint64 id); void removeColor(); private: ModelOpenGLVertex *m_triangleVertices = nullptr; int m_triangleVertexCount = 0; std::vector m_vertices; std::vector> m_faces; std::vector m_triangulatedVertices; QImage *m_textureImage = nullptr; QImage *m_normalMapImage = nullptr; QImage *m_metalnessRoughnessAmbientOcclusionMapImage = nullptr; bool m_hasMetalnessInImage = false; bool m_hasRoughnessInImage = false; bool m_hasAmbientOcclusionInImage = false; quint64 m_meshId = 0; }; #endif