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:
authorErwin Coumans <blender@erwincoumans.com>2006-01-30 23:33:59 +0300
committerErwin Coumans <blender@erwincoumans.com>2006-01-30 23:33:59 +0300
commit18857a6225fba4b2b0d662b904cf04625a56e088 (patch)
tree2b6efca751351db9d2c32847395d3dbba3db56cc /source/gameengine/Ketsji/KX_VehicleWrapper.cpp
parent8e9222ec217ab98980ffd75cd14387a062b46c9a (diff)
prepared physics/game engine infrastructure for vehicle support.
fixed a python related bug with physics contraints fixed some line-ending problem with blenderbuttons.c makefile/scons/projectfiles need to add source/gameengine/Ketsji/KX_VehicleWrapper.cpp
Diffstat (limited to 'source/gameengine/Ketsji/KX_VehicleWrapper.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_VehicleWrapper.cpp140
1 files changed, 140 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
new file mode 100644
index 00000000000..299a2d1f180
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
@@ -0,0 +1,140 @@
+
+
+#include <Python.h>
+#include "KX_VehicleWrapper.h"
+#include "PHY_IPhysicsEnvironment.h"
+#include "PHY_IVehicle.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+KX_VehicleWrapper::KX_VehicleWrapper(
+ PHY_IVehicle* vehicle,
+ PHY_IPhysicsEnvironment* physenv,PyTypeObject *T) :
+ PyObjectPlus(T),
+ m_vehicle(vehicle),
+ m_physenv(physenv)
+{
+}
+
+KX_VehicleWrapper::~KX_VehicleWrapper()
+{
+}
+
+
+PyObject* KX_VehicleWrapper::PyAddWheel(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+
+PyObject* KX_VehicleWrapper::PyGetWheelsTransform(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ assert(0);
+ return PyInt_FromLong(m_vehicle->GetNumWheels());
+}
+
+
+PyObject* KX_VehicleWrapper::PyGetNumWheels(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ return PyInt_FromLong(m_vehicle->GetNumWheels());
+}
+
+
+PyObject* KX_VehicleWrapper::PyGetConstraintId(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ return PyInt_FromLong(m_vehicle->GetUserConstraintId());
+}
+
+PyObject* KX_VehicleWrapper::PyGetConstraintType(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ return PyInt_FromLong(m_vehicle->GetUserConstraintType());
+}
+
+
+
+
+//python specific stuff
+PyTypeObject KX_VehicleWrapper::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "KX_VehicleWrapper",
+ sizeof(KX_VehicleWrapper),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject KX_VehicleWrapper::Parents[] = {
+ &KX_VehicleWrapper::Type,
+ NULL
+};
+
+PyObject* KX_VehicleWrapper::_getattr(const STR_String& attr)
+{
+ //here you can search for existing data members (like mass,friction etc.)
+ _getattr_up(PyObjectPlus);
+}
+
+int KX_VehicleWrapper::_setattr(const STR_String& attr,PyObject* pyobj)
+{
+
+ PyTypeObject* type = pyobj->ob_type;
+ int result = 1;
+
+ if (type == &PyList_Type)
+ {
+ result = 0;
+ }
+ if (type == &PyFloat_Type)
+ {
+ result = 0;
+
+ }
+ if (type == &PyInt_Type)
+ {
+ result = 0;
+ }
+ if (type == &PyString_Type)
+ {
+ result = 0;
+ }
+ if (result)
+ result = PyObjectPlus::_setattr(attr,pyobj);
+ return result;
+};
+
+
+PyMethodDef KX_VehicleWrapper::Methods[] = {
+ {"addWheel",(PyCFunction) KX_VehicleWrapper::sPyAddWheel, METH_VARARGS},
+ {"getNumWheels",(PyCFunction) KX_VehicleWrapper::sPyGetNumWheels, METH_VARARGS},
+ {"getWheelsTransform",(PyCFunction) KX_VehicleWrapper::sPyGetWheelsTransform, METH_VARARGS},
+ {"getConstraintId",(PyCFunction) KX_VehicleWrapper::sPyGetConstraintId, METH_VARARGS},
+ {"getConstraintType",(PyCFunction) KX_VehicleWrapper::sPyGetConstraintType, METH_VARARGS},
+ {NULL,NULL} //Sentinel
+};
+
+
+