Exemplo n.º 1
0
    def register_points_draw_callback(self, object_anchor, points):
        coords, colors = Point.split_points(points)
        draw_callback_handler = DrawCallBackHandler()
        draw_callback_handler.register_points_draw_callback(
            self, object_anchor, coords, colors)
        self.draw_callback_handler_list.append(draw_callback_handler)

        self.anchor_to_point_coords[object_anchor] = coords
        self.anchor_to_point_colors[object_anchor] = colors
Exemplo n.º 2
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 create_particle_color_nodes(node_tree,
                                points,
                                set_particle_color_flag,
                                particle_overwrite_color=None):

    if set_particle_color_flag:
        assert particle_overwrite_color is not None
        if 'RGB' in node_tree.nodes:
            particle_color_node = node_tree.nodes['RGB']
        else:
            particle_color_node = node_tree.nodes.new("ShaderNodeRGB")

        rgba_vec = Vector(particle_overwrite_color).to_4d()  # creates a copy
        particle_color_node.outputs['Color'].default_value = rgba_vec

    else:
        if 'Image Texture' in node_tree.nodes:
            particle_color_node = node_tree.nodes['Image Texture']
        else:
            particle_color_node = node_tree.nodes.new("ShaderNodeTexImage")

        coords, colors = Point.split_points(points)
        particle_color_node.image = compute_particle_color_texture(colors)

        particle_info_node = node_tree.nodes.new('ShaderNodeParticleInfo')
        divide_node = node_tree.nodes.new('ShaderNodeMath')
        divide_node.operation = 'DIVIDE'
        node_tree.links.new(particle_info_node.outputs['Index'],
                            divide_node.inputs[0])
        divide_node.inputs[1].default_value = len(points)
        shader_node_combine = node_tree.nodes.new('ShaderNodeCombineXYZ')
        node_tree.links.new(divide_node.outputs['Value'],
                            shader_node_combine.inputs['X'])
        node_tree.links.new(shader_node_combine.outputs['Vector'],
                            particle_color_node.inputs['Vector'])

    return particle_color_node