#ifndef DUST3D_CLOTH_SIMULATOR_H #define DUST3D_CLOTH_SIMULATOR_H #include #include #include struct mass_spring_system; class MassSpringSolver; class CgRootNode; class CgSpringDeformationNode; class CgMeshCollisionNode; class CgPointFixNode; class ClothSimulator : public QObject { Q_OBJECT public: ClothSimulator(const std::vector &vertices, const std::vector> &faces, const std::vector &collisionVertices, const std::vector> &collisionTriangles, const std::vector &externalForces); ~ClothSimulator(); void setStiffness(float stiffness); void create(); void step(); void getCurrentVertices(std::vector *currentVertices); private: std::vector m_vertices; std::vector> m_faces; std::vector m_collisionVertices; std::vector> m_collisionTriangles; std::vector m_externalForces; std::vector m_clothPointBuffer; std::vector m_clothPointSources; std::vector> m_clothSprings; float m_stiffness = 1.0f; QVector3D m_offset; mass_spring_system *m_massSpringSystem = nullptr; MassSpringSolver *m_massSpringSolver = nullptr; CgRootNode *m_rootNode = nullptr; CgSpringDeformationNode *m_deformationNode = nullptr; CgMeshCollisionNode *m_meshCollisionNode = nullptr; CgPointFixNode *m_fixNode = nullptr; void convertMeshToCloth(); }; #endif