예제 #1
0
def init_origin(scene: Scene):
    """Origin object, construction cone, so user knows ARB is running."""
    # TODO: migrate to shared-scene setting
    size = [0.2, 0.4, 0.2]
    scene.add_object(Cone(  # 370mm x 370mm # 750mm
        object_id="arb-origin",
        material=Material(
            color=Color(255, 114, 33),
            transparent=True,
            opacity=0.5,
            shader="flat"),
        position=Position(0, size[1] / 2, 0),
        scale=Scale(size[0] / 2, size[1], size[2] / 2)))
    scene.add_object(Cone(
        object_id="arb-origin-hole",
        **{"material-extras": {"transparentOccluder": True}},
        position=Position(0, size[1] - (size[1] / 2 / 15), 0),
        scale=Scale(size[0] / 15, size[1] / 10, size[2] / 15)))
    scene.add_object(Box(
        object_id="arb-origin-base",
        material=Material(
            color=Color(0, 0, 0),
            transparent=True,
            opacity=0.5,
            shader="flat"),
        position=Position(0, size[1] / 20, 0),
        scale=Scale(size[0], size[1] / 10, size[2])))
예제 #2
0
 def __init__(self, scene: Scene, camname, mode, x=0, y=0, label="", parent=None,
              drop=None, color=CLR_BUTTON, enable=True, callback=None,
              btype=ButtonType.ACTION):
     self.scene = scene
     if label == "":
         label = mode.value
     if parent is None:
         parent = camname
         scale = Scale(0.1, 0.1, 0.01)
     else:
         scale = Scale(1, 1, 1)
     self.type = btype
     self.enabled = enable
     if enable:
         self.colorbut = color
     else:
         self.colorbut = CLR_BUTTON_DISABLED
     self.colortxt = CLR_BUTTON_TEXT
     if len(label) > 8:  # easier to read
         self.label = f"{label[:6]}..."
     else:
         self.label = label
     self.mode = mode
     self.dropdown = drop
     self.active = False
     if drop is None:
         obj_name = f"{camname}_button_{mode.value}"
     else:
         obj_name = f"{camname}_button_{mode.value}_{drop}"
     shape = Box.object_type
     if btype == ButtonType.TOGGLE:
         shape = Cylinder.object_type
         scale = Scale(scale.x / 2, scale.y, scale.z / 2)
     self.button = Object(  # box is main button
         object_id=obj_name,
         object_type=shape,
         parent=parent,
         material=Material(
             color=self.colorbut,
             transparent=True,
             opacity=OPC_BUTTON,
             shader="flat"),
         position=Position(x * 1.1, PANEL_RADIUS, y * -1.1),
         scale=scale,
         clickable=True,
         evt_handler=callback,
     )
     scene.add_object(self.button)
     scale = Scale(1, 1, 1)
     if btype == ButtonType.TOGGLE:
         scale = Scale(scale.x * 2, scale.y * 2, scale.z)
     self.text = Text(  # text child of button
         object_id=f"{self.button.object_id}_text",
         parent=self.button.object_id,
         text=self.label,
         # position inside to prevent ray events
         position=Position(0, -0.1, 0),
         rotation=Rotation(-0.7, 0, 0, 0.7),
         scale=scale,
         color=self.colortxt,
     )
     scene.add_object(self.text)