###################################################### # # Mirror.py Blender 2.49 # # Tutorial for using Mirror.py can be found at # # www.tutorialsforblender3d.com # # Released under the Creative Commons Attribution 3.0 Unported License. # # If you use this code, please include this information header. # ###################################################### # get current scene scene = GameLogic.getCurrentScene() # get the current controller controller = GameLogic.getCurrentController() # get object script is attached to obj = controller.owner # check to see mirror has been added if obj.has_key("Mirror") == True: # update the mirror obj["Mirror"].refresh(True) # if mirror hasn't been added else: # import VideoTexture module import VideoTexture # Check for optional Property named cam if obj.has_key("cam") == True: # get object list objList = scene.objects # get camera name camName = obj["cam"] # get camera object cam = objList["OB" + camName] else: # default is the active camera # get active camera cam = scene.active_camera # get the mirror material ID matID = VideoTexture.materialID(obj, "MA" + obj['material']) #texture channel if obj.has_key('channel') == True: texChannel = obj['channel'] else: texChannel = 0 # get the mirrortexture mirror = VideoTexture.Texture(obj, matID, texChannel) # get the mirror source mirror.source = VideoTexture.ImageMirror(scene,cam,obj,matID) # save mirror as an object variable obj["Mirror"] = mirror