dust3d/src/clothsimulator.h

42 lines
1.3 KiB
C
Raw Normal View History

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