diff --git a/contrib/blender/odm_photo.py b/contrib/blender/odm_photo.py index 9eef207f..6f9bb858 100644 --- a/contrib/blender/odm_photo.py +++ b/contrib/blender/odm_photo.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # Renders a photo. +# ExifTool must be on your PATH. # To generate a 360 panoramic photo: # blender -b photo_360.blend --python odm_photo.py -- # To generate a 360 3D panoramic photo: @@ -10,6 +11,7 @@ import sys import bpy import materials_utils +import subprocess surfaceShaderType = 'ShaderNodeEmission' surfaceShaderName = 'Emission' @@ -26,7 +28,7 @@ def main(): bpy.ops.import_scene.obj(filepath=projectHome + '/odm_texturing/odm_textured_model_geo.obj', - axis_forward='Y', axis_up='-Z') + axis_forward='Y', axis_up='Z') bpy.ops.xps_tools.convert_to_cycles_all() @@ -48,7 +50,7 @@ def main(): minZ = min(z, minZ) maxZ = max(z, maxZ) - model.location[2] += minZ + model.location[2] += (maxZ - minZ)/2 for m in bpy.data.materials: nt = m.node_tree @@ -61,10 +63,41 @@ def main(): nt.nodes['Diffuse Texture'].outputs[0]) blendName = bpy.path.display_name_from_filepath(bpy.data.filepath) - bpy.data.scenes['Scene'].render.filepath = projectHome + - '/odm_photo/odm_' + blendName + '.jpg' + fileName = projectHome + '/odm_photo/odm_' + blendName + render = bpy.data.scenes[0].render + render.filepath = fileName bpy.ops.render.render(write_still=True) + width = render.resolution_x + height = render.resolution_y + if(render.use_multiview): + writeExif(fileName+render.views[0].file_suffix+'.jpg', width, height) + writeExif(fileName+render.views[1].file_suffix+'.jpg', width, height) + else: + writeExif(fileName+'.jpg', width, height) + + +def writeExif(fileName, width, height): + w = str(width) + h = str(height) + + subprocess.run(['exiftool', + '-overwrite_original', + '-CroppedAreaImageWidthPixels=' + w, + '-CroppedAreaImageHeightPixels=' + h, + '-FullPanoWidthPixels=' + w, + '-FullPanoHeightPixels=' + h, + '-CroppedAreaLeftPixels=0', + '-CroppedAreaTopPixels=0', + '-ProjectionType=equirectangular', + '-UsePanoramaViewer=True', + '-PoseHeadingDegrees=0', + '-LargestValidInteriorRectLeft=0', + '-LargestValidInteriorRectTop=0', + '-LargestValidInteriorRectWidth=' + w, + '-LargestValidInteriorRectHeight=' + h, + fileName]) + if __name__ == '__main__': main() diff --git a/contrib/blender/photo_360.blend b/contrib/blender/photo_360.blend index 9e450b6c..a55e75e1 100644 Binary files a/contrib/blender/photo_360.blend and b/contrib/blender/photo_360.blend differ diff --git a/contrib/blender/photo_vr.blend b/contrib/blender/photo_vr.blend index e997ad75..00f8e7ff 100644 Binary files a/contrib/blender/photo_vr.blend and b/contrib/blender/photo_vr.blend differ