Esempio n. 1
0
            y += cardSizex if (j % 2) else -cardSizex
            if (j > 0): x += 2.4
            orientation = "0 0 -1 " + str(math.pi / 2.)
            Box(root,
                name='book' + str(j),
                position=str(x) + " " + str(y) + " " + str(z),
                dim=dim,
                color="0. 0. 0.5 1.",
                orientation=orientation,
                friction="0.3",
                density="1")

        y -= (cardSizey - shifty) / 2.
        x = x0 + (cardSizey / 2. - shiftx) * i

        # Orientide Cards
        for j in range((nbFloor - i) * 2):
            if (j > 0): x += 1.2
            orientation = "0 0 -1 0.4" if (j % 2 == 0) else "0 0 1 0.4"
            Box(root,
                name='book' + str(j),
                position=str(x) + " " + str(y) + " " + str(z),
                dim=dim,
                color="0. 0. 0.5 1.",
                orientation=orientation,
                friction="0.3",
                density="1")
        y += (cardSizey - shifty) / 2.

export(root, "../houseOfCards.xml")
Esempio n. 2
0
import xml.etree.ElementTree as ET
from modules.box import Box
from modules.exportXML import export

root = ET.Element('root')

# Plane
plane = ET.SubElement(root, 'body')
plane.set('type', 'plane')
plane.set('p', '0 -1 0')
plane.set('n', '0 1 0')
plane.set('name', 'plane')

# Bodies pile
x = 0
for i in range(5):
    x += 8.1
    Box(root, name='box' + str(i), position=str(x) + " 0.0 0.0", dim='8 2 2')

export(root, "../line.xml")
Esempio n. 3
0
    position="-35.75 " + yb + " 1.",
    dim="0.15 2 1.5",
    color=colors[random.randint(0, 3)],
    friction="0.3",
    density="0.1")
Box(root,
    name='bookAlone2',
    position="-35.9 " + yb + " 1.",
    dim="0.1 2 1.5",
    color=colors[random.randint(0, 3)],
    friction="0.3",
    density="0.1")

# Truck
composite = Composite(root,
                      obj="data/truck.obj",
                      name="truck",
                      scale="0.1",
                      position="0. 2.5 0.",
                      color="0.5 0.5 0.5 1.",
                      density="1",
                      friction="0.3")
composite.addBox(name='ground', position="-20 -3.5 0", dim='80 2 25')
composite.addBox(name='ground', position="-50 -12 10", dim='5 12 5')
composite.addBox(name='ground', position="-50 -12 -10", dim='5 12 5')
composite.addBox(name='ground', position="5 -12 -10", dim='5 12 5')
composite.addBox(name='ground', position="5 -12 10", dim='5 12 5')
#composite.addBox(name='cockpit', position="-100 10 10", dim='20 20 20')

export(root, "../chariot.xml")
Esempio n. 4
0
# spinnery=6.5
# dist=2.1
# dx=dy=dz=0
# for i in range(2):
#     dx+=dist
#     dz=0
#     for j in range(2):
#         dz+=dist
#         Sphere(root, position=str(dx+0.75)+" "+str(dy+spinnery)+" "+str(dz+0.75), radius="1", color="0.8 0.6 0.6 1.", density="0.00001", friction="0.1")
#         Sphere(root, position=str(dx-6.75)+" "+str(dy+spinnery)+" "+str(dz-6.75), radius="1", color="0.6 0.8 0.6 1.", density="0.00001", friction="0.1")
#         Box(root, position=str(dx-6.75)+" "+str(dy+spinnery)+" "+str(dz+0.75), orientation="0 -1 0 0", dim="2 2 2", color="0.6 0.8 0.8 1.", density="0.00001", friction="0.1")
#         Box(root, position=str(dx+0.75)+" "+str(dy+spinnery)+" "+str(dz-6.75), orientation="0 -1 0 0", dim="2 2 2", color="0.8 0.8 0.6 1.", density="0.00001", friction="0.1")
# export(root, "../spinnerMultiple.xml")

