00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #pragma once
00015
00016 #include "maxheap.h"
00017 #include "iFnPub.h"
00018 #include "INodeTab.h"
00019
00020
00021 #define IKCONTROL_CLASS_ID Class_ID(0xe6f5815, 0x717f99a4)
00022 #define IKCHAINCONTROL_CLASS_ID Class_ID(0x78724378, 0x8a4fd9)
00023 #define GET_IKCHAIN_CD (GetCOREInterface()->GetDllDir().ClassDir().FindClass(CTRL_MATRIX3_CLASS_ID, IKCHAINCONTROL_CLASS_ID))
00024
00025 #define IK_FP_INTERFACE_ID Interface_ID(0x5b734601, 0x7c7c7ece)
00026 #define IKCHAIN_FP_INTERFACE_ID Interface_ID(0x5a5e7cbe, 0x55367776)
00027
00028 #define GET_IK_OPS_INTERFACE ((IKCmdOps*)GetCOREInterface(IK_FP_INTERFACE_ID))
00029 #define GET_IKCHAIN_FP_INTERFACE ((IKChainActions*)GET_IKCHAIN_CD->GetInterface(IKCHAIN_FP_INTERFACE_ID))
00030
00039 class IKCmdOps : public FPStaticInterface {
00040 public:
00054 virtual INode* CreateIKChain(INode* start, INode* end, const MCHAR* solver) =0;
00057 virtual int SolverCount() const =0;
00061 virtual MSTR SolverName(int) const =0;
00065 virtual MSTR SolverUIName(int) const =0;
00066 };
00067
00068
00070
00076 class IKCmdOpsEx : public IKCmdOps {
00077 public:
00080 virtual void SuspendLinkNotify() = 0;
00083 virtual void ResumeLinkNotify() = 0;
00086 virtual bool IsLinkNotifySuspended() const = 0;
00087 };
00088
00089 #define GET_IKEX_OPS_INTERFACE ((IKCmdOpsEx*)GetCOREInterface(IK_FP_INTERFACE_ID))
00090
00111 class IKChainActions : public FPStaticInterface {
00112 public:
00116 virtual FPStatus SnapAction() =0;
00121 virtual FPStatus IKSnapAction() =0;
00126 virtual FPStatus FKSnapAction() =0;
00127 virtual BOOL IsSnapEnabled() =0;
00132 virtual FPStatus ToggleEnabled() =0;
00137 virtual FPStatus SetPreferredAngles() =0;
00140 virtual FPStatus AssumePreferredAngles() =0;
00141 };
00142
00143 namespace IKSys {
00144 class ZeroPlaneMap;
00145 }
00146
00147
00148
00149 class IKSolver;
00161 class IIKChainControl: public MaxHeapOperators {
00162 public:
00163
00164
00165 enum {
00166 kPBlockRef = 0,
00167 kGoalTMRef,
00168 kEndJointRef,
00169 kEnableRef,
00170 kStartJointRef,
00171 kOwningNodeRef,
00172 kLastRef
00173 };
00174
00175
00176 enum {
00177 kParamBlock,
00178 kNumParamBlocks
00179 };
00180
00181
00182 enum {
00183 kStartJoint,
00184 kEndJoint,
00185 kSolverName,
00186 kAutoEnable,
00187 kSwivel,
00188 kPosThresh,
00189 kRotThresh,
00190 kIteration,
00191 kEEDisplay,
00192 kEESize,
00193 kGoalDisplay,
00194 kGoalSize,
00195 kVHDisplay,
00196 kVHSize,
00197 kVHLength,
00198 kSolverDisplay,
00199 kAutoSnap,
00200 kVHUseTarget,
00201 kVHTarget,
00202 kSAParent,
00203 kLastHIIKParam
00204 };
00205
00210 enum SplineIKParams {
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00229 kPickShape = kLastHIIKParam,
00230 kTwistHStartDisplay,
00231 kTwistHEndDisplay,
00232 kTwistHStartSize,
00233 kTwistHEndSize,
00234 kTwistHStartLength,
00235 kTwistHEndLength,
00236 kTwistHStartAngle,
00237 kTwistHEndAngle,
00238
00239
00240
00241
00242
00243
00251 kAutoSplineCreate,
00252
00253 kSplineTypeChoice,
00254
00259 kSplineKnotCount,
00260
00264 kCreateHelper,
00265
00272 kLinktoRootNode,
00273 kHelpersize,
00274 kHelperCentermarker,
00275 kHelperAxisTripod,
00276 kHelperCross,
00277 kHelperBox,
00278 kHelperScreensize,
00279 kHelperDrawontop,
00280 kUpnode,
00281 kUseUpnode,
00282 kLastSplineIKParam
00283 };
00285
00286 enum SAParentSpace {
00287 kSAInGoal,
00288 kSAInStartJoint
00289 };
00290
00291
00292
00293
00294
00295
00296
00297
00298 virtual float TwistHStartAngle(TimeValue, Interval&)=0;
00299 virtual float TwistHEndAngle(TimeValue, Interval&)=0;
00300
00301
00305 virtual INode* StartJoint() const =0;
00308 virtual INode* EndJoint() const =0;
00311 virtual INode* GetNode() const =0;
00312
00313
00314
00315
00316
00317
00336 virtual Point3 ChainNormal(TimeValue t, Interval& valid) =0;
00338 virtual Point3 InitPlane(TimeValue t) =0;
00340 virtual Point3 InitEEAxis(TimeValue t) =0;
00342 virtual float InitChainLength(TimeValue t) =0;
00346 virtual float SwivelAngle(TimeValue, Interval&)=0;
00352 virtual const IKSys::ZeroPlaneMap*
00353 DefaultZeroPlaneMap(TimeValue t) =0;
00357 virtual SAParentSpace SwivelAngleParent() const =0;
00358
00359
00362 virtual IKSolver* Solver() const =0;
00363
00366 virtual bool SolverEnabled(TimeValue, Interval* =0)=0;
00371 virtual bool CanAutoEnable() const =0;
00376 virtual bool AutoEnableSet() const =0;
00380 virtual bool Valid() const =0;
00381
00382
00388 virtual Interface_ID GoalInterfaceID() const =0;
00392 virtual BaseInterface* AcquireGoal(TimeValue, Interval&, const Matrix3& parent_of_start_joint) =0;
00393 };
00394
00395 namespace IKSys {
00396 enum DofAxis {
00397 TransX = 0, TransY, TransZ,
00398 RotX, RotY, RotZ,
00399 DofX = 0, DofY, DofZ
00400 };
00401 enum JointType {
00402 SlidingJoint,
00403 RotationalJoint
00404 };
00405 struct DofSet : public MaxHeapOperators {
00406 DofSet() : bits(0) {}
00407 DofSet(const DofSet& src) : bits(src.bits) {}
00408 void Add(DofAxis dn) { bits |= (1 << dn); }
00409 void Clear(DofAxis dn) { bits &= ~(unsigned(1 << dn)); }
00410 int Include(DofAxis dn) const { return bits & (1 << dn); }
00411 int Count() const;
00412 unsigned bits;
00413 };
00414 inline int DofSet::Count() const
00415 {
00416 unsigned int ret;
00417 unsigned int b, i;
00418 for (b = bits, ret = 0, i = TransX; i <= RotZ; ++i) {
00419 if (b == 0) break;
00420 else if (b & 01u) {
00421 ret++;
00422 }
00423 b = b >> 1;
00424 }
00425 return ret;
00426 }
00427 };
00428
00429
00430
00441 class IIKControl: public MaxHeapOperators {
00442 public:
00443 typedef IKSys::DofAxis DofAxis;
00444 typedef IKSys::JointType JointType;
00445 typedef IKSys::DofSet DofSet;
00446
00447
00455 virtual bool DofActive(DofAxis) const =0;
00460 virtual DofSet ActiveTrans() const =0;
00465 virtual DofSet ActiveRot() const =0;
00472 virtual DofSet ActiveDofs() const =0;
00481 virtual INodeTab IKChains(JointType) const =0;
00489 virtual bool DofLowerLimited(DofAxis) const =0;
00497 virtual bool DofUpperLimited(DofAxis) const =0;
00506 virtual Point2 DofLimits(DofAxis) const =0;
00510 virtual Point3 TransLowerLimits() const =0;
00514 virtual Point3 TransUpperLimits() const =0;
00517 virtual Point3 RotLowerLimits() const =0;
00520 virtual Point3 RotUpperLimits() const =0;
00533 virtual bool IKBound(TimeValue t, JointType jt)=0;
00537 virtual Control* FKSubController() const =0;
00540 virtual INode* GetNode() const =0;
00549 virtual Point3 PrefPosition(TimeValue t, Interval& validityInterval) =0;
00558 virtual Point3 PrefRotation(TimeValue t, Interval& validityInterval) =0;
00559
00560
00561 virtual Point3 TransValues(TimeValue, Interval* =0)=0;
00562 virtual Point3 RotValues(TimeValue, Interval* =0)=0;
00570 virtual void AssignTrans(const Point3&, const Interval&)=0;
00578 virtual void AssignRot(const Point3&, const Interval&)=0;
00587 virtual void AssignActiveTrans(const Point3&, const Interval&)=0;
00596 virtual void AssignActiveRot(const Point3&, const Interval&)=0;
00609 virtual void AssignActiveTrans(const DofSet&, const float[],
00610 const Interval&)=0;
00623 virtual void AssignActiveRot(const DofSet&, const float[],
00624 const Interval&)=0;
00630 virtual void SetTransValid(const Interval& valid) =0;
00636 virtual void SetRotValid(const Interval& valid) =0;
00642 virtual void SetTRValid(const Interval& valid) =0;
00651 virtual void SetPrefTrans(const Point3& val, TimeValue t =0) =0;
00660 virtual void SetPrefRot(const Point3& val, TimeValue t =0) =0;
00671 virtual void SetPrefTR(const Point3& trans, const Point3& rot,
00672 TimeValue t =0) =0;
00673 };