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:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-05-30 15:09:46 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-05-30 15:09:46 +0400
commitd38329b5aa6be472ea49c3a52b61875a772a6c9a (patch)
tree8f8ebf5a0438725b6d5398f1cb5d1f3c028ce668 /source/gameengine/Ketsji/KX_PyMath.cpp
parentb97c77df2bafd7add01ea9dc8bfcad1e82714559 (diff)
Added Python module for Lights.
Added attributes to the vertex class.
Diffstat (limited to 'source/gameengine/Ketsji/KX_PyMath.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp
index 11bc5d750ff..ba687744dfc 100644
--- a/source/gameengine/Ketsji/KX_PyMath.cpp
+++ b/source/gameengine/Ketsji/KX_PyMath.cpp
@@ -42,6 +42,7 @@
#include "MT_Vector3.h"
#include "MT_Vector4.h"
#include "MT_Matrix4x4.h"
+#include "MT_Point2.h"
#include "ListValue.h"
@@ -135,6 +136,50 @@ MT_Point3 MT_Point3FromPyList(PyObject* pylist)
return point;
}
+MT_Point2 MT_Point2FromPyList(PyObject* pylist)
+{
+ MT_Point2 point(0., 0.);
+ bool error=false;
+ if (pylist->ob_type == &CListValue::Type)
+ {
+ CListValue* listval = (CListValue*) pylist;
+ unsigned int numitems = listval->GetCount();
+ if (numitems <= 2)
+ {
+ for (unsigned int index=0;index<numitems;index++)
+ {
+ point[index] = listval->GetValue(index)->GetNumber();
+ }
+ } else
+ {
+ error = true;
+ }
+
+ } else
+ {
+ // assert the list is long enough...
+ unsigned int numitems = PySequence_Size(pylist);
+ if (numitems <= 2)
+ {
+ for (unsigned int index=0;index<numitems;index++)
+ {
+ PyObject *item = PySequence_GetItem(pylist,index); /* new ref */
+ point[index] = PyFloat_AsDouble(item);
+ Py_DECREF(item);
+ }
+ }
+ else
+ {
+ error = true;
+ }
+
+ }
+ if (error)
+ PyErr_SetString(PyExc_TypeError, "Expected list of twos items for point argument.");
+
+ return point;
+}
+
MT_Vector4 MT_Vector4FromPyList(PyObject* pylist)
{
MT_Vector4 vec(0., 0., 0., 1.);
@@ -360,6 +405,12 @@ PyObject* PyObjectFromMT_Matrix3x3(const MT_Matrix3x3 &mat)
mat[2][0], mat[2][1], mat[2][2]);
}
+PyObject* PyObjectFromMT_Vector4(const MT_Vector4 &vec)
+{
+ return Py_BuildValue("[ffff]",
+ vec[0], vec[1], vec[2], vec[3]);
+}
+
PyObject* PyObjectFromMT_Vector3(const MT_Vector3 &vec)
{
return Py_BuildValue("[fff]",
@@ -371,3 +422,8 @@ PyObject* PyObjectFromMT_Point3(const MT_Point3 &pos)
return Py_BuildValue("[fff]",
pos[0], pos[1], pos[2]);
}
+
+PyObject* PyObjectFromMT_Point2(const MT_Point2 &pos)
+{
+ return Py_BuildValue("[ff]", pos[0], pos[1]);
+}