# spinnery=7
# dx=dy=dz=0
# Sphere(root, position=str(dx+3.75)+" "+str(dy+spinnery)+" "+str(dz+3.75), radius="2", color="0.8 0.6 0.6 1.", density="0.0001")
# Sphere(root, position=str(dx-3.75)+" "+str(dy+spinnery)+" "+str(dz-3.75), radius="2", color="0.6 0.8 0.6 1.", density="0.0001")
# Box(root, position=str(dx-3.75)+" "+str(dy+spinnery)+" "+str(dz+3.75), orientation="0 -1 0 0", dim="3 3 3", color="0.6 0.8 0.8 1.", density="0.0001")
# Box(root, position=str(dx+3.75)+" "+str(dy+spinnery)+" "+str(dz-3.75), orientation="0 -1 0 0", dim="3 3 3", color="0.8 0.8 0.6 1.", density="0.0001")
# export(root, "../spinnerHighRotMassRatio.xml")

spinnery=7
dx=dy=dz=0
Sphere(root, position=str(dx+3.75)+" "+str(dy+spinnery)+" "+str(dz+3.75), radius="2", color="0.8 0.6 0.6 1.", density="0.1")
Sphere(root, position=str(dx-3.75)+" "+str(dy+spinnery)+" "+str(dz-3.75), radius="2", color="0.6 0.8 0.6 1.", density="0.1")
Box(root, position=str(dx-3.75)+" "+str(dy+spinnery)+" "+str(dz+3.75), orientation="0 -1 0 0", dim="3 3 3", color="0.6 0.8 0.8 1.", density="0.1")
Box(root, position=str(dx+3.75)+" "+str(dy+spinnery)+" "+str(dz-3.75), orientation="0 -1 0 0", dim="3 3 3", color="0.8 0.8 0.6 1.", density="0.1")
export(root, "../spinner.xml")
Esempio n. 5
0
# boat.addSpring(positionB="2.5 2.5 2.5", k="100", d="1")
# boat.addSpring(positionB="2.5 2.5 -2.5", k="100", d="1")
# boat.addSpring(positionB="-2.5 2.5 -2.5", k="100", d="1")
# boat.addSpring(positionB="-2.5 2.5 2.5", k="100", d="1")
# boat.addSpring(positionB="2.5 -2.5 2.5", k="100", d="1")
# boat.addSpring(positionB="2.5 -2.5 -2.5", k="100", d="1")
# boat.addSpring(positionB="-2.5 -2.5 -2.5", k="100", d="1")
# boat.addSpring(positionB="-2.5 -2.5 2.5", k="100", d="1")

# Ocean
ocean = Composite(root,
                  obj="data/ocean.obj",
                  scale="0.1",
                  name="ocean",
                  position="0. -2.5 60.",
                  color="0. 0.18 0.29 1.",
                  density="10")
ocean.addBox(name="dummy", position="0. -1.5 0.", dim="30 3 6")
ocean.addSpring(positionB="7. 0 1.8", positionW="7 -1.5 61.8", k="100", d="1")
ocean.addSpring(positionB="-7. 0 1.8",
                positionW="-7 -1.5 61.8",
                k="100",
                d="1")
ocean.addSpring(positionB="-7. 0 -1.8",
                positionW="-7 -1.5 58.2",
                k="100",
                d="1")
ocean.addSpring(positionB="7. 0 -1.8", positionW="7 -1.5 58.2", k="100", d="1")

export(root, "../cargoShip.xml")
Esempio n. 6
0
plane = ET.SubElement(root, 'body')
plane.set('type', 'plane')
plane.set('p', '0 0 0')
plane.set('n', '0 1 0')
plane.set('name', 'plane')

# Seesaw
composite = Composite(root,
                      obj="data/seesaw1.obj",
                      scale="0.1",
                      name="seesaw1",
                      position="0 10 0",
                      velocity="0. 0. 0.",
                      color="0.7 0.7 0.7 1.")
composite.addBox(name='seesaw1', position="0 2.0 0", dim='80 5 5')

composite = Composite(root,
                      obj="data/seesaw2.obj",
                      scale="0.1",
                      name="seesaw2",
                      position="0 10 0",
                      velocity="0. 0. 0.",
                      color="0.1 0.1 0.1 1.")
composite.addBox(name='part1',
                 position="0 -4 0",
                 dim='5 5 5',
                 orientation="0. 0. 1. " + str(math.pi / 4.))
composite.addBox(name='part2', position="0 -8 0", dim='9 5 5')

