49 using namespace HDK_Sample;
78 PRM_Name(
"straighten",
"Straighten Solution"),
142 SOP_IKSample::setupRestChain()
145 GA_Size num_bones = num_points - 1;
150 str.
sprintf(
"%d", 2 - (
int)num_points);
158 for (
GA_Size i = 0; i < num_bones; i++)
209 if (!setupRestChain())
229 pscale_attrib.set(ptoff, length);
237 pscale_attrib.bumpDataId();
241 const char *solver_name =
"inverse";
243 if (!evaluateSolverParms(context, parms))
248 if (!myRestChain.
solve(solver_name, &parms, solution))
283 for (
GA_Index i = 0; i < num_bones; i++)
285 auto &&bone = solution.
getBone(i);
289 xform.
leftMult(UT_R_FROM_F(bone.getExtraXform()));
301 bone.getRotates(rot.
data());
309 orient_attrib.
set(ptoff, q);
311 prev_length = bone.getLength();
331 return "Points for IK";
OP_ERROR cookMySop(OP_Context &context) override
Method to cook geometry for the SOP.
SYS_FORCE_INLINE void bumpDataId()
PRM_API PRM_Range PRMangleRange
Class which stores the default values for a GA_Attribute.
GA_Attribute * addFloatTuple(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringHolder &name, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0.0), const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, GA_Storage storage=GA_STORE_REAL32, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
void radToDeg()
conversion between degrees and radians
GA_API const UT_StringHolder rot
constexpr SYS_FORCE_INLINE T & z() noexcept
GA_Attribute * getP()
Convenience method to access the P attribute.
UT_Vector3T< T > computeRotations(const UT_XformOrder &) const
SYS_FORCE_INLINE const char * buffer() const
GLuint GLsizei GLsizei * length
constexpr SYS_FORCE_INLINE T length() const noexcept
const KIN_Bone & getBone(int index) const
bool addOperator(OP_Operator *op, std::ostream *err=nullptr)
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Offset ptoff) const
The ptoff passed is the point offset.
GLdouble GLdouble GLdouble q
void addError(int code, const char *msg=0)
exint GA_Size
Defines the bit width for index and offset types in GA.
constexpr SYS_FORCE_INLINE const T * data() const noexcept
void degToRad()
conversion between degrees and radians
int solve(const UT_StringHolder &type, const void *parms, KIN_Chain &solution)
OP_ERROR duplicateChangedSource(unsigned idx, OP_Context &ctx, int *changed=0, bool force=false)
Only duplicates the source if the source has changed since the last call to this method.
PRM_API const PRM_Type PRM_ANGLE_J
PRM_API const PRM_Type PRM_TOGGLE_J
void updateFromVectors(const UT_Vector3T< T > &v1, const UT_Vector3T< T > &v2)
GLuint const GLchar * name
static OP_Node * myConstructor(OP_Network *, const char *, OP_Operator *)
#define GA_FOR_ALL_PTOFF(gdp, ptoff)
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
PRM_API const PRM_Type PRM_FLT_J
GLenum GLenum GLsizei void * table
void setManagesDataIDs(bool onOff)
void setTranslates(const UT_Vector3T< S > &translates)
void prerotate(UT_Vector3T< S > &axis, T theta, int norm=1)
SOP_IKSample(OP_Network *net, const char *name, OP_Operator *op)
int sprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
SYS_FORCE_INLINE bool isValid() const
const GA_Attribute * findFloatTuple(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name, int min_size=1, int max_size=-1) const
const char * inputLabel(unsigned input_index) const override
Method to provide input labels.
SYS_FORCE_INLINE void setPos3(GA_Offset ptoff, const UT_Vector3 &pos)
Set P from a UT_Vector3.
fpreal myTrackingThresholdFactor
SYS_FORCE_INLINE void set(GA_Offset off, const T &val) const
static PRM_Template myTemplateList[]
void setNbones(int bones)
static const UT_XformOrder & getXformOrder()
void leftMult(const UT_Matrix4T< T > &m)
SYS_FORCE_INLINE UT_StorageMathFloat_t< T > normalize() noexcept
GA_RWHandleT< UT_QuaternionF > GA_RWHandleQ
constexpr SYS_FORCE_INLINE T & y() noexcept
void updateBone(int index, fpreal length, fpreal *rot, fpreal damp, const UT_Matrix4R &xform, const void *data)
SYS_FORCE_INLINE GA_Offset pointOffset(GA_Index index) const
Given a point's index (in append order), return its data offset.
UT_Vector3R myEndAffectorPos
void pretranslate(T dx, T dy, T dz=0)
void getTranslates(UT_Vector3T< S > &translates) const
void newSopOperator(OP_OperatorTable *table)
void updateFromRotationMatrix(const UT_Matrix3 &)
SYS_FORCE_INLINE GA_Size getNumPoints() const
Return the number of points.
constexpr SYS_FORCE_INLINE T & x() noexcept