Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00033 #include "PyObjectPlus.h" 00034 00035 #include "KX_PhysicsObjectWrapper.h" 00036 #include "PHY_IPhysicsEnvironment.h" 00037 #include "PHY_IPhysicsController.h" 00038 00039 KX_PhysicsObjectWrapper::KX_PhysicsObjectWrapper( 00040 PHY_IPhysicsController* ctrl, 00041 PHY_IPhysicsEnvironment* physenv) : 00042 PyObjectPlus(), 00043 m_ctrl(ctrl), 00044 m_physenv(physenv) 00045 { 00046 } 00047 00048 KX_PhysicsObjectWrapper::~KX_PhysicsObjectWrapper() 00049 { 00050 } 00051 00052 #ifdef WITH_PYTHON 00053 00054 PyObject* KX_PhysicsObjectWrapper::PySetPosition(PyObject* args) 00055 { 00056 float x,y,z; 00057 if (PyArg_ParseTuple(args,"fff:setPosition",&x,&y,&z)) 00058 { 00059 m_ctrl->setPosition(x,y,z); 00060 } 00061 else { 00062 return NULL; 00063 } 00064 Py_RETURN_NONE; 00065 } 00066 00067 00068 PyObject* KX_PhysicsObjectWrapper::PySetLinearVelocity(PyObject* args) 00069 { 00070 float x,y,z; 00071 int local; 00072 if (PyArg_ParseTuple(args,"fffi:setLinearVelocity",&x,&y,&z,&local)) 00073 { 00074 m_ctrl->SetLinearVelocity(x,y,z,local != 0); 00075 } 00076 else { 00077 return NULL; 00078 } 00079 Py_RETURN_NONE; 00080 } 00081 00082 PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* args) 00083 { 00084 float x,y,z; 00085 int local; 00086 if (PyArg_ParseTuple(args,"fffi:setAngularVelocity",&x,&y,&z,&local)) 00087 { 00088 m_ctrl->SetAngularVelocity(x,y,z,local != 0); 00089 } 00090 else { 00091 return NULL; 00092 } 00093 Py_RETURN_NONE; 00094 } 00095 00096 PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* args) 00097 { 00098 int active; 00099 if (PyArg_ParseTuple(args,"i:setActive",&active)) 00100 { 00101 m_ctrl->SetActive(active!=0); 00102 } 00103 else { 00104 return NULL; 00105 } 00106 Py_RETURN_NONE; 00107 } 00108 00109 00110 PyAttributeDef KX_PhysicsObjectWrapper::Attributes[] = { 00111 { NULL } //Sentinel 00112 }; 00113 00114 //python specific stuff 00115 PyTypeObject KX_PhysicsObjectWrapper::Type = { 00116 PyVarObject_HEAD_INIT(NULL, 0) 00117 "KX_PhysicsObjectWrapper", 00118 sizeof(PyObjectPlus_Proxy), 00119 0, 00120 py_base_dealloc, 00121 0, 00122 0, 00123 0, 00124 0, 00125 py_base_repr, 00126 0,0,0,0,0,0,0,0,0, 00127 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, 00128 0,0,0,0,0,0,0, 00129 Methods, 00130 0, 00131 0, 00132 &PyObjectPlus::Type, 00133 0,0,0,0,0,0, 00134 py_base_new 00135 }; 00136 00137 PyMethodDef KX_PhysicsObjectWrapper::Methods[] = { 00138 {"setPosition",(PyCFunction) KX_PhysicsObjectWrapper::sPySetPosition, METH_VARARGS}, 00139 {"setLinearVelocity",(PyCFunction) KX_PhysicsObjectWrapper::sPySetLinearVelocity, METH_VARARGS}, 00140 {"setAngularVelocity",(PyCFunction) KX_PhysicsObjectWrapper::sPySetAngularVelocity, METH_VARARGS}, 00141 {"setActive",(PyCFunction) KX_PhysicsObjectWrapper::sPySetActive, METH_VARARGS}, 00142 {NULL,NULL} //Sentinel 00143 }; 00144 00145 #endif