[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17356] trunk/blender/source/gameengine/ VideoTexture/Texture.cpp: VideoTexture: VideoTexture.materialID() can now take texture image name.

Benoit Bolsee benoit.bolsee at online.be
Fri Nov 7 11:54:32 CET 2008


Revision: 17356
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17356
Author:   ben2610
Date:     2008-11-07 11:54:32 +0100 (Fri, 07 Nov 2008)

Log Message:
-----------
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)

Modified Paths:
--------------
    trunk/blender/source/gameengine/VideoTexture/Texture.cpp

Modified: trunk/blender/source/gameengine/VideoTexture/Texture.cpp
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/Texture.cpp	2008-11-07 09:47:25 UTC (rev 17355)
+++ trunk/blender/source/gameengine/VideoTexture/Texture.cpp	2008-11-07 10:54:32 UTC (rev 17356)
@@ -112,11 +112,20 @@
 		// 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;





More information about the Bf-blender-cvs mailing list