face transp option CLIP wasnt added to the py api.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 27 Oct 2008 15:47:58 +0000 (15:47 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 27 Oct 2008 15:47:58 +0000 (15:47 +0000)
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.

source/blender/python/api2_2x/Material.c
source/blender/python/api2_2x/Mesh.c
source/blender/python/api2_2x/doc/Mesh.py
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_GameObject.h
source/gameengine/PyDoc/KX_GameObject.py

index 2e6bd326fb6c9c9d7a363e3f482d7276ba2060e5..cb2c81aba6ef0fea8239c36bdaca0ae08f50cda1 100644 (file)
@@ -2506,10 +2506,10 @@ static PyObject *Material_setTexture( BPy_Material * self, PyObject * args )
        if( !PyArg_ParseTuple( args, "iO!|ii", &texnum, &Texture_Type, &pytex,
                               &texco, &mapto ) )
                return EXPP_ReturnPyObjError( PyExc_TypeError,
-                                             "expected int in [0,9] and Texture" );
+                                             "expected int in [0,17] and Texture" );
        if( ( texnum < 0 ) || ( texnum >= MAX_MTEX ) )
                return EXPP_ReturnPyObjError( PyExc_TypeError,
-                                             "expected int in [0,9] and Texture" );
+                                             "expected int in [0,17] and Texture" );
 
        bltex = Texture_FromPyObject( pytex );
 
index d513a8be4db8ea6e979cba0c4bf76daf1d8299e8..a97a55244ad4d54dc2d7945787c1144cf3913033 100644 (file)
@@ -4239,7 +4239,7 @@ static int MFace_setTransp( BPy_MFace *self, PyObject *value )
                return -1;
 
        return EXPP_setIValueRange( value,
-                       &self->mesh->mtface[self->index].transp, TF_SOLID, TF_SUB, 'b' );
+                       &self->mesh->mtface[self->index].transp, TF_SOLID, TF_CLIP, 'b' );
 }
 
 /*
@@ -8743,6 +8743,7 @@ static PyObject *M_Mesh_FaceTranspModesDict( void )
                PyConstant_Insert( d, "ADD", PyInt_FromLong( TF_ADD ) );
                PyConstant_Insert( d, "ALPHA", PyInt_FromLong( TF_ALPHA ) );
                PyConstant_Insert( d, "SUB", PyInt_FromLong( TF_SUB ) );
+               PyConstant_Insert( d, "CLIP", PyInt_FromLong( TF_CLIP ) );
        }
 
        return FTM;
index e48f41e8f9c0ca23816df7e878f2832c0eada7d1..9b6dcae8bb6b3b1ebccf7346ee65a72784a0c1d2 100644 (file)
@@ -85,6 +85,7 @@ done once.
                - ADD - add to background (halo).
                - ALPHA - draw with transparency.
                - SUB - subtract from background.
+               - CLIP - Clipped alpha.
 @var EdgeFlags: The available edge flags.
                - SELECT - selected (B{deprecated}).  Use edge.sel attribute instead.
                - EDGEDRAW - edge is drawn out of edition mode.
index 8b2feca53a3471be422371efac70dc3239f7800b..739c122a5ef52c1f8f1cc2cb553a5168d4c807eb 100644 (file)
@@ -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)
 {
 
index 472d31362dd6409dff0528c947ab9f27cc2a9251..20b15787d27732da0332221c3b53c7f87127d749 100644 (file)
@@ -801,6 +801,7 @@ public:
        KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh);
        KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId);
        KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames);
+       KX_PYMETHOD_O(KX_GameObject,ReplaceMesh);
        KX_PYMETHOD_NOARGS(KX_GameObject,EndObject);
        KX_PYMETHOD_DOC(KX_GameObject,rayCastTo);
        KX_PYMETHOD_DOC(KX_GameObject,rayCast);
index ff9b4ffc95bed19dfe1d90d4bd5363cfad838533..505ce253dd1ee2b36f14f58b4680557c6893afa4 100644 (file)
@@ -30,6 +30,11 @@ class KX_GameObject:
                Delete this object, can be used inpace of the EndObject Actuator.
                The actual removal of the object from the scene is delayed.
                """     
+       def replaceMesh(mesh_name):
+               """
+               Replace the mesh of this object with a new mesh. This works the same was as the actuator.
+               @type mesh_name: string
+               """     
        def getVisible():
                """
                Gets the game object's visible flag.