From 8b2811d9d5539dd880bc78f05e303781511d657b Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 7 Nov 2008 10:54:32 +0000 Subject: VideoTexture: VideoTexture.materialID() can now take texture image name. You can specify a image name (starting with 'IM') instead of a material name in VideoTexture.materialID() and return the material ID matching this texture. The advantage of this method is that is works with blender material and UV texture. In case of UV texture, it grabs the internal material corresponding to the faces that are assigned to this texture. In case of blender material, it grabs the material that has an image texture matching the name as first texture channel. In both cases, the texture id used in VideoTexture.Texture() should be 0. Ex: matID = VideoTexture.materialID(obj,'IMvideo.png') GameLogic.video = VideoTexture.Texture(obj, matID, 0) --- source/gameengine/VideoTexture/Texture.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'source/gameengine/VideoTexture/Texture.cpp') diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 88a26e3c088..66c67023e38 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -112,11 +112,20 @@ short getMaterialID (PyObject * obj, char * name) // get material RAS_IPolyMaterial * mat = getMaterial(obj, matID); // if material is not available, report that no material was found - if (mat == NULL) break; - // if material name matches - if (strcmp(mat->GetMaterialName().ReadPtr(), name) == 0) - // matID is found - return matID; + if (mat == NULL) + break; + // name is a material name if it starts with MA and a UV texture name if it starts with IM + if (name[0] == 'I' && name[1] == 'M') + { + // if texture name matches + if (strcmp(mat->GetTextureName().ReadPtr(), name) == 0) + return matID; + } else + { + // if material name matches + if (strcmp(mat->GetMaterialName().ReadPtr(), name) == 0) + return matID; + } } // material was not found return -1; -- cgit v1.2.3