Okay so I got a working script, and this script projects a texture on a plane from a camera that takes it’s view from the scene. It’s called render to texture, this works fine. Problem is I don’t know how to convert the projected texture on the plane to an image and save it, I would be happy to save it as numpy as well directly without saving image to file first.
My problem is I’m new to this, I don’t understand arrays and pixel manipulation.
I do understand tho the Bge texture class, how to render and what everything there does, I put effort into understanding it. Also I do not want to use BPY, I know how to save images with bpy but BPY is useless once you start the BGE game engine on stand alone mode, it’s functions no longer work ? even more if you want to patch BGE blender to a stand alone game console…
I am using UPBGE alpha 3.
import bge controller = bge.logic.getCurrentController() own = controller.owner ## get current scene scene = bge.logic.getCurrentScene() # check to see variable RenderToTexture has been created if "RenderToTexture" in own: # update the texture own["RenderToTexture"].refresh(True) # if variable RenderToTexture hasn't been created else: # import VideoTexture module import VideoTexture # get a list of objects in the scene ownList = scene.objects cameraName = own['cam'] cam = scene.cameras[cameraName] print(cameraName) # get the texture material ID, identify the object by logic editor object name and it's material. matID = bge.texture.materialID(own, "MA" + own['material']) # set the texture , to my understanding this will set a blank texture on specified object and it's material # name specified in the logic editor game properties, so source can write over it, write the data it # captured from camera view over the set texture. So this tells where to place texture for source to print on. renderToTexture = VideoTexture.Texture(own, matID) # This is the source, it will grab the camera and "Image Render it" with the # settings made by the above line code . So this is the settings for the render mechanism where it #imprints the camera image onto the texture of the object that was set. renderToTexture.source = VideoTexture.ImageRender(scene,cam) # save RenderToTexture as an object variable, so when refreshed it loops the render inside the BGE. own["RenderToTexture"] = renderToTexture #==== my whole code import bge controller = bge.logic.getCurrentController() own = controller.owner scene = bge.logic.getCurrentScene() if "RenderToTexture" in own: own["RenderToTexture"].refresh(True) else: import VideoTexture ownList = scene.objects cameraName = own['cam'] cam = scene.cameras[cameraName] print(cameraName) get the texture material ID matID = bge.texture.materialID(own, "MA" + own['material']) renderToTexture = VideoTexture.Texture(own, matID) renderToTexture.source = VideoTexture.ImageRender(scene,cam) own["RenderToTexture"] = renderToTexture
The rest with arrays and grabing pixels I do not understand.
I do not understand them because there is limited information about them regarding their use with blender like for example ImageToArray that is an array specified in blender docs that you can use to grab the source render and convert to array, but I could not find how to use it because blender documentation is so poor on their site and google does not provide anything in detail, few results.
So my overall question is - How do I convert render results of ImageRender source or from the plane that has the image projected on to it and save it as an image or a numpy array then save to file without the use of BPY.
Can I grab it from the :
renderToTexture.source = VideoTexture.ImageRender(scene,cam)
or can I grab the image from the plane, where the texture has projected on.
Overall in the scene I have:
One plane that the texture image projects on to as a image I can view with a camera on a wall, the plane is the wall.
One Character that poses for the camera
I have two cameras, one that takes image of the character, the other camera looks at the wall to see the image projected.
The image of the character posing gets projected on the wall.
How do I grab the image on the wall and save to file or how do I grab the image from the source and save to file.
Save either as numpy or image file.