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")
composite.addBox(name='crane21', dim="0.5 10 0.5", position="0 2.5 -10") composite.addBox(name='crane22', dim="1 0.5 16", position="-2 5.5 -6") composite.addBox(name='stand3', dim="12 0.5 0.5", position="-4 5.5 -10") composite.addBox(name='cockpit1', dim="1 1 1", position="2 5.5 -10") composite.addBox(name='cockpit2', dim="1 1 1", position="-10 5.5 -10") if (k == 0): mag = Box(root, name='magnet', dim="1 0.5 1", position=str(disp - 2) + " 4 -6", magnetic="true", color="0. 0. 0. 1.") mag.addSpring(positionB="-0.4 0 0.4", positionW=str(disp - 2.4) + " 5.5 -5.6", controllable="true", k="100", d="1") mag.addSpring(positionB="0.4 0. 0.4", positionW=str(disp - 1.6) + " 5.5 -5.6", controllable="true", k="100", d="1") mag.addSpring(positionB="-0.4 0. -0.4", positionW=str(disp - 2.4) + " 5.5 -6.4", controllable="true", k="100", d="1") mag.addSpring(positionB="0.4 0. -0.4", positionW=str(disp - 1.6) + " 5.5 -6.4", controllable="true",
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")