export(root, "../seesaw.xml")
Esempio n. 7
0
import xml.etree.ElementTree as ET
from modules.box import Box
from modules.exportXML import export

root = ET.Element('root')

# Plane
plane = ET.SubElement(root, 'body')
plane.set('type', 'plane')
plane.set('p', '0 -1 0')
plane.set('n', '0 1 0')
plane.set('name', 'plane')

# Bodies pile
y = 0
for i in range(15):
    y += 2.5
    Box(root,
        name='box' + str(i),
        position="0.0 " + str(y) + " 0.0",
        dim='8 2 2')

export(root, "../pile.xml")
        x += dx
        Box(root,
            name='domino' + str(i + nbDominos * k),
            position=str(x) + " " + str(y + 1.2) + " " + str(z),
            dim="0.25 2 1",
            density="2")
        if (i == nbDominos / 2):
            v = "-0.22 0 0" if (k % 2) else "0.22 0 0"
            platform = Box(root,
                           name="platform" + str(k),
                           dim=str(platformDimx) + " 0.5 3",
                           position=str(x) + " " + str(y) + " " + str(z),
                           velocity=v)
            height = 3
            platform.addSpring(
                positionB="-" + str(platformDimx / 2) + " 0 1.5",
                positionW=str(-(platformDimx - 1) / 2. + x) + " " +
                str(y + height) + " 1.5")
            platform.addSpring(
                positionB="-" + str(platformDimx / 2) + " 0 -1.5",
                positionW=str(-(platformDimx - 1) / 2. + x) + " " +
                str(y + height) + " -1.5")
            platform.addSpring(positionB=str(platformDimx / 2) + " 0 -1.5",
                               positionW=str((platformDimx - 1) / 2. + x) +
                               " " + str(y + height) + " -1.5")
            platform.addSpring(positionB=str(platformDimx / 2) + " 0 1.5",
                               positionW=str((platformDimx - 1) / 2. + x) +
                               " " + str(y + height) + " 1.5")

export(root, "../dominosPlatforms.xml")
Esempio n. 9
0
import xml.etree.ElementTree as ET
from modules.box import Box
from modules.exportXML import export

root = ET.Element('root')

# Fixed bodies
x = 0
for i in range(2):
    if i == 1: x += 18
    Box(root,
        name='box' + str(i),
        position=str(x) + " 0.0 0.0",
        dim='8 2 8',
        pinned="true")

# Pile bodies
y = 0
x = 4
for i in range(8):
    y += 2.5
    if i == 4:
        x += 10
        y = 2.5
    Box(root,
        name='box' + str(i),
        position=str(x) + " " + str(y) + " 0.0",
        dim='8 2 8')

export(root, "../cycle.xml")
Esempio n. 10
0
# Plane
plane = ET.SubElement(root, 'body')
plane.set('type','plane')
plane.set('p','0 0 0')
plane.set('n','0. 1. 0.0')
plane.set('name','plane')

Box(root, name='wall1', position="0. 1 -50", orientation="0 0 1 0", dim="100 10 1", pinned="true")
Box(root, name='wall2', position="0. 1 50", orientation="0 0 1 0", dim="100 10 1", pinned="true")
Box(root, name='wall3', position="-50 1 0.", orientation="0 0 1 0", dim="1 10 100", pinned="true")
Box(root, name='wall4', position="50 1 0.", orientation="0 0 1 0", dim="1 10 100", pinned="true")

# Default Box
Box(root, name='box1', position="0 100 0", orientation="0 0 1 0", dim="1.8 1.8 1.8")
Box(root, name='box2', position="0 100 0", orientation="0 0 1 0", dim="1.8 1.8 1.8")
Box(root, name='box3', position="0 100 0", orientation="0 0 1 0", dim="1.8 1.8 1.8")
# Sphere(root, name='sphere', position="0 100 0", orientation="0 0 1 0", radius="1")
# Mesh(root, name='venus', obj="data/scaletorso10.obj", st="data/torso_flux.sph", position="0 100 0", orientation="0 0 1 0", scale="0.1")

