2018-10-25 00:19:38 +00:00
|
|
|
#ifndef DUST3D_CCD_IK_SOLVER_H
|
|
|
|
#define DUST3D_CCD_IK_SOLVER_H
|
2018-05-24 01:44:40 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <QVector3D>
|
|
|
|
#include <QQuaternion>
|
|
|
|
|
2020-11-09 10:46:06 +00:00
|
|
|
struct CcdIkNode
|
2018-05-24 01:44:40 +00:00
|
|
|
{
|
|
|
|
QVector3D position;
|
2020-11-09 10:46:06 +00:00
|
|
|
QVector3D axis;
|
|
|
|
double minLimitDegrees;
|
|
|
|
double maxLimitDegrees;
|
2018-05-24 01:44:40 +00:00
|
|
|
};
|
|
|
|
|
2020-11-09 10:46:06 +00:00
|
|
|
class CcdIkSolver
|
2018-05-24 01:44:40 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-11-09 10:46:06 +00:00
|
|
|
CcdIkSolver();
|
2018-05-24 01:44:40 +00:00
|
|
|
void setMaxRound(int maxRound);
|
|
|
|
void setDistanceThreshod(float threshold);
|
2018-08-27 08:50:40 +00:00
|
|
|
int addNodeInOrder(const QVector3D &position);
|
2018-05-24 01:44:40 +00:00
|
|
|
void solveTo(const QVector3D &position);
|
|
|
|
const QVector3D &getNodeSolvedPosition(int index);
|
2020-11-09 10:46:06 +00:00
|
|
|
int getNodeCount();
|
|
|
|
void setNodeHingeConstraint(int nodeIndex,
|
|
|
|
const QVector3D &axis, double minLimitDegrees, double maxLimitDegrees);
|
|
|
|
void setSolveFrom(int fromNodeIndex);
|
2018-05-24 01:44:40 +00:00
|
|
|
private:
|
|
|
|
void iterate();
|
|
|
|
private:
|
2020-11-09 10:46:06 +00:00
|
|
|
std::vector<CcdIkNode> m_nodes;
|
2018-05-24 01:44:40 +00:00
|
|
|
QVector3D m_destination;
|
2020-11-09 10:46:06 +00:00
|
|
|
int m_maxRound = 4;
|
|
|
|
float m_distanceThreshold2 = 0.001 * 0.001;
|
|
|
|
float m_distanceCeaseThreshold2 = 0.001 * 0.001;
|
|
|
|
int m_fromNodeIndex = 0;
|
2018-05-24 01:44:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|