def main(): imgDetectorX = 64 * 5 imgDetectorY = 36 * 5 imgPickupX = 256 imgPickupY = 144 if hasattr(GameLogic, 'detector') and hasattr(GameLogic, 'pickup'): GameLogic.detector.refresh(True) GameLogic.pickup.refresh(True) GameLogic.detector_png = list(GameLogic.detector.source.image) GameLogic.pickup_png = list(GameLogic.pickup.source.image) thread = Worker(None) thread.run(imgDetectorX, imgDetectorY, imgPickupX, imgPickupY) else: scene = GameLogic.getCurrentScene() screen1 = scene.objects['Screen1'] screen2 = scene.objects['Screen2'] detectorcamera = scene.objects['DetectionCamera'] pickupcamera = scene.objects['PickupCamera'] GameLogic.detector = bge.texture.Texture(screen1, 0, 0) GameLogic.pickup = bge.texture.Texture(screen2, 0, 0) GameLogic.detector.source = VideoTexture.ImageRender( scene, detectorcamera) GameLogic.detector.source.capsize = (imgDetectorX, imgDetectorY) GameLogic.detector_png = GameLogic.detector.source.image[:] GameLogic.pickup.source = VideoTexture.ImageRender(scene, pickupcamera) GameLogic.pickup.source.capsize = (imgPickupX, imgPickupY) GameLogic.pickup_png = GameLogic.pickup.source.image[:]
# update the texture obj["RenderToTexture"].refresh(True) # if RenderToTexture hasn't been added else: # import VideoTexture module import VideoTexture # get a list of objects in the scene objList = scene.objects # get camera name being used for render to texture camName = obj['cam'] # get camera object cam = objList[camName] # get the texture material ID matID = VideoTexture.materialID(obj, "MA" + obj['material']) # set the texture renderToTexture = VideoTexture.Texture(obj, matID) # get the texture image renderToTexture.source = VideoTexture.ImageRender(scene, cam) # save RenderToTexture as an object variable obj["RenderToTexture"] = renderToTexture