Texture: mipmap

mipmap
  • gets/sets whether or not texture can have mipmaps.

Type: 

  • boolean
     
  • True = mipmaps allowed
     
  • False = mipmaps not allowed
Note:
  • Mip Maps are multiple resolution images of a single texture.
  • Close objects use the largest resolution textures. 
  • As distance increases, smaller resolution textures are used.
Sample Code

###################### get if mipmaps are allowed

# 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 SecurityMonitor

obj = objList["SecurityMonitor"]

# check to see if render to texture variable saved
if "Render" in obj:

# get saved variable
renderToTexture = obj["Render"]

# update texture
renderToTexture.refresh(True)

else:
# get a list of the cameras
camList = scene.cameras

# get camera being used for render to texture
# my camera is named Security_Cam
cam = camList["Security_Cam"]

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

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

# get the texture image
renderToTexture.source = bge.texture.ImageRender(scene,cam)

# get if mip maps are allowed
status = renderToTexture.mipmap

# save RenderToTexture as an object variable
obj["Render"] = renderToTexture
 
Sample Code

###################### set if mip maps are allowed

# 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 SecurityMonitor

obj = objList["SecurityMonitor"]

# check to see if render to texture variable saved
if "Render" in obj:

# get saved variable
renderToTexture = obj["Render"]

# update texture
renderToTexture.refresh(True)

else:
# get a list of the cameras
camList = scene.cameras

# get camera being used for render to texture
# my camera is named Security_Cam
cam = camList["Security_Cam"]

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

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

# get the texture image
renderToTexture.source = bge.texture.ImageRender(scene,cam)

# set if mip maps are allowed
renderToTexture.mipmap = True

# save RenderToTexture as an object variable
obj["Render"] = renderToTexture