|
Blender
V2.59
|
00001 /* 00002 * $Id: BL_ActionActuator.h 36523 2011-05-06 20:18:42Z blendix $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 #ifndef BL_ACTIONACTUATOR 00035 #define BL_ACTIONACTUATOR 00036 00037 #include "CTR_HashedPtr.h" 00038 #include "SCA_IActuator.h" 00039 #include "DNA_actuator_types.h" 00040 #include "MT_Point3.h" 00041 00042 class BL_ActionActuator : public SCA_IActuator 00043 { 00044 public: 00045 Py_Header; 00046 BL_ActionActuator(SCA_IObject* gameobj, 00047 const STR_String& propname, 00048 const STR_String& framepropname, 00049 float starttime, 00050 float endtime, 00051 struct bAction *action, 00052 short playtype, 00053 short blendin, 00054 short priority, 00055 short end_reset, 00056 float stride) 00057 : SCA_IActuator(gameobj, KX_ACT_ACTION), 00058 00059 m_lastpos(0, 0, 0), 00060 m_blendframe(0), 00061 m_flag(0), 00062 m_startframe (starttime), 00063 m_endframe(endtime) , 00064 m_starttime(0), 00065 m_localtime(starttime), 00066 m_lastUpdate(-1), 00067 m_blendin(blendin), 00068 m_blendstart(0), 00069 m_stridelength(stride), 00070 m_playtype(playtype), 00071 m_priority(priority), 00072 m_end_reset(end_reset), 00073 m_pose(NULL), 00074 m_blendpose(NULL), 00075 m_userpose(NULL), 00076 m_action(action), 00077 m_propname(propname), 00078 m_framepropname(framepropname) 00079 { 00080 }; 00081 virtual ~BL_ActionActuator(); 00082 virtual bool Update(double curtime, bool frame); 00083 virtual CValue* GetReplica(); 00084 virtual void ProcessReplica(); 00085 00086 void SetBlendTime (float newtime); 00087 00088 bAction* GetAction() { return m_action; } 00089 void SetAction(bAction* act) { m_action= act; } 00090 00091 #ifdef WITH_PYTHON 00092 00093 KX_PYMETHOD_O(BL_ActionActuator,GetChannel); 00094 KX_PYMETHOD_DOC(BL_ActionActuator,setChannel); 00095 00096 static PyObject* pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00097 static int pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00098 static PyObject* pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00099 /* attribute check */ 00100 static int CheckFrame(void *self, const PyAttributeDef*) 00101 { 00102 BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self); 00103 00104 if (act->m_localtime < act->m_startframe) 00105 act->m_localtime = act->m_startframe; 00106 else if (act->m_localtime > act->m_endframe) 00107 act->m_localtime = act->m_endframe; 00108 00109 return 0; 00110 } 00111 00112 static int CheckBlendTime(void *self, const PyAttributeDef*) 00113 { 00114 BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self); 00115 00116 if (act->m_blendframe > act->m_blendin) 00117 act->m_blendframe = act->m_blendin; 00118 00119 return 0; 00120 } 00121 00122 static int CheckType(void *self, const PyAttributeDef*) 00123 { 00124 BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self); 00125 00126 switch (act->m_playtype) { 00127 case ACT_ACTION_PLAY: 00128 case ACT_ACTION_PINGPONG: 00129 case ACT_ACTION_FLIPPER: 00130 case ACT_ACTION_LOOP_STOP: 00131 case ACT_ACTION_LOOP_END: 00132 case ACT_ACTION_FROM_PROP: 00133 return 0; 00134 default: 00135 PyErr_SetString(PyExc_ValueError, "Action Actuator, invalid play type supplied"); 00136 return 1; 00137 } 00138 } 00139 #endif // WITH_PYTHON 00140 00141 protected: 00142 00143 void SetStartTime(float curtime); 00144 void SetLocalTime(float curtime); 00145 bool ClampLocalTime(); 00146 00147 MT_Point3 m_lastpos; 00148 float m_blendframe; 00149 int m_flag; 00151 float m_startframe; 00153 float m_endframe; 00155 float m_starttime; 00157 float m_localtime; 00158 00159 float m_lastUpdate; 00160 float m_blendin; 00161 float m_blendstart; 00162 float m_stridelength; 00163 short m_playtype; 00164 short m_priority; 00165 bool m_end_reset; 00166 struct bPose* m_pose; 00167 struct bPose* m_blendpose; 00168 struct bPose* m_userpose; 00169 struct bAction *m_action; 00170 STR_String m_propname; 00171 STR_String m_framepropname; 00172 }; 00173 00174 enum { 00175 ACT_FLAG_REVERSE = 0x00000001, 00176 ACT_FLAG_LOCKINPUT = 0x00000002, 00177 ACT_FLAG_KEYUP = 0x00000004, 00178 ACT_FLAG_ACTIVE = 0x00000008 00179 }; 00180 00181 #endif 00182