[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37775] branches/soc-2011-pepper/source/ gameengine/Ketsji: BGE Animations: Exposing KX_GameObject's GetActionFrame( ) and SetActionFrame() to Python.
Mitchell Stokes
mogurijin at gmail.com
Fri Jun 24 00:44:25 CEST 2011
Revision: 37775
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37775
Author: moguri
Date: 2011-06-23 22:44:24 +0000 (Thu, 23 Jun 2011)
Log Message:
-----------
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.
Modified Paths:
--------------
branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.cpp
branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.h
Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.cpp 2011-06-23 22:33:42 UTC (rev 37774)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.cpp 2011-06-23 22:44:24 UTC (rev 37775)
@@ -1556,6 +1556,8 @@
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 @@
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 @@
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 */
Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.h 2011-06-23 22:33:42 UTC (rev 37774)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.h 2011-06-23 22:44:24 UTC (rev 37775)
@@ -908,6 +908,8 @@
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);
More information about the Bf-blender-cvs
mailing list