Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #pragma once
00016
00017 #include "maxheap.h"
00018 #include "coreexp.h"
00019 #include "point2.h"
00020 #include "point3.h"
00021 #include "maxtypes.h"
00022 #include "matrix3.h"
00023
00024
00025 class IIKChainControl;
00026
00027 namespace IKSys
00028 {
00029
00037 class ZeroPlaneMap : public MaxHeapOperators {
00038 public:
00044 virtual Point3 operator()(const Point3& EEAxis) const =0;
00048 virtual ~ZeroPlaneMap() {}
00049 };
00050
00051 const Interface_ID kGoalID(0x53937e2, 0x2be92941);
00052 const Interface_ID kHIIKGoalID(0x2497c0e, 0x376f602a);
00053 const Interface_ID kSplineIKGoalID(0x4ee7cd9, 0x68a54886);
00054
00056 const Interface_ID IID_SPLINE_IKGOAL2(0x163a2f78, 0xb3027de);
00057
00058 enum SAParentSpace {
00059 kSAInGoal,
00060 kSAInStartJoint,
00061 kSANotApplicable = 1000
00062 };
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00122 class RootLink : public MaxHeapOperators {
00123 public:
00127 RootLink():flags(7){}
00128 Point3 rotXYZ;
00129 Point3 initXYZ;
00130 Point3 llimits;
00131 Point3 ulimits;
00132 Matrix3 rigidExtend;
00141 bool GetActive(unsigned i) const { return flags&(1<<i)?true:false;}
00150 bool GetLLimited(unsigned i) const { return flags&(1<<(i+3))?true:false;}
00159 bool GetULimited(unsigned i) const { return flags&(1<<(i+6))?true:false;}
00160
00174 CoreExport Matrix3& RotateByAxis(Matrix3& mat, unsigned i) const;
00182 CoreExport Matrix3 LinkMatrix(bool include_rot) const;
00194 CoreExport Matrix3& ApplyLinkMatrix(Matrix3& mat, bool include_rot) const;
00195
00196
00204 CoreExport void SetActive(unsigned i, bool s);
00212 CoreExport void SetLLimited(unsigned i, bool s);
00220 CoreExport void SetULimited(unsigned i, bool s);
00221 private:
00222 unsigned flags;
00223 };
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00278 class Link : public MaxHeapOperators {
00279 public:
00283 Link():rigidExtend(0),dofAxis(RotZ){}
00287 CoreExport ~Link();
00288 enum DofAxis {
00289 TransX,
00290 TransY,
00291 TransZ,
00292 RotX,
00293 RotY,
00294 RotZ
00295 };
00296 DofAxis dofAxis;
00297 float dofValue;
00298 float initValue;
00299 Point2 limits;
00304 bool NullLink() const {return rigidExtend?false:true;}
00307 bool ZeroLength() const {
00308 return NullLink() ? true :
00309 (rigidExtend->GetIdentFlags() & POS_IDENT) ? true : false; }
00314 bool LLimited() const { return llimited?true:false; }
00319 bool ULimited() const { return ulimited?true:false; }
00320
00325 CoreExport Matrix3 DofMatrix() const;
00332 CoreExport Matrix3& DofMatrix(Matrix3& mat) const;
00340 CoreExport Matrix3 LinkMatrix(bool include_dof =true) const;
00351 CoreExport Matrix3& ApplyLinkMatrix(Matrix3& mat, bool include_dof =true) const;
00352
00353
00354
00360 void SetLLimited(bool s) { llimited = s?1:0; }
00366 void SetULimited(bool s) { ulimited = s?1:0; }
00367
00372 CoreExport void SetRigidExtend(const Matrix3& mat);
00373
00374 private:
00375 Matrix3* rigidExtend;
00376 byte llimited : 1;
00377 byte ulimited : 1;
00378 };
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00453 class LinkChain : public MaxHeapOperators {
00454 public:
00455 LinkChain():links(0),linkCount(0) {}
00456 CoreExport LinkChain(unsigned lc);
00457 CoreExport virtual ~LinkChain();
00458 virtual void* GetInterface(ULONG i) const { UNUSED_PARAM(i); return NULL; }
00464 Matrix3 parentMatrix;
00465 RootLink rootLink;
00471 const Link& LinkOf(unsigned i) const {return links[i];}
00474 Link& LinkOf(unsigned i) {return links[i];}
00477 unsigned LinkCount() const { return linkCount; }
00486 CoreExport int PreBone(unsigned i) const;
00491 CoreExport unsigned Bone(unsigned i) const;
00492
00497 BaseInterface* GetIKGoal() { return ikGoal; }
00502 void SetIKGoal(BaseInterface* ikgoal) { ikGoal = ikgoal; }
00504 CoreExport void ReleaseIKGoal();
00505 protected:
00506 CoreExport void SetLinkCount(unsigned lc);
00507 private:
00508 Link* links;
00509 unsigned linkCount;
00510 BaseInterface* ikGoal;
00511 };
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00569 class IterJoint : public MaxHeapOperators
00570 {
00571 public:
00572 struct JointAxes : public MaxHeapOperators {
00573 char& operator[](int i) { return mAxes[i]; }
00574 char mAxes[3];
00575 };
00576 enum JointType
00577 {
00578 SlidingJoint,
00579 RotationalJoint
00580 };
00581
00582 IterJoint(LinkChain& lc)
00583 : mLinkChain(lc) , mSkipSlide(false)
00584 {
00585
00586 }
00587
00589 CoreExport void InitJointAngles();
00590
00598 void SetSkipSliding(bool skip) { mSkipSlide = skip; }
00599
00604 CoreExport void Begin(bool in_world);
00605
00607 CoreExport JointType GetJointType() const;
00608
00614 int DofCount() const { return mBegin == -1 ? 3: mEnd - mBegin; }
00615
00617 CoreExport JointAxes GetJointAxes() const;
00618
00625 const Matrix3& ProximalFrame() const { return mMat0; }
00626
00629 const Matrix3& DistalFrame() const { return mMat; }
00630
00633 Point3 Pivot() const { return mMat0.GetTrans(); }
00634
00637 Point3 DistalEnd() const { return mMat.GetTrans(); }
00638
00642 CoreExport void SetJointAngles(const Point3&);
00643
00645 CoreExport Point3 GetJointAngles() const;
00646
00650 CoreExport bool Next();
00651
00652 protected:
00653 CoreExport void SkipSliding();
00654
00655 private:
00656
00657 IterJoint& operator=(const IterJoint& );
00658 Matrix3 mMat0;
00659 Matrix3 mMat;
00660 LinkChain& mLinkChain;
00661 bool mSkipSlide;
00662 short mBegin;
00663 short mEnd;
00664 short mNext;
00665 };
00666
00667
00668
00677 class IIKGoal : public BaseInterface {
00678 public:
00686 BaseInterface* GetInterface(Interface_ID id) { if (id == kGoalID) return this; else return BaseInterface::GetInterface(id); }
00689 Interface_ID GetID() { return kGoalID; }
00693 LifetimeType LifetimeControl() { return wantsRelease; }
00695 CoreExport void ReleaseInterface();
00699 virtual ~IIKGoal() {}
00700 };
00701
00716 class IHIIKGoal: public IIKGoal {
00717 public:
00718
00719 BaseInterface* GetInterface(Interface_ID id) { if (id == kHIIKGoalID) return this; else return IIKGoal::GetInterface(id); }
00720 Interface_ID GetID() { return kHIIKGoalID; }
00721
00727 virtual bool UseVHTarget() const =0;
00729 virtual float SwivelAngle() const =0;
00731 virtual const Point3& VHTarget() const =0;
00734 virtual SAParentSpace SwivelAngleParent() const =0;
00738 virtual const Point3& ChainNormal() const =0;
00741 virtual const ZeroPlaneMap* DefaultZeroMap() const =0;
00743 virtual Matrix3& Goal() =0;
00744 };
00745
00746
00753 class ISplineIKGoal: public IIKGoal {
00754 public:
00755
00756 BaseInterface* GetInterface(Interface_ID id) { if (id == kSplineIKGoalID) return this; else return IIKGoal::GetInterface(id); }
00757 Interface_ID GetID() { return kSplineIKGoalID; }
00758
00760 virtual float StartParam() const = 0;
00761 virtual float EndParam() const = 0;
00762
00768 virtual Point3 SplinePosAt(float, BOOL, BOOL = FALSE) const = 0;
00773 virtual Point3 SplineTangentAt(float, BOOL) const = 0;
00777 virtual const Matrix3& Goal() const = 0;
00780 virtual INode* GetGoalNode() const = 0;
00783 virtual IIKChainControl* GetChainControl() = 0;
00787 virtual float GetSplineLength() const = 0;
00790 virtual float TwistHStartAngle() const = 0;
00793 virtual float TwistHEndAngle() const = 0;
00796 virtual INode* StartJoint() const = 0;
00799 virtual INode* EndJoint() const = 0;
00802 virtual const ZeroPlaneMap* DefaultZeroMap() const = 0;
00804 virtual BOOL IsClosed() const = 0;
00805 virtual const Matrix3& TwistParent() const = 0;
00806 };
00807
00809
00812
00813 class ISplineIKGoal2: public ISplineIKGoal {
00814 public:
00815 Interface_ID GetID() { return IID_SPLINE_IKGOAL2; }
00816
00819 virtual const TimeValue& GetSolveTime() const = 0;
00820 };
00821
00822 CoreExport IterJoint::JointType DofType(Link::DofAxis axis);
00823
00824 };