2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +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.
|
2002-10-12 11:37:38 +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,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* 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 *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
#include <Python.h>
|
2008-09-06 14:13:31 +00:00
|
|
|
#include "PyObjectPlus.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "KX_ConstraintWrapper.h"
|
|
|
|
#include "PHY_IPhysicsEnvironment.h"
|
|
|
|
|
2002-11-25 15:29:57 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
KX_ConstraintWrapper::KX_ConstraintWrapper(
|
|
|
|
PHY_ConstraintType ctype,
|
|
|
|
int constraintId,
|
2004-03-22 22:02:18 +00:00
|
|
|
PHY_IPhysicsEnvironment* physenv,PyTypeObject *T) :
|
|
|
|
PyObjectPlus(T),
|
|
|
|
m_constraintId(constraintId),
|
|
|
|
m_constraintType(ctype),
|
|
|
|
m_physenv(physenv)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
KX_ConstraintWrapper::~KX_ConstraintWrapper()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-19 17:29:07 +00:00
|
|
|
PyObject* KX_ConstraintWrapper::PyGetConstraintId(PyObject* args, PyObject* kwds)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
return PyInt_FromLong(m_constraintId);
|
|
|
|
}
|
|
|
|
|
2009-05-24 00:42:40 +00:00
|
|
|
PyObject* KX_ConstraintWrapper::PySetLimit(PyObject* args, PyObject* kwds)
|
|
|
|
{
|
|
|
|
int len = PyTuple_Size(args);
|
|
|
|
int success = 1;
|
|
|
|
|
|
|
|
if (len == 3)
|
|
|
|
{
|
|
|
|
int dof;
|
|
|
|
float minLimit,maxLimit;
|
|
|
|
success = PyArg_ParseTuple(args,"iff",&dof,&minLimit,&maxLimit);
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
m_physenv->setConstraintParam(m_constraintId,dof,minLimit,maxLimit);
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject* KX_ConstraintWrapper::PyEnableMotor(PyObject* args, PyObject* kwds)
|
|
|
|
{
|
|
|
|
///will add it soon
|
|
|
|
return PyInt_FromLong(0);
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
//python specific stuff
|
|
|
|
PyTypeObject KX_ConstraintWrapper::Type = {
|
2009-04-29 16:54:45 +00:00
|
|
|
#if (PY_VERSION_HEX >= 0x02060000)
|
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
|
|
|
#else
|
|
|
|
/* python 2.5 and below */
|
|
|
|
PyObject_HEAD_INIT( NULL ) /* required py macro */
|
|
|
|
0, /* ob_size */
|
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
"KX_ConstraintWrapper",
|
2009-04-19 14:57:52 +00:00
|
|
|
sizeof(PyObjectPlus_Proxy),
|
2002-10-12 11:37:38 +00:00
|
|
|
0,
|
2009-04-19 14:57:52 +00:00
|
|
|
py_base_dealloc,
|
2002-10-12 11:37:38 +00:00
|
|
|
0,
|
|
|
|
0,
|
2009-04-03 14:51:06 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
py_base_repr,
|
|
|
|
0,0,0,0,0,0,
|
|
|
|
py_base_getattro,
|
|
|
|
py_base_setattro,
|
|
|
|
0,0,0,0,0,0,0,0,0,
|
2009-04-03 04:12:20 +00:00
|
|
|
Methods
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PyParentObject KX_ConstraintWrapper::Parents[] = {
|
|
|
|
&KX_ConstraintWrapper::Type,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2009-04-20 23:17:52 +00:00
|
|
|
//here you can search for existing data members (like mass,friction etc.)
|
|
|
|
PyObject* KX_ConstraintWrapper::py_getattro(PyObject *attr)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-04-03 14:51:06 +00:00
|
|
|
py_getattro_up(PyObjectPlus);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 23:17:52 +00:00
|
|
|
PyObject* KX_ConstraintWrapper::py_getattro_dict() {
|
|
|
|
py_getattro_dict_up(PyObjectPlus);
|
|
|
|
}
|
|
|
|
|
2009-04-29 10:24:12 +00:00
|
|
|
int KX_ConstraintWrapper::py_setattro(PyObject *attr,PyObject* value)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-04-29 10:24:12 +00:00
|
|
|
py_setattro_up(PyObjectPlus);
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-24 00:42:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
PyMethodDef KX_ConstraintWrapper::Methods[] = {
|
|
|
|
{"getConstraintId",(PyCFunction) KX_ConstraintWrapper::sPyGetConstraintId, METH_VARARGS},
|
2009-05-24 00:42:40 +00:00
|
|
|
{"setLimit",(PyCFunction) KX_ConstraintWrapper::sPySetLimit, METH_VARARGS},
|
|
|
|
{"enableMotor",(PyCFunction) KX_ConstraintWrapper::sPyEnableMotor, METH_VARARGS},
|
2002-10-12 11:37:38 +00:00
|
|
|
{NULL,NULL} //Sentinel
|
|
|
|
};
|
2009-02-26 09:04:06 +00:00
|
|
|
|
|
|
|
PyAttributeDef KX_ConstraintWrapper::Attributes[] = {
|
2009-04-23 00:47:45 +00:00
|
|
|
//KX_PYATTRIBUTE_TODO("constraintId"),
|
2009-02-26 09:04:06 +00:00
|
|
|
{ NULL } //Sentinel
|
|
|
|
};
|