From 9b3f7fa1273c145d67357ada01dc249fba8ee2f2 Mon Sep 17 00:00:00 2001 From: Solal Depardieu Date: Fri, 7 May 2021 13:24:11 +0200 Subject: [PATCH] [node] Adding a density factor to the render node Added a numeral scale to the node to make the density rendering of the cloud of point more customisable... --- meshroom/nodes/blender/RenderAnimatedCamera.py | 8 ++++++++ meshroom/nodes/blender/scripts/camera_support.py | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/meshroom/nodes/blender/RenderAnimatedCamera.py b/meshroom/nodes/blender/RenderAnimatedCamera.py index 5f85aa84..b14dd4bb 100644 --- a/meshroom/nodes/blender/RenderAnimatedCamera.py +++ b/meshroom/nodes/blender/RenderAnimatedCamera.py @@ -39,6 +39,14 @@ class RenderAnimatedCamera(desc.CommandLineNode): value='', uid=[0], ), + desc.FloatParam( + name='cloudPointDensity', + label='Cloud Point Density', + description='''Number of point from the cloud rendered''', + value=0.50, + range=(0.01, 0.75, 0.01), + uid=[0], + ), desc.File( name='undistortedImages', label='Images Folder', diff --git a/meshroom/nodes/blender/scripts/camera_support.py b/meshroom/nodes/blender/scripts/camera_support.py index d6fd585f..2188d44b 100644 --- a/meshroom/nodes/blender/scripts/camera_support.py +++ b/meshroom/nodes/blender/scripts/camera_support.py @@ -32,7 +32,12 @@ def main(): "--sfMCameraPath", dest="SFM_cam_path", metavar='FILE', required=True, help="This text will be used to render an image", ) - + + parser.add_argument( + "--cloudPointDensity", dest="Cloud_Point_Density", type=float, required=True, + help="Number of point from the cloud rendered", + ) + parser.add_argument( "--undistortedImages", dest="undisto_images", metavar='FILE', required=True, help="Save the generated file to the specified path", @@ -58,6 +63,11 @@ def main(): print("Error: --undisto_images argument not given, aborting.") parser.print_help() return + + if not args.Cloud_Point_Density: + print("Error: --Cloud_Point_Density argument not given, aborting.") + parser.print_help() + return if not args.output_path: print("Error: --output_path argument not given, aborting.") @@ -106,6 +116,7 @@ def main(): bpy.context.view_layer.objects.active = obj bpy.context.scene.camera = obj #bpy.ops.image.open(directory=args.undisto_images, files=undis_imgs, show_multiview=False) + bpy.ops.image.open(filepath=args.undisto_images + "985078214_RJB05565.exr", directory=args.undisto_images, files=undis_imgs, relative_path=True, show_multiview=False) obj.data.show_background_images = True @@ -126,9 +137,10 @@ def main(): obj.modifiers.new("ParticleSystem", "PARTICLE_SYSTEM") particle_system = bpy.data.particles["ParticleSystem"] particle_system.render_type = 'OBJECT' + particle_system.instance_object = bpy.data.objects["Cube"] particle_system.emit_from = 'VERT' - particle_system.count = 4000 #Modulation of numbers in the node + particle_system.count = 4000#args.Cloud_Point_Density * len(obj.vertices.values()) particle_system.frame_end = 1.0 particle_system.use_emit_random = False particle_system.particle_size = 0.02