Blender V2.61 - r43446

BL_ShapeActionActuator.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_SHAPEACTIONACTUATOR
00033 #define BL_SHAPEACTIONACTUATOR
00034 
00035 #include "CTR_HashedPtr.h"
00036 #include "SCA_IActuator.h"
00037 #include "BL_ActionActuator.h"
00038 #include "MT_Point3.h"
00039 #include <vector>
00040 
00041 struct Key;
00042 class BL_ShapeActionActuator : public SCA_IActuator  
00043 {
00044 public:
00045     Py_Header
00046     BL_ShapeActionActuator(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                         float   stride);
00056     virtual ~BL_ShapeActionActuator();
00057     virtual bool Update(double curtime, bool frame);
00058     virtual CValue* GetReplica();
00059     virtual void ProcessReplica();
00060     
00061     void SetBlendTime (float newtime);
00062     void BlendShape(struct Key* key, float weigth);
00063     
00064     bAction*    GetAction() { return m_action; }
00065     void        SetAction(bAction* act) { m_action= act; }
00066 
00067 #ifdef WITH_PYTHON
00068 
00069     static PyObject*    pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
00070     static int          pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
00071 
00072     static int CheckBlendTime(void *self, const PyAttributeDef*)
00073     {
00074         BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
00075 
00076         if (act->m_blendframe > act->m_blendin)
00077             act->m_blendframe = act->m_blendin;
00078 
00079         return 0;
00080     }
00081     static int CheckFrame(void *self, const PyAttributeDef*)
00082     {
00083         BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
00084 
00085         if (act->m_localtime < act->m_startframe)
00086             act->m_localtime = act->m_startframe;
00087         else if (act->m_localtime > act->m_endframe)
00088             act->m_localtime = act->m_endframe;
00089 
00090         return 0;
00091     }
00092     static int CheckType(void *self, const PyAttributeDef*)
00093     {
00094         BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
00095 
00096         switch (act->m_playtype) {
00097             case ACT_ACTION_PLAY:
00098             case ACT_ACTION_PINGPONG:
00099             case ACT_ACTION_FLIPPER:
00100             case ACT_ACTION_LOOP_STOP:
00101             case ACT_ACTION_LOOP_END:
00102             case ACT_ACTION_FROM_PROP:
00103                 return 0;
00104             default:
00105                 PyErr_SetString(PyExc_ValueError, "Shape Action Actuator, invalid play type supplied");
00106                 return 1;
00107         }
00108 
00109     }
00110 
00111 #endif // WITH_PYTHON
00112 
00113 protected:
00114 
00115     void SetStartTime(float curtime);
00116     void SetLocalTime(float curtime);
00117     bool ClampLocalTime();
00118 
00119     MT_Point3   m_lastpos;
00120     float   m_blendframe;
00121     int     m_flag;
00123     float   m_startframe;
00125     float   m_endframe;
00127     float   m_starttime;
00129     float   m_localtime;
00130     
00131     float   m_lastUpdate;
00132     float   m_blendin;
00133     float   m_blendstart;
00134     float   m_stridelength;
00135     short   m_playtype;
00136     short   m_priority;
00137     struct bAction *m_action;
00138     STR_String  m_framepropname;
00139     STR_String  m_propname;
00140     vector<float> m_blendshape;
00141     struct PointerRNA *m_idptr;
00142 };
00143 
00144 #endif
00145