Blender V2.61 - r43446

BL_ActionManager.cpp

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 #include "BL_ActionManager.h"
00028 
00029 BL_ActionManager::BL_ActionManager(class KX_GameObject *obj)
00030 {
00031     for (int i=0; i<MAX_ACTION_LAYERS; ++i)
00032         m_layers[i] = new BL_Action(obj);
00033 }
00034 
00035 BL_ActionManager::~BL_ActionManager()
00036 {
00037     for (int i=0; i<MAX_ACTION_LAYERS; ++i)
00038         delete m_layers[i];
00039 }
00040 
00041 float BL_ActionManager::GetActionFrame(short layer)
00042 {
00043     return m_layers[layer]->GetFrame();
00044 
00045     return 0.f;
00046 }
00047 
00048 void BL_ActionManager::SetActionFrame(short layer, float frame)
00049 {
00050     m_layers[layer]->SetFrame(frame);
00051 }
00052 
00053 struct bAction *BL_ActionManager::GetCurrentAction(short layer)
00054 {
00055     return m_layers[layer]->GetAction();
00056     
00057     return 0;
00058 }
00059 
00060 void BL_ActionManager::SetPlayMode(short layer, short mode)
00061 {
00062     m_layers[layer]->SetPlayMode(mode);
00063 }
00064 
00065 void BL_ActionManager::SetTimes(short layer, float start, float end)
00066 {
00067     m_layers[layer]->SetTimes(start, end);
00068 }
00069 
00070 bool BL_ActionManager::PlayAction(const char* name,
00071                                 float start,
00072                                 float end,
00073                                 short layer,
00074                                 short priority,
00075                                 float blendin,
00076                                 short play_mode,
00077                                 float layer_weight,
00078                                 short ipo_flags,
00079                                 float playback_speed)
00080 {
00081     // Disable layer blending on the first layer
00082     if (layer == 0) layer_weight = -1.f;
00083 
00084     return m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, layer_weight, ipo_flags, playback_speed);
00085 }
00086 
00087 void BL_ActionManager::StopAction(short layer)
00088 {
00089     m_layers[layer]->Stop();
00090 }
00091 
00092 bool BL_ActionManager::IsActionDone(short layer)
00093 {
00094     return m_layers[layer]->IsDone();
00095 
00096     return true;
00097 }
00098 
00099 void BL_ActionManager::Update(float curtime)
00100 {
00101     for (int i=0; i<MAX_ACTION_LAYERS; ++i)
00102     {
00103         if (!m_layers[i]->IsDone())
00104         {
00105             m_layers[i]->Update(curtime);
00106         }
00107     }
00108 }