diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-10-27 18:47:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-10-27 18:47:58 +0300 |
commit | 2e96728843d01fa0e8c79133b0e7f943930405de (patch) | |
tree | 3694c8af2120e0206006901b21592b0c516e4106 /source/gameengine/Ketsji/KX_GameObject.cpp | |
parent | 71260b6603b1edfdbae57bfaa7d7388af366b17e (diff) |
face transp option CLIP wasnt added to the py api.
added gameObject.replaceMesh(meshname) - needed this for an automatically generated scene where 100's of objects would have needed logic bricks automatically added. Quicker to run replace mesh on all of them from 1 script.
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 8b2feca53a3..739c122a5ef 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -998,6 +998,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS}, {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_NOARGS}, {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_NOARGS}, + {"replaceMesh",(PyCFunction) KX_GameObject::sPyReplaceMesh, METH_O}, {"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_NOARGS}, KX_PYMETHODTABLE(KX_GameObject, rayCastTo), KX_PYMETHODTABLE(KX_GameObject, rayCast), @@ -1024,6 +1025,28 @@ bool KX_GameObject::ConvertPythonVectorArgs(PyObject* args, } */ +PyObject* KX_GameObject::PyReplaceMesh(PyObject* self, PyObject* value) +{ + KX_Scene *scene = PHY_GetActiveScene(); + char* meshname; + void* mesh_pt; + + meshname = PyString_AsString(value); + if (meshname==NULL) { + PyErr_SetString(PyExc_ValueError, "Expected a mesh name"); + return NULL; + } + mesh_pt = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname)); + + if (mesh_pt==NULL) { + PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist"); + return NULL; + } + scene->ReplaceMesh(this, (class RAS_MeshObject*)mesh_pt); + + Py_RETURN_NONE; +} + PyObject* KX_GameObject::PyEndObject(PyObject* self) { |