Newton Dynamics  4.00
ndIk6DofEffector.h
1 /* Copyright (c) <2003-2022> <Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely
10 */
11 
12 #ifndef __ND_IK_6DOF_EFFECTOR_H__
13 #define __ND_IK_6DOF_EFFECTOR_H__
14 
15 #include "ndNewtonStdafx.h"
16 #include "ndJointBilateralConstraint.h"
17 
19 {
20  public:
21  enum ndRotationType
22  {
23  m_disabled,
24  m_fixAxis,
25  m_shortestPath,
26  };
27 
28  D_CLASS_REFLECTION(ndIk6DofEffector);
29  D_NEWTON_API ndIk6DofEffector(const ndLoadSaveBase::ndLoadDescriptor& desc);
30  D_NEWTON_API ndIk6DofEffector(const ndMatrix& pinAndPivotChild, const ndMatrix& pinAndPivotParent, ndBodyKinematic* const child, ndBodyKinematic* const parent);
31  D_NEWTON_API virtual ~ndIk6DofEffector();
32 
33  D_NEWTON_API void EnableAxisX(bool state);
34  D_NEWTON_API void EnableAxisY(bool state);
35  D_NEWTON_API void EnableAxisZ(bool state);
36  D_NEWTON_API void EnableRotationAxis(ndRotationType type);
37 
38  D_NEWTON_API ndMatrix GetOffsetMatrix() const;
39  D_NEWTON_API void SetOffsetMatrix(const ndMatrix& matrix);
40 
41  D_NEWTON_API void SetLinearSpringDamper(ndFloat32 regularizer, ndFloat32 springConst, ndFloat32 damperConst);
42  D_NEWTON_API void GetLinearSpringDamper(ndFloat32& regularizer, ndFloat32& springConst, ndFloat32& damperConst) const;
43 
44  D_NEWTON_API void SetAngularSpringDamper(ndFloat32 regularizer, ndFloat32 springConst, ndFloat32 damperConst);
45  D_NEWTON_API void GetAngularSpringDamper(ndFloat32& regularizer, ndFloat32& springConst, ndFloat32& damperConst) const;
46 
47  D_NEWTON_API ndFloat32 GetMaxForce() const;
48  D_NEWTON_API void SetMaxForce(ndFloat32 force);
49 
50  D_NEWTON_API ndFloat32 GetMaxTorque() const;
51  D_NEWTON_API void SetMaxTorque(ndFloat32 torque);
52 
53  protected:
54  D_NEWTON_API void JacobianDerivative(ndConstraintDescritor& desc);
55  D_NEWTON_API void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
56  D_NEWTON_API void DebugJoint(ndConstraintDebugCallback& debugCallback) const;
57 
58  D_NEWTON_API void SubmitLinearAxis(const ndMatrix& matrix0, const ndMatrix& matrix1, ndConstraintDescritor& desc);
59  D_NEWTON_API void SubmitAngularAxis(const ndMatrix& matrix0, const ndMatrix& matrix1, ndConstraintDescritor& desc);
60  D_NEWTON_API void SubmitShortestPathAxis(const ndMatrix& matrix0, const ndMatrix& matrix1, ndConstraintDescritor& desc);
61 
62  ndMatrix m_targetFrame;
63  ndFloat32 m_angularSpring;
64  ndFloat32 m_angularDamper;
65  ndFloat32 m_angularMaxTorque;
66  ndFloat32 m_angularRegularizer;
67 
68  ndFloat32 m_linearSpring;
69  ndFloat32 m_linearDamper;
70  ndFloat32 m_linearMaxForce;
71  ndFloat32 m_linearRegularizer;
72 
73  ndRotationType m_rotationType;
74  union
75  {
76  ndUnsigned8 m_controlDofOptions;
77  struct
78  {
79  ndUnsigned8 m_axisX : 1;
80  ndUnsigned8 m_axisY : 1;
81  ndUnsigned8 m_axisZ : 1;
82  };
83  };
84 };
85 
86 #endif
87 
ndConstraintDescritor
Definition: ndConstraint.h:179
ndJointBilateralConstraint
Definition: ndJointBilateralConstraint.h:53
ndConstraintDebugCallback
Definition: ndConstraint.h:42
ndBodyKinematic
Definition: ndBodyKinematic.h:40
ndMatrix
Definition: ndMatrix.h:42
ndIk6DofEffector
Definition: ndIk6DofEffector.h:19
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93