BL_ArmatureActuator.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_ArmatureActuator.h
  28. * \ingroup bgeconv
  29. */
  30. #ifndef __BL_ARMATUREACTUATOR_H__
  31. #define __BL_ARMATUREACTUATOR_H__
  32. #include "SCA_IActuator.h"
  33. #include "BL_ArmatureConstraint.h"
  34. /**
  35. * This class is the conversion of the Pose channel constraint.
  36. * It makes a link between the pose constraint and the KX scene.
  37. * The main purpose is to give access to the constraint target
  38. * to link it to a game object.
  39. * It also allows to activate/deactivate constraints during the game.
  40. * Later it will also be possible to create constraint on the fly
  41. */
  42. class BL_ArmatureActuator : public SCA_IActuator
  43. {
  44. Py_Header
  45. public:
  46. BL_ArmatureActuator(SCA_IObject* gameobj,
  47. int type,
  48. const char *posechannel,
  49. const char *constraintname,
  50. KX_GameObject* targetobj,
  51. KX_GameObject* subtargetobj,
  52. float weight,
  53. float influence);
  54. virtual ~BL_ArmatureActuator();
  55. virtual CValue* GetReplica() {
  56. BL_ArmatureActuator* replica = new BL_ArmatureActuator(*this);
  57. replica->ProcessReplica();
  58. return replica;
  59. };
  60. virtual void ProcessReplica();
  61. virtual bool UnlinkObject(SCA_IObject* clientobj);
  62. virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
  63. virtual bool Update(double curtime, bool frame);
  64. virtual void ReParent(SCA_IObject* parent);
  65. #ifdef WITH_PYTHON
  66. /* These are used to get and set m_target */
  67. static PyObject *pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
  68. static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
  69. static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
  70. #endif /* WITH_PYTHON */
  71. private:
  72. // identify the constraint that this actuator controls
  73. void FindConstraint();
  74. BL_ArmatureConstraint* m_constraint;
  75. KX_GameObject* m_gametarget;
  76. KX_GameObject* m_gamesubtarget;
  77. STR_String m_posechannel;
  78. STR_String m_constraintname;
  79. float m_weight;
  80. float m_influence;
  81. int m_type;
  82. };
  83. #endif /* __BL_ARMATUREACTUATOR_H__ */