コード例 #1
0
left_sound = sounds.W3DSound(
    name="left",
    filename="sound/left.wav",
    movement_mode="Positional"  # Positional for 3D audio
)
right_sound = sounds.W3DSound(name="right",
                              filename="sound/right.wav",
                              movement_mode="Positional")
my_project["sounds"].append(play_sound)
my_project["sounds"].append(left_sound)
my_project["sounds"].append(right_sound)

# An object to play a sound to the left
left_object = objects.W3DObject(
    name="left_object",
    placement=placement.W3DPlacement(position=(-5, 0, 0), ),
    content=objects.W3DText(text="Left"),
    sound="left",  # Attach the sound named left to this object
    visible=False)
# An object to play a sound to the right
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(
コード例 #2
0
ファイル: axis_rotations.py プロジェクト: jryoo94/Writing3D
all_angles = [2 * pi / theta_div * i for i in range(theta_div)]
for i in range(0, theta_div):

    theta = all_angles[i]

    object_name = "elem_x_{}".format(i)

    my_object = objects.W3DObject(
        name=object_name,
        color=(int(i / theta_div * 255), 100, 0),
        placement=placement.W3DPlacement(
            position=(
                0,
                radius * sin(theta),
                radius * cos(theta)
            ),
            rotation=placement.W3DRotation(
                rotation_mode="Axis",
                rotation_vector=(1, 0, 0),
                rotation_angle=degrees(-theta + pi / 2)
            )
        ),
        content=objects.W3DText(
            text="{}".format(int(180 / pi * theta))
        ),
    )

    absolute_actions.extend(
        [
            (
                1 + 2 * j, actions.ObjectAction(
                    object_name=object_name,
コード例 #3
0
ファイル: font_sample.py プロジェクト: jryoo94/Writing3D
    $ python3 link_sample.py
"""

import os
from pyw3d import project, objects, placement, actions, export_to_blender

# First, create a W3DProject to hold everything else you'll create
my_project = project.W3DProject(call_directory=os.path.dirname(__file__),
                                allow_movement=True)

# Next, let's create a simple text object
my_object = objects.W3DObject(
    name="hello",  # 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="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.
コード例 #4
0
import os
from pyw3d import project, objects, placement, export_to_blender, timeline, \
    actions, convert_to_blender_axes

# First, create a W3DProject to hold everything else you'll create
my_project = project.W3DProject(call_directory=os.path.dirname(__file__),
                                allow_movement=True)

relative_actions = []
absolute_actions = []

ordered_names = ["floor", "left", "front", "right"]

placements_dic = {
    "floor":
    placement.W3DPlacement(position=convert_to_blender_axes((0, 0, 4)),
                           relative_to="FloorWall"),
    "left":
    placement.W3DPlacement(position=convert_to_blender_axes((0, 4, 0)),
                           relative_to="LeftWall"),
    "right":
    placement.W3DPlacement(position=convert_to_blender_axes((0, 4, 0)),
                           relative_to="RightWall"),
    "front":
    placement.W3DPlacement(position=convert_to_blender_axes((0, 4, 0)),
                           relative_to="FrontWall"),
}
relative_placement_dic = {
    "floor":
    placement.W3DPlacement(position=convert_to_blender_axes((0, 0, 4)),
                           rotation=placement.W3DRotation(rotation_mode="Axis",
                                                          rotation_vector=(0,
コード例 #5
0
import os
from pyw3d import project, objects, placement, export_to_blender,\
    psys, groups, actions, timeline

# First, create a W3DProject to hold everything else you'll create
my_project = project.W3DProject(call_directory=os.path.dirname(__file__),
                                allow_movement=True)

# Next, let's create three simple text objects that will be emitted by our
# system
particles = []
for index, char in enumerate(["W", "3", "D"]):
    particles.append(
        objects.W3DObject(
            name="part{}".format(index),  # Give it a name
            placement=placement.W3DPlacement(),
            color=(255, 0, 0),
            content=objects.W3DText(  # Specify that this is a text object
                text=char),
            visible=False  # This object needn't be visible.
        ))
# Now add these objects to the project
my_project["objects"].extend(particles)

# and make them a group.
my_project["groups"].append(
    groups.W3DGroup(name="particles",
                    objects=[obj["name"] for obj in particles]))

# Next, we describe the actions that will describe the system
my_project["particle_actions"].append(
コード例 #6
0
# Next, make the test sounds available in Writing3D
play_sound = sounds.W3DSound(name="basic", filename="sound/play.wav")
left_sound = sounds.W3DSound(
    name="left",
    filename="sound/left.wav",
    movement_mode="Positional"  # Positional for 3D audio
)
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),
コード例 #7
0
import os
from pyw3d import project, objects, placement, export_to_blender, timeline, \
    actions, convert_to_blender_axes

# First, create a W3DProject to hold everything else you'll create
my_project = project.W3DProject(call_directory=os.path.dirname(__file__),
                                allow_movement=True)

relative_actions = []
absolute_actions = []

ordered_names = ["floor", "left", "front", "right"]

placements_dic = {
    "floor":
    placement.W3DPlacement(position=convert_to_blender_axes((0, 0, 4)),
                           relative_to="FloorWall"),
    "left":
    placement.W3DPlacement(position=convert_to_blender_axes((0, 4, 0)),
                           relative_to="LeftWall"),
    "right":
    placement.W3DPlacement(position=convert_to_blender_axes((0, 4, 0)),
                           relative_to="RightWall"),
    "front":
    placement.W3DPlacement(position=convert_to_blender_axes((0, 4, 0)),
                           relative_to="FrontWall"),
}

for name, positioning in placements_dic.items():

    my_object = objects.W3DObject(
        name=name,
コード例 #8
0
ファイル: performance.py プロジェクト: jryoo94/Writing3D
radius = 10
for i in range(1, theta_div):
    for j in range(phi_div):
        theta = pi / theta_div * i
        phi = 2 * pi / phi_div * j

        play_sound = sounds.W3DSound(name="basic{}x{}".format(i, j),
                                     filename="sound/play.wav")
        my_project["sounds"].append(play_sound)

        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.
                            ))
                    ]
                }),
コード例 #9
0
radius = 10
for i in range(1, theta_div):
    for j in range(phi_div):
        theta = pi/theta_div*i
        phi = 2*pi/phi_div*j

        my_object = objects.W3DObject(
            name="elem{}x{}".format(i, j),
            color=(randint(0, 255), randint(0, 255), randint(0, 255)),
            double_sided=False,
            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"
            ),
        )

        my_project["objects"].append(my_object)

#Now, we export the project to archival XML (e.g. for use in legacy cwapp
#environment)
my_project.save_XML("single_sided_sample.xml")
コード例 #10
0
all_angles = [2 * pi / theta_div * i for i in range(theta_div)]
for i in range(0, theta_div):

    theta = all_angles[i]

    object_name = "elem_y_{}".format(i)

    my_object = objects.W3DObject(
        name=object_name,
        color=(int(i / theta_div * 255), 100, 0),
        placement=placement.W3DPlacement(
            position=(
                radius * sin(theta),
                radius * cos(theta),
                0,
            ),
            rotation=placement.W3DRotation(
                rotation_mode="LookAt",
                rotation_vector=(0, 0, theta_div),
            )
        ),
        content=objects.W3DText(
            text="{}".format(int(180 / pi * theta))
        ),
    )

    absolute_actions.extend(
        [
            (
                1 + 2 * j, actions.ObjectAction(
                    object_name=object_name,
コード例 #11
0
radius = 10
relative_actions = []
absolute_actions = []
all_angles = [2 * pi / theta_div * i for i in range(theta_div)]
all_positions = [(radius * sin(theta), radius * cos(theta), 0)
                 for theta in all_angles]
for i in range(0, theta_div):

    object_name = "elem_y_{}".format(i)

    my_object = objects.W3DObject(
        name=object_name,
        color=(int(i / theta_div * 255), 100, 0),
        placement=placement.W3DPlacement(
            position=all_positions[i],
            rotation=placement.W3DRotation(
                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=[