Package org.ode4j.ode

Examples of org.ode4j.ode.DBody


//    bodies = new DBody[1];
//    geoms = new DGeom[1];
//    masses = new DMass[1];
   
    DMass mass = OdeHelper.createMass();
    DBody body = OdeHelper.createBody(env.getWorld());
    mass.setBox(1, 1, 1, 3);
    body.setMass(mass);
    body.setPosition(pos.x, pos.y, pos.z);
    DGeom geom = OdeHelper.createBox(0.5, 0.5, 3);
    geom.setBody(body);
    env.getSpace().add(geom);
    body.setAngularDamping(.001f);
    body.setLinearDamping(.001f);
    bodies.add(body);
    geoms.add(geom);
    masses.add(mass);
//    masses[0] = OdeHelper.createMass();
//    bodies[0] = OdeHelper.createBody(env.getWorld());
View Full Code Here


//    bodies = new DBody[1];
//    geoms = new DGeom[1];
//    masses = new DMass[1];
   
    DMass mass = OdeHelper.createMass();
    DBody body = OdeHelper.createBody(env.getWorld());
    mass.setBox(1, 1, 1, 3);
    body.setMass(mass);
    body.setPosition(pos.x, pos.y, pos.z);
    DGeom geom = OdeHelper.createBox(1, 1, 1);
    geom.setBody(body);
    env.getSpace().add(geom);
    body.setAngularDamping(.001f);
    body.setLinearDamping(.001f);
    bodies.add(body);
    geoms.add(geom);
    masses.add(mass);
