Ejemplo n.º 1
0
# Next, let's create a clickable object to start the timeline
my_object = objects.W3DObject(
    name="button",  # Give it a name
    color=(255, 0, 0),  # Make it red
    placement=placement.W3DPlacement(  # Specify position and orientation
        position=(0, 1, 0),  # We'll leave rotation as default for now
    ),
    content=objects.W3DText(  # Specify that this is a text object
        text="Play"  # ...with text reading "Hello, World!"
    ),
    link=objects.W3DLink(  # Add a clickable link to the text object
        actions={
            0: [  # On first click (index 0)...
                actions.TimelineAction(  # start the timeline
                    timeline_name="my_timeline", change="Start"
                )
            ]
        }
    )
)

# Now add this object to the project
my_project["objects"].append(my_object)
my_project["debug"] = True

# Finally, we render the whole thing using Blender, export it, and display the
# result
export_to_blender(my_project,
                  filename="timeline_sound_sample.blend",
                  display=True)
Ejemplo n.º 2
0
)
right_sound = sounds.W3DSound(name="right",
                              filename="sound/right.wav",
                              movement_mode="Positional")
long_sound = sounds.W3DSound(name="long", filename="sound/long.wav")

# Next, let's create link to play a basic sound
play_object = objects.W3DObject(
    name="play",
    placement=placement.W3DPlacement(position=(0, 10, 1), ),
    content=objects.W3DText(text="Play Sound!"),
    link=objects.W3DLink(
        actions={
            -1: [  # On every click (negative number)...
                actions.SoundAction(  # Affect the sound...
                    sound_name="basic",  # named "basic"...
                    change="Start"  # by starting it.
                )
            ]
        }))

# An object to play a sound to the left
left_object = objects.W3DObject(
    name="left_button",
    placement=placement.W3DPlacement(position=(-5, 0, 0),
                                     rotation=placement.W3DRotation(
                                         rotation_mode="LookAt",
                                         rotation_vector=(0, 0, 0))),
    content=objects.W3DText(text="Left"),
    sound="left",  # Attach the sound named left to this object
    link=objects.W3DLink(
Ejemplo n.º 3
0
    color=(255, 0, 0),  # Make it red
    placement=placement.W3DPlacement(  # Specify position and orientation
        position=(0, 1, 0),  # We'll leave rotation as default for now
    ),
    content=objects.W3DText(  # Specify that this is a text object
        text="Hello, World!",  # ...with text reading "Hello, World!"
        font="LinBiolinum_K.otf"
    ),
    link=objects.W3DLink(  # Add a clickable link to the text object
        actions = {
            -1: [  # On every click (negative number)...
                actions.ObjectAction(  # ...change the object...
                    object_name="hello",  # ...named hello...
                    duration=1,  # ...over a period of one second...
                    move_relative=True,  # ...by moving it relative to its
                                         # current location...
                    placement=placement.W3DPlacement(
                        position=(0, 0.5, 0)  # ...back half a meter.
                    )
                )
            ]
        }
    ),
)

# Now add this object to the project
my_project["objects"].append(my_object)

#Finally, we render the whole thing using Blender, export it, and display the
#result
export_to_blender(my_project, filename="link_sample.blend", display=True)
Ejemplo n.º 4
0
        my_object = objects.W3DObject(
            name="elem{}x{}".format(i, j),
            color=(randint(0, 255), randint(0, 255), randint(0, 255)),
            placement=placement.W3DPlacement(
                position=(radius * sin(theta) * cos(phi),
                          radius * sin(theta) * sin(phi), radius * cos(theta)),
                rotation=placement.W3DRotation(rotation_mode="LookAt",
                                               rotation_vector=(0, 0, 0))),
            content=objects.W3DText(text="W3D"),
            link=objects.W3DLink(
                actions={
                    -1: [
                        actions.ObjectAction(
                            object_name="elem{}x{}".format(i, j),
                            duration=1,
                            move_relative=True,
                            placement=placement.W3DPlacement(
                                position=(0, 0.5, 0)  # ...back half a meter.
                            ))
                    ]
                }),
        )

        my_project["objects"].append(my_object)

        my_object = objects.W3DObject(
            name="shape{}x{}".format(i, j),
            content=objects.W3DShape(shape_type=shapes[(i + j) % len(shapes)]),
            placement=placement.W3DPlacement(
                rotation=placement.W3DRotation(rotation_mode="LookAt",
                                               rotation_vector=(0, 0, 0)),