Texture: Texture

Texture(obj, matID, texID, objTex)
  • Returns a texture object

obj:

  • game object
  • Type: KX_GameObject
matID:
  • index number of game object’s material.
  • Type:  integer
texID:
  • index number of object’s texture.
  • Type:  integer
objTex:
  • Use same VideoTexture Texture on a different game object.
  • Type: VideoTexture Texture
Texture(obj, matID, texID)
  • Returns a texture object

obj:

  • game object
  • Type: KX_GameObject
matID:
  • index number of game object’s material.
  • Type:  integer
texID:
  • index number of object’s texture.
  • Type:  integer

Note:

  • Uses the default value of 0 (zero) for objTex.
Texture(obj, matID)
  • Returns a texture object

obj:

  • game object
  • Type: KX_GameObject
matID:
  • index number of game object’s material.
  • Type:  integer

Note:

  • Uses the default values of 0 (zero) for texID and objTex.
Texture(obj)
  • Returns a texture object

obj:

  • game object
  • Type: KX_GameObject

Note:

  • Uses the default values of 0 (zero) for matID, texID and objTex.
Sample Code

###################### Video Texture Texture

# import bge module
import bge

# get current scene
scene = bge.logic.getCurrentScene()

# get list of objects in scene
objList = scene.objects

# get object to render to
# my object is named Security_Monitor
obj = objList["Security_Monitor"]

# get the Security_Monitor material ID
# Name of my render material is Screen
matID = bge.texture.materialID(obj, "MAScreen")

# use the first texture slot
texID = 0

# use the default objTex value

# set the texture
viewport_texture = bge.texture.Texture(obj, matID, texID)

# get the texture image
viewport_texture.source = bge.texture.ImageViewport()

# save as an object property
obj["image_viewport"] = viewport_texture

# update texture
viewport_texture.refresh(True)