From 2bece8dcb5104bc95149b0c40723f1dc855d6b29 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 18 Jun 2008 06:46:49 +0000 Subject: BGE Patch: Add Shape Action support and update MSCV_7 project file for glew. Shape Action are now supported in the BGE. A new type of actuator "Shape Action" is available on mesh objects. It can be combined with Action actuator on parent armature. Only relative keys are supported. All the usual action options are available: type, blending, priority, Python API. Only actions with shape channels should be specified of course, otherwise the actuator has no effect. Shape action will still work after a mesh replacement provided that the new mesh has compatible shape keys. --- .../Converter/BL_DeformableGameObject.cpp | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'source/gameengine/Converter/BL_DeformableGameObject.cpp') diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp index 68a2e41ca47..d23274324ee 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.cpp +++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp @@ -28,6 +28,8 @@ */ #include "BL_DeformableGameObject.h" +#include "BL_ShapeDeformer.h" +#include "BL_ShapeActionActuator.h" #ifdef HAVE_CONFIG_H #include @@ -60,3 +62,48 @@ CValue* BL_DeformableGameObject::GetReplica() ProcessReplica(replica); return replica; } + +bool BL_DeformableGameObject::SetActiveAction(BL_ShapeActionActuator *act, short priority, double curtime) +{ + if (curtime != m_lastframe){ + m_activePriority = 9999; + m_lastframe= curtime; + m_activeAct = NULL; + } + + if (priority<=m_activePriority) + { + if (m_activeAct && (m_activeAct!=act)) + m_activeAct->SetBlendTime(0.0f); /* Reset the blend timer */ + m_activeAct = act; + m_activePriority = priority; + m_lastframe = curtime; + + return true; + } + else{ + act->SetBlendTime(0.0f); + return false; + } +} + +bool BL_DeformableGameObject::GetShape(vector &shape) +{ + shape.clear(); + if (m_pDeformer) + { + Mesh* mesh = ((BL_MeshDeformer*)m_pDeformer)->GetMesh(); + // this check is normally superfluous: a shape deformer can only be created if the mesh + // has relative keys + if (mesh && mesh->key && mesh->key->type==KEY_RELATIVE) + { + KeyBlock *kb; + for (kb = (KeyBlock*)mesh->key->block.first; kb; kb = (KeyBlock*)kb->next) + { + shape.push_back(kb->curval); + } + } + } + return !shape.empty(); +} + -- cgit v1.2.3