tahoma2d/toonz/sources/include/toonz/ikengine.h

68 lines
1.3 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef IKENGINE_H
#define IKENGINE_H
#include "ikskeleton.h"
#undef DVAPI
#undef DVVAR
#ifdef TOONZLIB_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
class Jacobian;
2016-06-15 18:43:10 +12:00
class DVAPI IKEngine {
IKSkeleton m_skeleton;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
IKEngine();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// n.b. root index == 0
void setRoot(const TPointD &pos);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int addJoint(const TPointD &pos, int parentIndex);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void lock(int index);
void unlock(int index);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool isLocked(int index);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void clear() {
m_skeleton.clear();
target.clear();
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int getJointCount() const { return m_skeleton.getNodeCount(); }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
const TPointD getJoint(int index) const {
assert(0 <= index && index < (int)m_skeleton.getNodeCount());
TPointD jointPos = m_skeleton.getNode(index)->getPos();
return jointPos;
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int getJointParent(int index) const {
assert(index > -1 && index < m_skeleton.getNodeCount());
IKNode *node = m_skeleton.getNode(index)->getParent();
return node ? node->getIndex() : -1;
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
double getJointAngle(int index);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// trascino il punto index
void drag(TPointD &pos);
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
std::vector<TPointD> target;
void doUpdateStep(Jacobian &jacobian);
void setSequenceJoints();
2016-03-19 06:57:51 +13:00
};
//#endif
2016-06-15 18:43:10 +12:00
#endif // IKENGINE_H