Blender V2.61 - r43446

BL_Action.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  * Contributor(s): Mitchell Stokes.
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00027 #ifndef __BL_ACTION
00028 #define __BL_ACTION
00029 
00030 
00031 #include <vector>
00032 
00033 #ifdef WITH_CXX_GUARDEDALLOC
00034 #include "MEM_guardedalloc.h"
00035 #endif
00036 
00037 
00038 class BL_Action
00039 {
00040 private:
00041     struct bAction* m_action;
00042     struct bPose* m_pose;
00043     struct bPose* m_blendpose;
00044     struct bPose* m_blendinpose;
00045     struct PointerRNA *m_ptrrna;
00046     std::vector<class SG_Controller*> m_sg_contr_list;
00047     class KX_GameObject* m_obj;
00048     std::vector<float>  m_blendshape;
00049     std::vector<float>  m_blendinshape;
00050 
00051     float m_startframe;
00052     float m_endframe;
00053     float m_starttime;
00054     float m_endtime;
00055     float m_localtime;
00056 
00057     float m_blendin;
00058     float m_blendframe;
00059     float m_blendstart;
00060 
00061     float m_layer_weight;
00062 
00063     float m_speed;
00064 
00065     short m_priority;
00066 
00067     short m_playmode;
00068 
00069     short m_ipo_flags;
00070 
00071     bool m_done;
00072     bool m_calc_localtime;
00073 
00074     void ClearControllerList();
00075     void InitIPO();
00076     void SetLocalTime(float curtime);
00077     void ResetStartTime(float curtime);
00078     void IncrementBlending(float curtime);
00079     void BlendShape(struct Key* key, float srcweight, std::vector<float>& blendshape);
00080 public:
00081     BL_Action(class KX_GameObject* gameobj);
00082     ~BL_Action();
00083 
00087     bool Play(const char* name,
00088             float start,
00089             float end,
00090             short priority,
00091             float blendin,
00092             short play_mode,
00093             float layer_weight,
00094             short ipo_flags,
00095             float playback_speed);
00099     void Stop();
00103     bool IsDone();
00107     void Update(float curtime);
00108 
00109     // Accessors
00110     float GetFrame();
00111     struct bAction *GetAction();
00112 
00113     // Mutators
00114     void SetFrame(float frame);
00115     void SetPlayMode(short play_mode);
00116     void SetTimes(float start, float end);
00117 
00118     enum 
00119     {
00120         ACT_MODE_PLAY = 0,
00121         ACT_MODE_LOOP,
00122         ACT_MODE_PING_PONG,
00123         ACT_MODE_MAX,
00124     };
00125 
00126     enum
00127     {
00128         ACT_IPOFLAG_FORCE = 1,
00129         ACT_IPOFLAG_LOCAL = 2,
00130         ACT_IPOFLAG_ADD = 4,
00131         ACT_IPOFLAG_CHILD = 8,
00132     };
00133 
00134 #ifdef WITH_CXX_GUARDEDALLOC
00135 public:
00136     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Action"); }
00137     void operator delete( void *mem ) { MEM_freeN(mem); }
00138 #endif
00139 };
00140 
00141 #endif //BL_ACTION
00142