Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2011-06-24 02:44:24 +0400
committerMitchell Stokes <mogurijin@gmail.com>2011-06-24 02:44:24 +0400
commitea47125f1630554fa5e69943821bdbe9964a589f (patch)
tree856df0838b732c09c8396a3880dcdd3bca9d3300 /source
parent7996d0447445daaeca1a9e08e3a1e1d901cd7fc9 (diff)
BGE Animations: Exposing KX_GameObject's GetActionFrame() and SetActionFrame() to Python. KX_GameObject.setActionFrame() seems to still have some issues, which I suspect to be a timing thing. I may need to find a better way to set the local time.
Diffstat (limited to 'source')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp31
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h2
2 files changed, 32 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 175a2b6ccdf..07e4523585a 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -1556,6 +1556,8 @@ PyMethodDef KX_GameObject::Methods[] = {
KX_PYMETHODTABLE(KX_GameObject, sendMessage),
KX_PYMETHODTABLE_KEYWORDS(KX_GameObject, playAction),
+ KX_PYMETHODTABLE(KX_GameObject, getActionFrame),
+ KX_PYMETHODTABLE(KX_GameObject, setActionFrame),
// dict style access for props
{"get",(PyCFunction) KX_GameObject::sPyget, METH_VARARGS},
@@ -3046,7 +3048,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, playAction,
static const char *kwlist[] = {"name", "start_frame", "end_frame", "layer", "priority", "blendin", "play_mode", "blend_mode", "ipo_flags", "speed", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hhfhhhf", const_cast<char**>(kwlist),
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hhfhhhf:playAction", const_cast<char**>(kwlist),
&name, &start, &end, &layer, &priority, &blendin, &play_mode, &blend_mode, &ipo_flags, &speed))
return NULL;
@@ -3072,6 +3074,33 @@ KX_PYMETHODDEF_DOC(KX_GameObject, playAction,
Py_RETURN_NONE;
}
+
+KX_PYMETHODDEF_DOC(KX_GameObject, getActionFrame,
+ "getActionFrame(layer)\n"
+ "Gets the current frame of the action playing in the supplied layer")
+{
+ short layer;
+
+ if (!PyArg_ParseTuple(args, "h:getActionFrame", &layer))
+ return NULL;
+
+ return PyLong_FromLong(GetActionFrame(layer));
+}
+
+KX_PYMETHODDEF_DOC(KX_GameObject, setActionFrame,
+ "setActionFrame(layer, frame)\n"
+ "Set the current fram of the action playing in the supplied layer")
+{
+ short layer, frame;
+
+ if (!PyArg_ParseTuple(args, "hh:setActionFrame", &layer, &frame))
+ return NULL;
+
+ SetActionFrame(layer, frame);
+
+ Py_RETURN_NONE;
+}
+
/* dict style access */
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index b5ece5f8ac8..b55b2bba60a 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -908,6 +908,8 @@ public:
KX_PYMETHOD_VARARGS(KX_GameObject, ReinstancePhysicsMesh);
KX_PYMETHOD_DOC(KX_GameObject, playAction);
+ KX_PYMETHOD_DOC(KX_GameObject, getActionFrame);
+ KX_PYMETHOD_DOC(KX_GameObject, setActionFrame);
/* Dict access */
KX_PYMETHOD_VARARGS(KX_GameObject,get);