Example #1
0
    )

    absolute_actions.extend(
        [
            (
                1 + 2 * j, actions.ObjectAction(
                    object_name=object_name,
                    placement=placement.W3DPlacement(
                        position=(
                            0,
                            radius * sin(
                                all_angles[(i + j + 1) % theta_div]),
                            radius * cos(
                                all_angles[(i + j + 1) % theta_div]),
                        ),
                        rotation=placement.W3DRotation(
                            rotation_mode="Axis",
                            rotation_vector=(1, 0, 0),
                            rotation_angle=degrees(
                                -all_angles[
                                    (i + j + 1) % theta_div] + pi / 2
                            )
                        ),
                    ),
                    duration=1
                )
            ) for j in range(theta_div)
        ]
    )

    relative_actions.extend(
Example #2
0
for name, positioning in placements_dic.items():

    my_object = objects.W3DObject(
        name=name,
        color=(200, 0, 180),
        placement=positioning,
        scale=0.5,
        content=objects.W3DText(text=name.upper()),
    )

    my_project["objects"].append(my_object)

absolute_actions.extend([
    (1 + 2 * j,
     actions.ObjectAction(
         object_name=ordered_names[i],
         placement=placements_dic[ordered_names[(j + i) % len(ordered_names)]],
         duration=1)) for i in range(len(ordered_names))
    for j in range(len(ordered_names) + 1)
])

relative_actions.extend([
    (2,
     actions.ObjectAction(
         object_name=ordered_names[i],
         placement=relative_placement_dic[ordered_names[i]],
         move_relative=True,
         duration=1,
     )) for i in range(len(ordered_names))
])

relative_actions.extend([
Example #3
0
right_object = objects.W3DObject(
    name="right_object",
    placement=placement.W3DPlacement(position=(5, 0, 0), ),
    content=objects.W3DText(text="Right"),
    sound="right",  # Attach the sound named right to this object
    visible=False)
my_project["objects"].append(left_object)
my_project["objects"].append(right_object)

# A timeline to play the sounds
my_timeline = timeline.W3DTimeline(
    name="my_timeline",
    start_immediately=False,
    actions=[(0, actions.SoundAction(sound_name="basic", change="Start")),
             (3.1,
              actions.ObjectAction(object_name="left_object",
                                   sound_change="Start")),
             (6.2,
              actions.ObjectAction(object_name="right_object",
                                   sound_change="Start"))])
my_project["timelines"].append(my_timeline)

# 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!"
    ),
Example #4
0
        }))

# 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(
        actions={
            -1: [
                actions.ObjectAction(  # Affect the object...
                    object_name="left_button",  # named "left_button"...
                    sound_change="Start"  # by starting its sound file.
                )
            ]
        }))

# An object to play a sound to the right
right_object = objects.W3DObject(
    name="right_button",
    placement=placement.W3DPlacement(position=(5, 0, 0),
                                     rotation=placement.W3DRotation(
                                         rotation_mode="LookAt",
                                         rotation_vector=(0, 0, 0))),
    content=objects.W3DText(text="Right"),
    sound="right",  # Attach the sound named right to this object
    link=objects.W3DLink(
        actions={
Example #5
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)
Example #6
0
# Next, we create the particle system itself

my_project["objects"].append(
    objects.W3DObject(name="system",
                      placement=placement.W3DPlacement(position=(0, 8, 0)),
                      content=objects.W3DPSys(particle_group="particles",
                                              max_particles=100,
                                              max_age=3,
                                              speed=1,
                                              particle_actions="my_actions"),
                      visible=False))

visibility_actions = [
    (0, actions.ObjectAction(
        object_name="system",
        visible=True,
        duration=5,
    )),
    (10, actions.ObjectAction(
        object_name="system",
        visible=False,
        duration=5,
    )),
    (16, actions.TimelineAction(timeline_name="visify", change="Start")),
]
vis_timeline = timeline.W3DTimeline(name="visify",
                                    start_immediately=True,
                                    actions=visibility_actions)

my_project["timelines"].append(vis_timeline)
Example #7
0
        text="Right"
    ),
    sound="right",  # Attach the sound named right to this object
    visible=False
)
my_project["objects"].append(left_object)
my_project["objects"].append(right_object)


# A timeline to play the sounds
my_timeline = timeline.W3DTimeline(
    name="my_timeline",
    start_immediately=False,
    actions=[
        (0, actions.SoundAction(sound_name="DOESNOTEXIST", change="Start")),
        (3.1, actions.ObjectAction(
            object_name="DOESNOTEXIST", sound_change="Start")),
        (6.2, actions.ObjectAction(
            object_name="DOESNOTEXIST", sound_change="Start"))
    ]
)
my_project["timelines"].append(my_timeline)


# 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
Example #8
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)),
Example #9
0
            text="{}".format(int(180 / pi * theta))
        ),
    )

    absolute_actions.extend(
        [
            (
                1 + 2 * j, actions.ObjectAction(
                    object_name=object_name,
                    placement=placement.W3DPlacement(
                        position=(
                            radius * sin(
                                all_angles[(i + j + 1) % theta_div]),
                            radius * cos(
                                all_angles[(i + j + 1) % theta_div]),
                            0,
                        ),
                        rotation=placement.W3DRotation(
                            rotation_mode="LookAt",
                            rotation_vector=(0, 0, theta_div - 1 - j),
                        ),
                    ),
                    duration=1
                )
            ) for j in range(theta_div)
        ]
    )

    relative_actions.extend(
        [
            (
Example #10
0
                rotation_mode="Normal",
                rotation_vector=[-coord for coord in all_positions[i]],
                rotation_angle=90)),
        content=objects.W3DText(
            text="L{}R".format(int(180 / pi * all_angles[i]))),
    )

    absolute_actions.extend([
        (1 + 2 * j,
         actions.ObjectAction(
             object_name=object_name,
             placement=placement.W3DPlacement(
                 position=all_positions[(i + j + 1) % theta_div],
                 rotation=placement.W3DRotation(
                     rotation_mode="Normal",
                     rotation_vector=[
                         -coord
                         for coord in all_positions[(i + j + 1) % theta_div]
                     ],
                     rotation_angle=0),
             ),
             duration=1)) for j in range(theta_div)
    ])

    relative_actions.extend([
        (
            2 * j,
            actions.ObjectAction(
                object_name=object_name,
                # move_relative=True,
                placement=placement.W3DPlacement(