BL_ArmatureConstraint.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  19. * All rights reserved.
  20. *
  21. * The Original Code is: all of this file.
  22. *
  23. * Contributor(s): none yet.
  24. *
  25. * ***** END GPL LICENSE BLOCK *****
  26. */
  27. /** \file BL_ArmatureConstraint.h
  28. * \ingroup bgeconv
  29. */
  30. #ifndef __BL_ARMATURECONSTRAINT_H__
  31. #define __BL_ARMATURECONSTRAINT_H__
  32. #include "DNA_constraint_types.h"
  33. #include "CTR_HashedPtr.h"
  34. #include "CTR_Map.h"
  35. #include "EXP_PyObjectPlus.h"
  36. class SCA_IObject;
  37. class KX_GameObject;
  38. class BL_ArmatureObject;
  39. struct bConstraint;
  40. struct bPoseChannel;
  41. struct Object;
  42. struct bPose;
  43. /**
  44. * SG_DList : element of controlled constraint list
  45. * head = BL_ArmatureObject::m_controlledConstraints
  46. * SG_QList : not used
  47. */
  48. class BL_ArmatureConstraint : public PyObjectPlus
  49. {
  50. Py_Header
  51. private:
  52. struct bConstraint* m_constraint;
  53. struct bPoseChannel* m_posechannel;
  54. class BL_ArmatureObject* m_armature;
  55. char m_name[64];
  56. KX_GameObject* m_target;
  57. KX_GameObject* m_subtarget;
  58. struct Object* m_blendtarget;
  59. struct Object* m_blendsubtarget;
  60. float m_blendmat[4][4];
  61. float m_blendsubmat[4][4];
  62. struct bPose* m_pose;
  63. struct bPose* m_subpose;
  64. public:
  65. BL_ArmatureConstraint(class BL_ArmatureObject *armature,
  66. struct bPoseChannel *posechannel,
  67. struct bConstraint *constraint,
  68. KX_GameObject* target,
  69. KX_GameObject* subtarget);
  70. virtual ~BL_ArmatureConstraint();
  71. BL_ArmatureConstraint* GetReplica() const;
  72. void ReParent(BL_ArmatureObject* armature);
  73. void Relink(CTR_Map<CTR_HashedPtr, void*> *map);
  74. bool UnlinkObject(SCA_IObject* clientobj);
  75. void UpdateTarget();
  76. void RestoreTarget();
  77. bool Match(const char* posechannel, const char* constraint);
  78. const char* GetName() { return m_name; }
  79. void SetConstraintFlag(int flag)
  80. {
  81. if (m_constraint)
  82. m_constraint->flag |= flag;
  83. }
  84. void ClrConstraintFlag(int flag)
  85. {
  86. if (m_constraint)
  87. m_constraint->flag &= ~flag;
  88. }
  89. void SetWeight(float weight)
  90. {
  91. if (m_constraint && m_constraint->type == CONSTRAINT_TYPE_KINEMATIC && m_constraint->data) {
  92. bKinematicConstraint* con = (bKinematicConstraint*)m_constraint->data;
  93. con->weight = weight;
  94. }
  95. }
  96. void SetInfluence(float influence)
  97. {
  98. if (m_constraint)
  99. m_constraint->enforce = influence;
  100. }
  101. void SetTarget(KX_GameObject* target);
  102. void SetSubtarget(KX_GameObject* subtarget);
  103. #ifdef WITH_PYTHON
  104. // Python access
  105. virtual PyObject *py_repr(void);
  106. static PyObject *py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
  107. static int py_attr_setattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
  108. #endif /* WITH_PYTHON */
  109. };
  110. #endif /* __BL_ARMATURECONSTRAINT_H__ */