BL_ShapeActionActuator.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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_ShapeActionActuator.h
  28. * \ingroup bgeconv
  29. */
  30. #ifndef __BL_SHAPEACTIONACTUATOR_H__
  31. #define __BL_SHAPEACTIONACTUATOR_H__
  32. #include "CTR_HashedPtr.h"
  33. #include "SCA_IActuator.h"
  34. #include "BL_ActionActuator.h"
  35. #include "MT_Point3.h"
  36. #include <vector>
  37. struct Key;
  38. class BL_ShapeActionActuator : public SCA_IActuator
  39. {
  40. public:
  41. Py_Header
  42. BL_ShapeActionActuator(SCA_IObject* gameobj,
  43. const STR_String& propname,
  44. const STR_String& framepropname,
  45. float starttime,
  46. float endtime,
  47. struct bAction *action,
  48. short playtype,
  49. short blendin,
  50. short priority,
  51. float stride);
  52. virtual ~BL_ShapeActionActuator();
  53. virtual bool Update(double curtime, bool frame);
  54. virtual CValue* GetReplica();
  55. virtual void ProcessReplica();
  56. void SetBlendTime (float newtime);
  57. void BlendShape(struct Key* key, float weight);
  58. bAction* GetAction() { return m_action; }
  59. void SetAction(bAction* act) { m_action= act; }
  60. #ifdef WITH_PYTHON
  61. static PyObject* pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
  62. static int pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
  63. static int CheckBlendTime(void *self, const PyAttributeDef*)
  64. {
  65. BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
  66. if (act->m_blendframe > act->m_blendin)
  67. act->m_blendframe = act->m_blendin;
  68. return 0;
  69. }
  70. static int CheckFrame(void *self, const PyAttributeDef*)
  71. {
  72. BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
  73. if (act->m_localtime < act->m_startframe)
  74. act->m_localtime = act->m_startframe;
  75. else if (act->m_localtime > act->m_endframe)
  76. act->m_localtime = act->m_endframe;
  77. return 0;
  78. }
  79. static int CheckType(void *self, const PyAttributeDef*)
  80. {
  81. BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
  82. switch (act->m_playtype) {
  83. case ACT_ACTION_PLAY:
  84. case ACT_ACTION_PINGPONG:
  85. case ACT_ACTION_FLIPPER:
  86. case ACT_ACTION_LOOP_STOP:
  87. case ACT_ACTION_LOOP_END:
  88. case ACT_ACTION_FROM_PROP:
  89. return 0;
  90. default:
  91. PyErr_SetString(PyExc_ValueError, "Shape Action Actuator, invalid play type supplied");
  92. return 1;
  93. }
  94. }
  95. #endif /* WITH_PYTHON */
  96. protected:
  97. void SetStartTime(float curtime);
  98. void SetLocalTime(float curtime);
  99. bool ClampLocalTime();
  100. MT_Point3 m_lastpos;
  101. float m_blendframe;
  102. int m_flag;
  103. /** The frame this action starts */
  104. float m_startframe;
  105. /** The frame this action ends */
  106. float m_endframe;
  107. /** The time this action started */
  108. float m_starttime;
  109. /** The current time of the action */
  110. float m_localtime;
  111. float m_lastUpdate;
  112. float m_blendin;
  113. float m_blendstart;
  114. float m_stridelength;
  115. short m_playtype;
  116. short m_priority;
  117. struct bAction *m_action;
  118. STR_String m_framepropname;
  119. STR_String m_propname;
  120. vector<float> m_blendshape;
  121. struct PointerRNA *m_idptr;
  122. };
  123. #endif /* __BL_SHAPEACTIONACTUATOR_H__ */