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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-04-20 13:13:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-20 13:13:59 +0400
commitdee32d0b3f409007f5a392668068b92c3810026a (patch)
tree3127ac9c88ea9d783282d3bf8ed5ba8f2a40eb43 /source/gameengine/Ketsji/KX_PyMath.cpp
parent9078ce5da209bcfd31c60b55118076359ce7244f (diff)
BGE Python API
- initialize pythons sys.argv in the blenderplayer - ignore all arguments after a single " - " in the blenderplayer (like in blender), so args can be passed to the game. - add a utility function PyOrientationTo() - to take a Py euler, quat or 3x3 matrix and convert into a C++ MT_Matrix3x3. - add utility function ConvertPythonToMesh to get a RAS_MeshObject from a KX_MeshProxy or a name. - Added error prefix arguments to ConvertPythonToGameObject, ConvertPythonToMesh and PyOrientationTo so the error messages can include what function they came from. - deprecated brick.getOwner() for the "owner" attribute.
Diffstat (limited to 'source/gameengine/Ketsji/KX_PyMath.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp
index cceb7a12446..0093a72808e 100644
--- a/source/gameengine/Ketsji/KX_PyMath.cpp
+++ b/source/gameengine/Ketsji/KX_PyMath.cpp
@@ -44,6 +44,7 @@
#include "ListValue.h"
#include "KX_Python.h"
+#include "KX_PyMath.h"
bool PyObject_IsMT_Matrix(PyObject *pymat, unsigned int rank)
{
@@ -74,6 +75,39 @@ bool PyObject_IsMT_Matrix(PyObject *pymat, unsigned int rank)
return false;
}
+bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &mat, const char *error_prefix)
+{
+ MT_Matrix3x3 rot;
+ int size= PySequence_Size(pyval);
+
+ if (size == 4)
+ {
+ MT_Quaternion qrot;
+ if (PyVecTo(pyval, qrot))
+ {
+ rot.setRotation(qrot);
+ return true;
+ }
+ }
+ else if (size == 3) {
+ /* 3x3 matrix or euler */
+ MT_Vector3 erot;
+ if (PyVecTo(pyval, erot))
+ {
+ rot.setEuler(erot);
+ return true;
+ }
+ PyErr_Clear();
+
+ if (PyMatTo(pyval, rot))
+ {
+ return true;
+ }
+ }
+
+ PyErr_Format(PyExc_TypeError, "%s, could not set the orientation from a 3x3 matrix, quaternion or euler sequence", error_prefix);
+ return false;
+}
PyObject* PyObjectFrom(const MT_Matrix4x4 &mat)
{