Beispiel #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(
    name="my_timeline",
Beispiel #2
0
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,
Beispiel #3
0
                                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.
                    )
                )
            ]
        }
    ),
)

# Now add this object to the project
my_project["objects"].append(my_object)
    "front":
    placement.W3DPlacement(
        position=convert_to_blender_axes((0, 4, 0)),
        relative_to="FrontWall",
        rotation=placement.W3DRotation(rotation_mode="Axis",
                                       rotation_vector=(0, 1, 0),
                                       rotation_angle=180),
    ),
}

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)
])
Beispiel #5
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

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

my_project = project.W3DProject(call_directory=os.path.dirname(__file__),
                                allow_movement=True)

my_object = objects.W3DObject(
    name="lit",
    color=(255, 255, 255),
    placement=placement.W3DPlacement(position=(0, 8, 1), ),
    content=objects.W3DText(text="This text is lit!"),
    lighting=True)
my_project["objects"].append(my_object)

my_object = objects.W3DObject(
    name="unlit",
    color=(255, 255, 255),
    placement=placement.W3DPlacement(position=(0, 8, -1), ),
    content=objects.W3DText(text="This text is not."),
    lighting=False)

my_project["objects"].append(my_object)

my_object = objects.W3DObject(name="monkey",
                              color=(255, 255, 255),
    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),
                                     rotation=placement.W3DRotation(
                                         rotation_mode="LookAt",
                                         rotation_vector=(0, 0, 0))),
    content=objects.W3DText(text="Left"),
Beispiel #7
0
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(
    psys.W3DPAction(name="my_actions",
                    source_domain=psys.W3DPDomain(type="Line",
Beispiel #8
0
        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.
                            ))
                    ]
                }),
        )

        my_project["objects"].append(my_object)

        my_object = objects.W3DObject(
            name="shape{}x{}".format(i, j),
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")
Beispiel #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,
                    placement=placement.W3DPlacement(
Beispiel #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=[