2011-05-24 07:52:29 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
2011-07-07 03:53:24 +00:00
|
|
|
* Contributor(s): Mitchell Stokes.
|
2011-05-24 07:52:29 +00:00
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-07-07 03:53:24 +00:00
|
|
|
/** \file BL_ActionManager.cpp
|
|
|
|
* \ingroup ketsji
|
|
|
|
*/
|
|
|
|
|
2011-05-24 07:52:29 +00:00
|
|
|
#include "BL_ActionManager.h"
|
|
|
|
|
2011-06-11 00:14:47 +00:00
|
|
|
BL_ActionManager::BL_ActionManager(class KX_GameObject *obj)
|
2011-05-24 07:52:29 +00:00
|
|
|
{
|
|
|
|
for (int i=0; i<MAX_ACTION_LAYERS; ++i)
|
2011-06-11 00:14:47 +00:00
|
|
|
m_layers[i] = new BL_Action(obj);
|
2011-05-24 07:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BL_ActionManager::~BL_ActionManager()
|
|
|
|
{
|
|
|
|
for (int i=0; i<MAX_ACTION_LAYERS; ++i)
|
2011-08-29 06:19:55 +00:00
|
|
|
delete m_layers[i];
|
2011-05-24 07:52:29 +00:00
|
|
|
}
|
|
|
|
|
2011-06-01 07:42:40 +00:00
|
|
|
float BL_ActionManager::GetActionFrame(short layer)
|
|
|
|
{
|
2011-08-29 06:19:55 +00:00
|
|
|
return m_layers[layer]->GetFrame();
|
2011-06-01 07:42:40 +00:00
|
|
|
|
|
|
|
return 0.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_ActionManager::SetActionFrame(short layer, float frame)
|
|
|
|
{
|
2011-08-29 06:19:55 +00:00
|
|
|
m_layers[layer]->SetFrame(frame);
|
2011-06-01 07:42:40 +00:00
|
|
|
}
|
|
|
|
|
2011-07-05 05:22:02 +00:00
|
|
|
struct bAction *BL_ActionManager::GetCurrentAction(short layer)
|
|
|
|
{
|
2011-08-29 06:19:55 +00:00
|
|
|
return m_layers[layer]->GetAction();
|
2011-07-29 21:58:31 +00:00
|
|
|
|
2011-07-30 17:27:54 +00:00
|
|
|
return 0;
|
2011-07-05 05:22:02 +00:00
|
|
|
}
|
|
|
|
|
2011-08-08 04:28:30 +00:00
|
|
|
void BL_ActionManager::SetPlayMode(short layer, short mode)
|
|
|
|
{
|
2011-08-29 06:19:55 +00:00
|
|
|
m_layers[layer]->SetPlayMode(mode);
|
2011-08-08 04:28:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BL_ActionManager::SetTimes(short layer, float start, float end)
|
|
|
|
{
|
2011-08-29 06:19:55 +00:00
|
|
|
m_layers[layer]->SetTimes(start, end);
|
2011-08-08 04:28:30 +00:00
|
|
|
}
|
|
|
|
|
2011-06-29 01:53:17 +00:00
|
|
|
bool BL_ActionManager::PlayAction(const char* name,
|
2011-05-24 07:52:29 +00:00
|
|
|
float start,
|
|
|
|
float end,
|
|
|
|
short layer,
|
2011-06-23 22:12:49 +00:00
|
|
|
short priority,
|
2011-05-24 07:52:29 +00:00
|
|
|
float blendin,
|
|
|
|
short play_mode,
|
2011-07-03 01:59:17 +00:00
|
|
|
float layer_weight,
|
2011-06-16 01:18:52 +00:00
|
|
|
short ipo_flags,
|
2011-05-28 07:15:27 +00:00
|
|
|
float playback_speed)
|
2011-05-24 07:52:29 +00:00
|
|
|
{
|
2011-06-29 02:42:46 +00:00
|
|
|
// Disable layer blending on the first layer
|
2011-07-03 01:59:17 +00:00
|
|
|
if (layer == 0) layer_weight = -1.f;
|
2011-06-29 02:42:46 +00:00
|
|
|
|
2011-07-03 01:59:17 +00:00
|
|
|
return m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, layer_weight, ipo_flags, playback_speed);
|
2011-05-24 07:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BL_ActionManager::StopAction(short layer)
|
|
|
|
{
|
2011-06-11 00:14:47 +00:00
|
|
|
m_layers[layer]->Stop();
|
2011-05-24 07:52:29 +00:00
|
|
|
}
|
|
|
|
|
2011-06-01 05:46:19 +00:00
|
|
|
bool BL_ActionManager::IsActionDone(short layer)
|
|
|
|
{
|
2011-08-29 06:19:55 +00:00
|
|
|
return m_layers[layer]->IsDone();
|
2011-06-01 05:46:19 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-05-24 07:52:29 +00:00
|
|
|
void BL_ActionManager::Update(float curtime)
|
|
|
|
{
|
|
|
|
for (int i=0; i<MAX_ACTION_LAYERS; ++i)
|
|
|
|
{
|
2011-06-11 00:14:47 +00:00
|
|
|
if (!m_layers[i]->IsDone())
|
2011-05-24 07:52:29 +00:00
|
|
|
{
|
2011-06-11 00:14:47 +00:00
|
|
|
m_layers[i]->Update(curtime);
|
2011-05-24 07:52:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|