//    masses[0] = OdeHelper.createMass();
//    bodies[0] = OdeHelper.createBody(env.getWorld());
View Full Code Here

 
  public PuckAgent(int id, AbstractEnvironmentODE3D<?> env,
      ParCollection params, DVector3 position) {
    super(id, env, params);
    DMass mass = OdeHelper.createMass();
    DBody body = OdeHelper.createBody(env.getWorld());
    body.setPosition(position);
//    DVector3 size = new DVector3(1,1,1);
//    mass.setBox(1, size.get0(), size.get1(), size.get2());
    mass.setCylinder(1, 1, 1, .5);
    body.setMass(mass);
//    geom = OdeHelper.createBox(size.get0(), size.get1(), size.get2());
    DGeom geom = OdeHelper.createCylinder(null, 1, .5);
    geom.setBody(body);
    env.getSpace().add(geom);
   
View Full Code Here

    joints = new DHingeJoint[numberOfModules];

    // create bodies and geoms for the modules
    {
      // create left body
      DBody body = OdeHelper.createBody(env.getWorld());
      body.setPosition(0, -L / 4, H / 2);
      mass.setBoxTotal(MASS / 2, W, L / 2, H);
      body.setMass(mass);
      DGeom geom = OdeHelper.createBox(env.getSpace(), W, L / 2, H);
      geom.setBody(body);
      bodies.add(body);
      geoms.add(geom);

      // create central bodies
      for (int i = 1; i < numberOfModules; i++) {
        body = OdeHelper.createBody(env.getWorld());
        body.setPosition(0, -L * (i), H / 2);
        mass.setBoxTotal(MASS, W, L / 2, H);
        body.setMass(mass);

        geom = OdeHelper.createBox(env.getSpace(), W, L / 2, H);
        DGeom geom2 = OdeHelper.createBox(
            env.getSpace(), W, L / 2, H);

        geom.setBody(body);
        geom2.setBody(body);

        geom.setOffsetPosition(0, L / 4, 0);
        geom2.setOffsetPosition(0, -L / 4, 0);
        bodies.add(body);
        geoms.add(geom);
        geoms.add(geom2);
      }

      // create right body
      body = OdeHelper.createBody(env.getWorld());
      body.setPosition(0,
          (-(numberOfModules) * L + L / 4), H / 2);
      mass.setBoxTotal(MASS / 2, W, L / 2, H);
      body.setMass(mass);
      geom = OdeHelper.createBox(
          env.getSpace(), W, L / 2, H);
      geom.setBody(body);
      bodies.add(body);
      geoms.add(geom);
View Full Code Here

  public BumperAgent(int id, AbstractEnvironmentODE3D<?> env,
      ParCollection params, DVector3 position) {
    super(id, env, params);
   
    DMass mass = OdeHelper.createMass();
    DBody body = OdeHelper.createBody(env.getWorld());
    body.setPosition(position);
    DVector3 size = new DVector3(1,1,1);
    mass.setBox(1, size.get0(), size.get1(), size.get2());
    body.setMass(mass);
    DGeom geom = OdeHelper.createBox(size.get0(), size.get1(), size.get2());
    geom.setBody(body);
    env.getSpace().add(geom);
   
    bodies.add(body);
View Full Code Here

     */
    private static final long serialVersionUID = -4099834334274853259L;

    public ClothEnv(int id, ParCollection params) {
    super(id, params);
    DBody blockbody = OdeHelper.createBody(getWorld());
    DGeom blockgeom = OdeHelper.createSphere(1);
    DMass blockmass = OdeHelper.createMass();
    blockbody.setPosition(0, 0, 1.1);
    blockmass.setSphere(1, 1);
    blockgeom.setBody(blockbody);
    blockbody.setMass(blockmass);
    getSpace().add(blockgeom);
   
  }
View Full Code Here

   */
  public ObstacleAgent(int id, ClothEnv env, ParCollection params) {
    super(id, env, params);
   
    DGeom geom = OdeHelper.createSphere(env.getSpace(), 1);
    DBody body = OdeHelper.createBody(env.getWorld());
    body.setPosition(0, 0, 1);
    DMass mass = OdeHelper.createMass();
    mass.setSphere(2, 2);
    geom.setBody(body);
    body.setKinematic();
   
    bodies.add(body);
    geoms.add(geom);
    masses.add(mass);
  }
View Full Code Here

        newPos = new DVector3(
            prePos.get0() + relPos.get0()*size.get0()/2,
            prePos.get1() + relPos.get1()*size.get1()/2,
            prePos.get2() + relPos.get2()*size.get2()/2);
      }
      DBody b = OdeHelper.createBody(env.getWorld());
      bp.setBody(b);
      DGeom g = OdeHelper.createBox(
          env.getSpace(),
          size.get0(),
          size.get1(),
          size.get2());
      b.setPosition(newPos);
      g.setBody(b);
      DMass mass = OdeHelper.createMass();
      mass.setBox(
          1,
          bp.getSize().get0(),
          bp.getSize().get1(),
          bp.getSize().get2());
      b.setMass(mass);
     
      lowestHeight = Math.min(lowestHeight,b.getPosition().get2()-size.get2()/2);     
      bodies.add(b);
      masses.add(mass);
      geoms.add(g);
    }
   
    // Move close to ground
    Iterator<DBody> itb = bodies.iterator();
    while (itb.hasNext()) {
      DBody b = itb.next();
      DVector3 newPos = b.getPosition().clone();
      newPos.set2(b.getPosition().get2()-lowestHeight*.99);
      b.setPosition(newPos);
      System.out.println(b.getPosition());
    }
   
   
    System.out.println(genome);
   
 
View Full Code Here

    assert (o2 != null);   
    ////////////////////////////////////////////////////
    ////////////////////////////////////////////////////
    // Do not let bodies collide which are somehow connected by joints!
    // This causes very bad instability!!!!
    DBody b1 = o1.getBody();
    DBody b2 = o2.getBody();
    if ((b1 != null) && (b2 != null) && OdeHelper.areConnectedExcluding(b1, b2, DContactJoint.class)){
      return;
    }
    ////////////////////////////////////////////////////
    ////////////////////////////////////////////////////
View Full Code Here

TOP

Related Classes of org.ode4j.ode.DBody

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.