| 
									
										
										
										
											2011-02-22 10:33:14 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2008-04-16 22:40:48 +00:00
										 |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2008-04-16 22:40:48 +00:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): none yet. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2008-04-16 22:40:48 +00:00
										 |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							| 
									
										
										
										
											2011-02-22 10:33:14 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \file KX_PyMath.h
 | 
					
						
							|  |  |  |  *  \ingroup ketsji | 
					
						
							|  |  |  |  *  \brief Initialize Python thingies. | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __KX_PYMATH_H__
 | 
					
						
							|  |  |  | #define __KX_PYMATH_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-30 11:09:46 +00:00
										 |  |  | #include "MT_Point2.h"
 | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  | #include "MT_Point3.h"
 | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | #include "MT_Vector2.h"
 | 
					
						
							| 
									
										
										
										
											2004-05-30 11:09:46 +00:00
										 |  |  | #include "MT_Vector3.h"
 | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  | #include "MT_Vector4.h"
 | 
					
						
							|  |  |  | #include "MT_Matrix3x3.h"
 | 
					
						
							| 
									
										
										
										
											2004-05-30 11:09:46 +00:00
										 |  |  | #include "MT_Matrix4x4.h"
 | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-12 16:55:33 +02:00
										 |  |  | #include "EXP_Python.h"
 | 
					
						
							|  |  |  | #include "EXP_PyObjectPlus.h"
 | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-31 04:11:39 +00:00
										 |  |  | #ifdef WITH_PYTHON
 | 
					
						
							| 
									
										
										
										
											2009-06-28 11:22:26 +00:00
										 |  |  | #ifdef USE_MATHUTILS
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							| 
									
										
										
										
											2011-07-15 04:01:47 +00:00
										 |  |  | #include "../../blender/python/mathutils/mathutils.h" /* so we can have mathutils callbacks */
 | 
					
						
							| 
									
										
										
										
											2009-06-28 11:22:26 +00:00
										 |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-09 19:45:59 +00:00
										 |  |  | inline unsigned int Size(const MT_Matrix4x4&)          { return 4; } | 
					
						
							|  |  |  | inline unsigned int Size(const MT_Matrix3x3&)          { return 3; } | 
					
						
							|  |  |  | inline unsigned int Size(const MT_Tuple2&)                { return 2; } | 
					
						
							|  |  |  | inline unsigned int Size(const MT_Tuple3&)                { return 3; } | 
					
						
							|  |  |  | inline unsigned int Size(const MT_Tuple4&)                { return 4; } | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-30 11:09:46 +00:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2009-12-22 23:38:09 +00:00
										 |  |  |  *  Converts the given python matrix (column-major) to an MT class (row-major). | 
					
						
							| 
									
										
										
										
											2004-05-30 11:09:46 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | template<class T> | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | bool PyMatTo(PyObject *pymat, T& mat) | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	bool noerror = true; | 
					
						
							|  |  |  | 	mat.setIdentity(); | 
					
						
							| 
									
										
										
										
											2011-12-23 00:51:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef USE_MATHUTILS
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (MatrixObject_Check(pymat)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		MatrixObject *pymatrix = (MatrixObject *)pymat; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (BaseMath_ReadCallback(pymatrix) == -1) | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (pymatrix->num_col != Size(mat) || pymatrix->num_row != Size(mat)) | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (unsigned int row = 0; row < Size(mat); row++) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			for (unsigned int col = 0; col < Size(mat); col++) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				mat[row][col] = *(pymatrix->matrix + col * pymatrix->num_row + row); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* USE_MATHUTILS */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 	if (PySequence_Check(pymat)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-12-23 00:51:54 +00:00
										 |  |  | 		unsigned int rows = PySequence_Size(pymat); | 
					
						
							|  |  |  | 		if (rows != Size(mat)) | 
					
						
							| 
									
										
										
										
											2004-12-29 01:34:07 +00:00
										 |  |  | 			return false; | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											2011-12-23 00:51:54 +00:00
										 |  |  | 		for (unsigned int row = 0; noerror && row < rows; row++) | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2011-12-23 00:51:54 +00:00
										 |  |  | 			PyObject *pyrow = PySequence_GetItem(pymat, row); /* new ref */ | 
					
						
							|  |  |  | 			if (!PyErr_Occurred() && PySequence_Check(pyrow)) | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2011-12-23 00:51:54 +00:00
										 |  |  | 				unsigned int cols = PySequence_Size(pyrow); | 
					
						
							| 
									
										
										
										
											2012-06-17 09:58:26 +00:00
										 |  |  | 				if (cols != Size(mat)) { | 
					
						
							| 
									
										
										
										
											2004-12-29 01:34:07 +00:00
										 |  |  | 					noerror = false; | 
					
						
							| 
									
										
										
										
											2012-06-17 09:58:26 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				else { | 
					
						
							|  |  |  | 					for (unsigned int col = 0; col < cols; col++) { | 
					
						
							| 
									
										
										
										
											2011-12-23 00:51:54 +00:00
										 |  |  | 						PyObject *item = PySequence_GetItem(pyrow, col); /* new ref */ | 
					
						
							|  |  |  | 						mat[row][col] = PyFloat_AsDouble(item); | 
					
						
							| 
									
										
										
										
											2004-12-29 01:34:07 +00:00
										 |  |  | 						Py_DECREF(item); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-06-17 09:58:26 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 				noerror = false; | 
					
						
							| 
									
										
										
										
											2012-06-17 09:58:26 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2011-12-23 00:51:54 +00:00
										 |  |  | 			Py_DECREF(pyrow); | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} else  | 
					
						
							|  |  |  | 		noerror = false; | 
					
						
							| 
									
										
										
										
											2008-07-25 21:14:23 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	if (noerror==false) | 
					
						
							|  |  |  | 		PyErr_SetString(PyExc_TypeError, "could not be converted to a matrix (sequence of sequences)"); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 	return noerror; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2004-05-30 11:09:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2009-04-20 15:06:46 +00:00
										 |  |  |  *  Converts a python sequence to a MT class. | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | template<class T> | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | bool PyVecTo(PyObject *pyval, T& vec) | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | #ifdef USE_MATHUTILS
 | 
					
						
							|  |  |  | 	/* no need for BaseMath_ReadCallback() here, reading the sequences will do this */ | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 	if (VectorObject_Check(pyval)) { | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | 		VectorObject *pyvec= (VectorObject *)pyval; | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 		if (BaseMath_ReadCallback(pyvec) == -1) { | 
					
						
							| 
									
										
										
										
											2010-12-06 08:29:41 +00:00
										 |  |  | 			return false; /* exception raised */ | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | 		if (pyvec->size != Size(vec)) { | 
					
						
							|  |  |  | 			PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", pyvec->size, Size(vec)); | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-08-26 06:15:43 +00:00
										 |  |  | 		vec.setValue((float *) pyvec->vec); | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 	else if (QuaternionObject_Check(pyval)) { | 
					
						
							| 
									
										
										
										
											2009-06-25 20:47:41 +00:00
										 |  |  | 		QuaternionObject *pyquat= (QuaternionObject *)pyval; | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 		if (BaseMath_ReadCallback(pyquat) == -1) { | 
					
						
							| 
									
										
										
										
											2010-12-06 08:29:41 +00:00
										 |  |  | 			return false; /* exception raised */ | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-06-25 20:47:41 +00:00
										 |  |  | 		if (4 != Size(vec)) { | 
					
						
							|  |  |  | 			PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 4, Size(vec)); | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		/* xyzw -> wxyz reordering is done by PyQuatTo */ | 
					
						
							| 
									
										
										
										
											2009-08-26 06:15:43 +00:00
										 |  |  | 		vec.setValue((float *) pyquat->quat); | 
					
						
							| 
									
										
										
										
											2009-06-25 20:47:41 +00:00
										 |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 	else if (EulerObject_Check(pyval)) { | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | 		EulerObject *pyeul= (EulerObject *)pyval; | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 		if (BaseMath_ReadCallback(pyeul) == -1) { | 
					
						
							| 
									
										
										
										
											2010-12-06 08:29:41 +00:00
										 |  |  | 			return false; /* exception raised */ | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | 		if (3 != Size(vec)) { | 
					
						
							|  |  |  | 			PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 3, Size(vec)); | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-08-26 06:15:43 +00:00
										 |  |  | 		vec.setValue((float *) pyeul->eul); | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 	if (PyTuple_Check(pyval)) { | 
					
						
							| 
									
										
										
										
											2009-04-20 15:06:46 +00:00
										 |  |  | 		unsigned int numitems = PyTuple_GET_SIZE(pyval); | 
					
						
							|  |  |  | 		if (numitems != Size(vec)) { | 
					
						
							|  |  |  | 			PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", numitems, Size(vec)); | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		for (unsigned int x = 0; x < numitems; x++) | 
					
						
							|  |  |  | 			vec[x] = PyFloat_AsDouble(PyTuple_GET_ITEM(pyval, x)); /* borrow ref */ | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		if (PyErr_Occurred()) { | 
					
						
							|  |  |  | 			PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float"); | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 	else if (PyObject_TypeCheck(pyval, (PyTypeObject *)&PyObjectPlus::Type)) { | 
					
						
							|  |  |  | 		/* note, include this check because PySequence_Check does too much introspection
 | 
					
						
							| 
									
										
										
										
											2009-06-08 20:08:19 +00:00
										 |  |  | 		 * on the PyObject (like getting its __class__, on a BGE type this means searching up | 
					
						
							|  |  |  | 		 * the parent list each time only to discover its not a sequence. | 
					
						
							|  |  |  | 		 * GameObjects are often used as an alternative to vectors so this is a common case | 
					
						
							|  |  |  | 		 * better to do a quick check for it, likely the error below will be ignored. | 
					
						
							|  |  |  | 		 *  | 
					
						
							|  |  |  | 		 * This is not 'correct' since we have proxy type CListValues's which could | 
					
						
							|  |  |  | 		 * contain floats/ints but there no cases of CValueLists being this way | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		PyErr_Format(PyExc_AttributeError, "expected a sequence type"); | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 	else if (PySequence_Check(pyval)) { | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 		unsigned int numitems = PySequence_Size(pyval); | 
					
						
							| 
									
										
										
										
											2008-07-25 21:14:23 +00:00
										 |  |  | 		if (numitems != Size(vec)) { | 
					
						
							| 
									
										
										
										
											2009-04-20 15:06:46 +00:00
										 |  |  | 			PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", numitems, Size(vec)); | 
					
						
							| 
									
										
										
										
											2004-12-29 01:34:07 +00:00
										 |  |  | 			return false; | 
					
						
							| 
									
										
										
										
											2008-07-25 21:14:23 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 		for (unsigned int x = 0; x < numitems; x++) { | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 			PyObject *item = PySequence_GetItem(pyval, x); /* new ref */ | 
					
						
							|  |  |  | 			vec[x] = PyFloat_AsDouble(item); | 
					
						
							|  |  |  | 			Py_DECREF(item); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2008-07-25 21:14:23 +00:00
										 |  |  | 		if (PyErr_Occurred()) { | 
					
						
							|  |  |  | 			PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float"); | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2012-07-21 22:58:08 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2009-04-20 15:06:46 +00:00
										 |  |  | 		PyErr_Format(PyExc_AttributeError, "not a sequence type, expected a sequence of numbers size %d", Size(vec)); | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-25 20:47:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | bool PyQuatTo(PyObject *pyval, MT_Quaternion &qrot); | 
					
						
							| 
									
										
										
										
											2009-06-25 20:47:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | bool PyOrientationTo(PyObject *pyval, MT_Matrix3x3 &mat, const char *error_prefix); | 
					
						
							| 
									
										
										
										
											2009-04-20 15:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Converts an MT_Matrix4x4 to a python object. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | PyObject *PyObjectFrom(const MT_Matrix4x4 &mat); | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Converts an MT_Matrix3x3 to a python object. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | PyObject *PyObjectFrom(const MT_Matrix3x3 &mat); | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  |  * Converts an MT_Tuple2 to a python object. | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | PyObject *PyObjectFrom(const MT_Tuple2 &vec); | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-30 11:09:46 +00:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  |  * Converts an MT_Tuple3 to a python object | 
					
						
							| 
									
										
										
										
											2004-05-30 11:09:46 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | PyObject *PyObjectFrom(const MT_Tuple3 &vec); | 
					
						
							| 
									
										
										
										
											2004-05-30 11:09:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-25 20:47:41 +00:00
										 |  |  | #ifdef USE_MATHUTILS
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Converts an MT_Quaternion to a python object. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | PyObject *PyObjectFrom(const MT_Quaternion &qrot); | 
					
						
							| 
									
										
										
										
											2009-06-25 20:47:41 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2004-07-17 05:28:23 +00:00
										 |  |  |  * Converts an MT_Tuple4 to a python object. | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-09-16 04:58:18 +00:00
										 |  |  | PyObject *PyObjectFrom(const MT_Tuple4 &pos); | 
					
						
							| 
									
										
										
										
											2004-05-26 12:09:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-16 12:53:54 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												BGE: Extend Python API for KX_BlenderMaterial (specular, diffuse…)
Add support for material diffuse, specular… in KX_BlenderMaterial python proxy. And use mathutils in KX_BlenderMaterial for the specular and diffuse color in KX_BlenderMaterial.
Reviewers: sybren, brita_, kupoman, agoose77, dfelinto, moguri, campbellbarton, hg1
Reviewed By: moguri, campbellbarton, hg1
Subscribers: dfelinto
Projects: #game_engine
Differential Revision: https://developer.blender.org/D1298
											
										 
											2015-07-03 11:47:48 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Converts an MT_Vector3 to a python color object. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | PyObject *PyColorFromVector(const MT_Vector3 &vec); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-09 13:36:42 +00:00
										 |  |  | #endif  /* WITH_PYTHON */
 |