Exemplo n.º 1
0
def redraw_points(dummy):
    """Redraw points of the previous Blender session."""

    # This test is very cheap, so it will not cause
    # huge overheads for scenes without point clouds
    if "contains_opengl_point_clouds" in bpy.context.scene:

        log_report(
            "INFO",
            "Checking scene for missing point cloud draw handlers",
            op=None,
        )
        for obj in bpy.data.objects:
            if "particle_coords" in obj and "particle_colors" in obj:
                coords = obj["particle_coords"]
                colors = obj["particle_colors"]

                draw_manager = DrawManager.get_singleton()
                draw_manager.register_points_draw_callback(obj, coords, colors)
                viz_point_size = (
                    bpy.context.scene.opengl_panel_settings.viz_point_size)
                draw_manager.set_point_size(viz_point_size)

        for area in bpy.context.screen.areas:
            if area.type == "VIEW_3D":
                area.tag_redraw()
                break
def draw_points(op, points):

    op.report({'INFO'}, 'Drawing points: ...')

    object_anchor_handle = add_empty("point_cloud_drawing_handle")
    draw_manager = DrawManager.get_singleton()
    draw_manager.register_points_draw_callback(object_anchor_handle, points)

    op.report({'INFO'}, 'Drawing points: Done')
 def execute(self, context):
     """Update the visualization of the point cloud in the 3D view."""
     draw_manager = DrawManager.get_singleton()
     viz_point_size = context.scene.opengl_panel_settings.viz_point_size
     draw_manager.set_point_size(viz_point_size)
     for area in bpy.context.screen.areas:
         if area.type == "VIEW_3D":
             area.tag_redraw()
             break
     return {"FINISHED"}
    def set_viz_point_size(self, value):
        point_cloud_anchor = get_selected_empty()
        if point_cloud_anchor is not None:
            point_cloud_anchor["point_size"] = value

            draw_manager = DrawManager.get_singleton()
            draw_back_handler = draw_manager.get_draw_callback_handler(
                point_cloud_anchor
            )
            draw_back_handler.set_point_size(value)
 def execute(self, context):
     """Render the point cloud and save the result as image in Blender."""
     log_report("INFO", "Save opengl render as image: ...", self)
     save_point_size = context.scene.opengl_panel_settings.save_point_size
     cam = get_selected_camera()
     image_name = "OpenGL Render"
     log_report("INFO", "image_name: " + image_name, self)
     draw_manager = DrawManager.get_singleton()
     coords, colors = draw_manager.get_coords_and_colors(visible_only=True)
     render_opengl_image(image_name, cam, coords, colors, save_point_size)
     log_report("INFO", "Save opengl render as image: Done", self)
     return {"FINISHED"}
Exemplo n.º 6
0
def draw_points(op, points, add_points_to_point_cloud_handle, reconstruction_collection=None):

    log_report('INFO', 'Add particle draw handlers', op)

    coords, colors = Point.split_points(points)
    object_anchor_handle = add_empty(
        "OpenGL Point Cloud", reconstruction_collection)
    if add_points_to_point_cloud_handle:
        object_anchor_handle['particle_coords'] = coords
        object_anchor_handle['particle_colors'] = colors
        bpy.context.scene['contains_opengl_point_clouds'] = True

    draw_manager = DrawManager.get_singleton()
    draw_manager.register_points_draw_callback(
        object_anchor_handle, coords, colors)
    def execute(self, context):
        """Render the point cloud and export the result as image sequence."""
        log_report("INFO", "Export opengl render as image sequencemation: ...",
                   self)
        scene = context.scene
        save_point_size = scene.opengl_panel_settings.save_point_size

        # The export helper stores the path in self.filepath (even if it is a
        # directory)
        output_dp = self.filepath
        log_report("INFO", "Output Directory Path: " + str(output_dp), self)

        if not os.path.isdir(output_dp):
            os.mkdir(output_dp)

        # Used to cache the results
        image_name = "OpenGL Export"
        ext = "." + scene.opengl_panel_settings.render_file_format
        save_alpha = scene.opengl_panel_settings.save_alpha
        selected_cam = get_selected_camera()
        use_camera_keyframes = (
            scene.opengl_panel_settings.use_camera_keyframes_for_rendering)
        if (use_camera_keyframes and selected_cam is not None
                and selected_cam.animation_data is not None):
            animation_indices = get_object_animation_indices(selected_cam)
        else:
            animation_indices = get_scene_animation_indices()

        draw_manager = DrawManager.get_singleton()
        coords, colors = draw_manager.get_coords_and_colors(visible_only=True)
        for idx in animation_indices:
            bpy.context.scene.frame_set(idx)
            current_frame_fn = str(idx).zfill(5) + ext
            current_frame_fp = os.path.join(output_dp, current_frame_fn)

            log_report("INFO", "Output File Path: " + str(current_frame_fp),
                       self)
            render_opengl_image(image_name, selected_cam, coords, colors,
                                save_point_size)
            save_image_to_disk(image_name, current_frame_fp, save_alpha)

        log_report("INFO", "Save opengl render as animation: Done", self)
        return {"FINISHED"}
Exemplo n.º 8
0
def _draw_coords_with_color(
    coords,
    colors,
    add_points_to_point_cloud_handle,
    reconstruction_collection=None,
    object_anchor_handle_name="OpenGL Point Cloud",
    op=None,
):

    object_anchor_handle = add_empty(object_anchor_handle_name,
                                     reconstruction_collection)
    if add_points_to_point_cloud_handle:
        object_anchor_handle["particle_coords"] = coords
        object_anchor_handle["particle_colors"] = colors
        bpy.context.scene["contains_opengl_point_clouds"] = True

    draw_manager = DrawManager.get_singleton()
    draw_manager.register_points_draw_callback(object_anchor_handle, coords,
                                               colors)
    return object_anchor_handle
Exemplo n.º 9
0
def redraw_points(dummy):

    # This test is very cheap, so it will not cause 
    # huge overheads for scenes without point clouds
    if 'contains_opengl_point_clouds' in bpy.context.scene:

        log_report('INFO', 'Checking scene for missing point cloud draw handlers', dummy)
        for obj in bpy.data.objects:
            if 'particle_coords' in obj and 'particle_colors' in obj:
                coords = obj['particle_coords']
                colors = obj['particle_colors']

                draw_manager = DrawManager.get_singleton()
                draw_manager.register_points_draw_callback(
                    obj, coords, colors)
                viz_point_size = bpy.context.scene.opengl_panel_viz_settings.viz_point_size
                draw_manager.set_point_size(viz_point_size)

        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                area.tag_redraw()
                break
    def execute(self, context):
        """Render the point cloud and export the result as image."""
        log_report("INFO", "Export opengl render as image: ...", self)
        scene = context.scene
        save_point_size = scene.opengl_panel_settings.save_point_size

        filename_ext = scene.opengl_panel_settings.render_file_format
        ofp = self.filepath + "." + filename_ext
        log_report("INFO", "Output File Path: " + ofp, self)

        # Used to cache the results
        image_name = "OpenGL Export"

        cam = get_selected_camera()
        draw_manager = DrawManager.get_singleton()
        coords, colors = draw_manager.get_coords_and_colors(visible_only=True)
        render_opengl_image(image_name, cam, coords, colors, save_point_size)

        save_alpha = scene.opengl_panel_settings.save_alpha
        save_image_to_disk(image_name, ofp, save_alpha)

        log_report("INFO", "Save opengl render as image: Done", self)
        return {"FINISHED"}