# Funnel
composite = Composite(root, obj="data/funnel.obj", scale="1", name="funnel", position="0. 50. 0.", velocity="0. 0. 0.", color="0.5 0. 0. 1.", omega="0 0 -0.05")
composite.addBox(name='wall1', position="0. -0.5 -13.5", orientation="-1 0 0 1.07", dim='48 22 1')
composite.addBox(name='wall3', position="0. -0.5 13.5", orientation="1 0 0 1.07", dim='48 22 1')
composite.addBox(name='wall2', position="-13.5 -0.5 0.", orientation="0 0 1 1.07", dim='1 22 48')
composite.addBox(name='wall4', position="13.5 -0.5 0.", orientation="0 0 -1 1.07", dim='1 22 48')

# Stand(root, body2="funnel", dimBody2="26 20 26", ybody2="74", width="40", height="100", pinned="true")
Stand(root, body2="funnel", dimBody2="46 10 46", ybody2="74", width="40", height="100", pinned="true")

export(root, "../funnel.xml")
Esempio n. 11
0
import xml.etree.ElementTree as ET
from modules.box import Box
from modules.exportXML import export

root = ET.Element('root')

# Spring Default
body = Box(root, name='body1', position="0.0 0.0 0.0", dim='2 2 2')
body.addSpring("0. 0. 0.", k="10")

# Spring World
body = Box(root, name='body2', position="4.0 0.0 0.0", dim='2 2 2')
body.addSpring("0. 0. 0.", positionW="4. 10. 0.", k="10")

# Spring body body
body = Box(root, name='body3', position="8.0 0.0 0.0", dim='2 2 2')
body.addSpring("0. 0. 0.", k="10")
boat = Box(root, name='body4', position="8.0 -5.0 0.0", dim='2 2 2')
boat.addSpring("0. 0. 0.", positionB2="0. 0. 0.", k="10", body2="body3")

export(root, "../springsTest.xml")
Esempio n. 12
0
colors = [
    "0.3 0.3 0.3 1.", "0.2 0.5 0.2 1.", "0.3 0.3 0.5 1.", "0.7 0.7 0.5 1."
]
for i in range(8):
    y = str(i * 2.5 + 2.5)
    composite.addBox(name='floor' + str(i),
                     position=" 0. " + y + " 0.",
                     dim='10.2 0.2 4')
    # Books
    if (i > 0):
        for j in range(12):
            yb = str(float(y) - 1.39)
            shift = 4.8 if (i % 2 == 0) else 0.6
            x = str(-45 + shift + 0.42 * j)
            orientation = "0 0 -1 0.3" if (i % 2 == 0) else "0 0 1 0.3"
            orientation = "0 0 -1 0" if (i % 3 == 0) else orientation
            Box(root,
                name='book' + str(j),
                position=str(x) + " " + str(yb) + " " + str(z),
                dim="0.4 2 1.5",
                color=colors[random.randint(0, 3)],
                orientation=orientation,
                friction="0.3",
                density="1")

# Box(root, name='bookAlone1', position="-35.75 "+yb+" 1.", dim="0.15 2 1.5", color=colors[random.randint(0,3)], friction="0.3", density="0.1")
# Box(root, name='bookAlone2', position="-35.9 "+yb+" 1.", dim="0.1 2 1.5", color=colors[random.randint(0,3)], friction="0.3", density="0.1")

export(root, "../chariotvenus.xml")
Esempio n. 13
0
                             ls=ls,
                             body2="perle" + str(i - 1),
                             positionB2="0.05 3.5 0")
        elif i > 0:
            sphere.addSpring(positionB="-0.05 0 0",
                             k="300.",
                             d="100",
                             ls=ls,
                             body2="perle" + str(i - 1),
                             positionB2="0.05 0 0")
    else:
        sphere = Composite(root,
                           name="perle" + str(i),
                           obj="data/pendant.obj",
                           position=str(x) + " " + str(y) + " " + str(z),
                           density="1",
                           friction="0.6")
        sphere.addSphere(position="0. 0. 0.", radius="1.6", density="1")
        sphere.addBox(position="0. -4.5 0.",
                      dim="5 5 1.5",
                      orientation="0 0 -1 0.77",
                      density="1")
        sphere.addSpring(positionB="-0.05 3.5 0",
                         k="300.",
                         d="100",
                         ls=ls,
                         body2="perle" + str(i - 1),
                         positionB2="0.05 0. 0")

export(root, "../venus.xml")