Skip to content

How to set "real" color with 'MaterialRecord' #6261

Open
@beta1scat

Description

@beta1scat

Checklist

My Question

I use the code in the #6260 :

#!/usr/bin/env python

import numpy as np
import open3d as o3d

RED = [1.0, 0.0, 0.0, 1.0]
GREEN = [0.0, 0.5, 0.0, 1.0]  # dark green is easier to see on white when small
BLUE = [0.0, 0.0, 1.0, 1.0]

def add_cloud(scene, name, npts, center, radius, color, size):
    pts = np.random.uniform(-radius, radius, size=[npts, 3]) + center
    cloud = o3d.geometry.PointCloud()
    cloud.points = o3d.utility.Vector3dVector(pts)

    material = o3d.visualization.rendering.Material()
    material.shader = "defaultUnlit"
    material.base_color = color
    material.point_size = size
    scene.add_geometry(name, cloud, material)

def main():
    app = o3d.visualization.gui.Application.instance
    app.initialize()
    window = app.create_window("Open3d", 1024, 768)
    widget3d = o3d.visualization.gui.SceneWidget()
    widget3d.scene = o3d.visualization.rendering.Open3DScene(window.renderer)
    widget3d.scene.set_background_color([1.0, 1.0, 1.0, 1.0])
    window.add_child(widget3d)

    add_cloud(widget3d.scene, "green", 5000, [0, 0, 0], 10.0, GREEN, 2)
    add_cloud(widget3d.scene, "red", 500, [-2, -2, -2], 5.0, RED, 4)
    add_cloud(widget3d.scene, "blue", 250, [1, 1, 1], 5.0, BLUE, 6)

    widget3d.setup_camera(60, widget3d.scene.bounding_box, [0, 0, 0])

    app.run()

if __name__ == "__main__":
    main()

First, I found the backgroud color is not "real" #FFFFFF, so I add a line to set backgroud color to "real" #FFFFFF.

widget3d.scene.view.set_post_processing(False)

Second, I found the MaterialRecord.base_color is also not "real", I set #FF0000 will get #7F0000, #00FF00 will get #007F00, #0000FF will get #0000FF. I'm confusing how to set the "real" color.
2023-07-11_19-06
2023-07-11_19-07

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions