I've seen similar questions on how to take pictures, but those questions are for the render engine, cycles, and others. I have a set of weapons, and want to take a picture from the side view. When you swap to your weapon, your newly selected weapon will show its picture on the right side of your screen, like other FPS games. In other words, I am looking for a way to take a screenshot in the GE; if you can, then can I also change the resolution? Any help is appreciated, thanks!
Pose your weapon according to the view , than run the script to take a picture using openGl render , got o the UV editor and the image will have the name of the active object :
import bpy # path to the folder file_path = bpy.data.filepath file_name = bpy.path.display_name_from_filepath(file_path) file_ext = '.blend' file_dir = file_path.replace(file_name+file_ext, '') mainScreen = bpy.context.screen #current scene scene = mainScreen.scene #set render settings scene.render.resolution_x = 128 scene.render.resolution_y = 128 scene.render.resolution_percentage = 100 #render from view (set view_context = False for the camera render) bpy.ops.render.opengl(view_context = True) #save and load the render (you can't keep the render result) img_name = bpy.context.object.name+".png" bpy.data.images['Render Result'].save_render(file_dir+img_name) bpy.ops.image.open(filepath = file_dir+img_name) bpy.data.images[img_name].pack()
- you can change the render size in the script
For screenshots while playing the BGE has a function for that :
bge.render.makeScreenshot(filename) see the DOC
bge offers methods to render to texture, in the renderTexture part of bge, that can export a png, or you can snapshot a view of a item on frame 0, the advantage here, is you can load from external blends, and then snap the image, so if you change anything, you just save the external file and the main file updates automagically.
there is also ctrl+print screen to copy a image to paste that is a screenshot.