[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38137] trunk/blender/doc/python_api/ examples/bge.texture.1.py: new example for bge.texture, a basic texture replacement

Dalai Felinto dfelinto at gmail.com
Wed Jul 6 09:26:04 CEST 2011


Revision: 38137
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38137
Author:   dfelinto
Date:     2011-07-06 07:26:04 +0000 (Wed, 06 Jul 2011)
Log Message:
-----------
new example for bge.texture, a basic texture replacement
fresh simple and didactic example straight from my bge book, enjoy it ;)
video texture documentation online ... tears dropping.

Added Paths:
-----------
    trunk/blender/doc/python_api/examples/bge.texture.1.py

Added: trunk/blender/doc/python_api/examples/bge.texture.1.py
===================================================================
--- trunk/blender/doc/python_api/examples/bge.texture.1.py	                        (rev 0)
+++ trunk/blender/doc/python_api/examples/bge.texture.1.py	2011-07-06 07:26:04 UTC (rev 38137)
@@ -0,0 +1,38 @@
+"""
+Texture replacement
+++++++++++++++++++++++
+Example of how to replace a texture in game with an external image.
+createTexture() and removeTexture() are to be called from a module Python
+Controller.
+"""
+import bge
+from bge import logic
+from bge import texture	
+
+def createTexture(cont):
+    """Create a new Dynamic Texture"""
+    object = cont.owner
+	
+    # get the reference pointer (ID) of the internal texture
+    ID = VT.materialID(obj, 'IMoriginal.png')
+	
+    # create a texture object 
+    object_texture = texture.Texture(object, ID)
+	
+    # create a new source with an external image
+    url = logic.expandPath("//newtexture.jpg")
+    new_source = texture.ImageFFmpeg(url)
+	
+    # the texture has to be stored in a permanent Python object
+    logic.texture = object_texture
+	
+    # update/replace the texture
+    logic.texture.source = new_source
+    logic.texture.refresh(False)
+
+def removeTexture(cont):
+    """Delete the Dynamic Texture, reversing back the final to its original state."""
+    try:
+        del logic.texture
+    except:
+        pass


Property changes on: trunk/blender/doc/python_api/examples/bge.texture.1.py
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native




More information about the Bf-blender-cvs mailing list