Blender V2.61 - r43446

BL_ActionActuator.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef BL_ACTIONACTUATOR
00033 #define BL_ACTIONACTUATOR
00034 
00035 #include "CTR_HashedPtr.h"
00036 #include "SCA_IActuator.h"
00037 #include "DNA_actuator_types.h"
00038 #include "MT_Point3.h"
00039 
00040 class BL_ActionActuator : public SCA_IActuator  
00041 {
00042 public:
00043     Py_Header
00044     BL_ActionActuator(SCA_IObject* gameobj,
00045                         const STR_String& propname,
00046                         const STR_String& framepropname,
00047                         float starttime,
00048                         float endtime,
00049                         struct bAction *action,
00050                         short   playtype,
00051                         short   blendin,
00052                         short   priority,
00053                         short   layer,
00054                         float   layer_weight,
00055                         short   ipo_flags,
00056                         short   end_reset,
00057                         float   stride);
00058 
00059     virtual ~BL_ActionActuator();
00060     virtual bool Update(double curtime, bool frame);
00061     virtual CValue* GetReplica();
00062     virtual void ProcessReplica();
00063     
00064     void SetBlendTime (float newtime);
00065     void SetLocalTime (float curtime);
00066     void ResetStartTime (float curtime);
00067     
00068     bAction*    GetAction() { return m_action; }
00069     void        SetAction(bAction* act) { m_action= act; }
00070 
00071 #ifdef WITH_PYTHON
00072 
00073     KX_PYMETHOD_O(BL_ActionActuator,GetChannel)
00074     KX_PYMETHOD_DOC(BL_ActionActuator,setChannel)
00075 
00076     static PyObject*    pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
00077     static int          pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
00078     static PyObject*    pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
00079     static PyObject*    pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
00080     static int          pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
00081     static PyObject*    pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
00082     static int          pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
00083 
00084     static int CheckBlendTime(void *self, const PyAttributeDef*)
00085     {
00086         BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
00087 
00088         if (act->m_blendframe > act->m_blendin)
00089             act->m_blendframe = act->m_blendin;
00090 
00091         return 0;
00092     }
00093 
00094     static int CheckType(void *self, const PyAttributeDef*)
00095     {
00096         BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
00097 
00098         switch (act->m_playtype) {
00099             case ACT_ACTION_PLAY:
00100             case ACT_ACTION_PINGPONG:
00101             case ACT_ACTION_FLIPPER:
00102             case ACT_ACTION_LOOP_STOP:
00103             case ACT_ACTION_LOOP_END:
00104             case ACT_ACTION_FROM_PROP:
00105                 return 0;
00106             default:
00107                 PyErr_SetString(PyExc_ValueError, "Action Actuator, invalid play type supplied");
00108                 return 1;
00109         }
00110     }
00111 #endif // WITH_PYTHON
00112     
00113 protected:
00114     MT_Point3   m_lastpos;
00115     float   m_blendframe;
00116     int     m_flag;
00118     float   m_startframe;
00120     float   m_endframe;
00122     float   m_starttime;
00124     float   m_localtime;
00125     
00126     float   m_lastUpdate;
00127     float   m_blendin;
00128     float   m_blendstart;
00129     float   m_stridelength;
00130     float   m_layer_weight;
00131     short   m_playtype;
00132     short   m_priority;
00133     short   m_layer;
00134     short   m_ipo_flags;
00135     struct bPose* m_pose;
00136     struct bPose* m_blendpose;
00137     struct bPose* m_userpose;
00138     struct bAction *m_action;
00139     STR_String  m_propname;
00140     STR_String  m_framepropname;
00141 };
00142 
00143 // Not all of these values are used in BL_ActionActuator anymore,
00144 // but BL_ShapeActionActuator still uses them, so we keep them around
00145 // for now.
00146 enum {
00147     ACT_FLAG_REVERSE    = 1<<0,
00148     ACT_FLAG_LOCKINPUT  = 1<<1,
00149     ACT_FLAG_KEYUP      = 1<<2,
00150     ACT_FLAG_ACTIVE     = 1<<3,
00151     ACT_FLAG_CONTINUE   = 1<<4,
00152     ACT_FLAG_PLAY_END   = 1<<5,
00153     ACT_FLAG_ATTEMPT_PLAY = 1<<6,
00154 };
00155 
00156 #endif
00157