Package com.bulletphysics.linearmath

Examples of com.bulletphysics.linearmath.Transform


        gewichtAgent.getRigidBody(),
        new Vector3f (5,0,0),
        new Vector3f (0,0,0));
     
   
    Transform localA = new Transform();
    localA.setIdentity();
    Transform localB = new Transform();
    localB.setIdentity();
   
    localA.origin.set(new Vector3f (0,0,0));
    localB.origin.set(new Vector3f (0,0,0));
    Generic6DofConstraint senkrecht = new Generic6DofConstraint(
        groundAgent.getRigidBody(),
        gewichtAgent.getRigidBody(),
        localA,
        localB,
        true);
   
    senkrecht.setLimit(0, -.9f, .9f);
    senkrecht.setLimit(1, 7, 100);
    senkrecht.setLimit(2, -.9f, .9f);

    env.getDynamicsWorld().addConstraint(gelenk1, true);
    env.getDynamicsWorld().addConstraint(gelenk2, true);
    env.getDynamicsWorld().addConstraint(gewichtBefestigung, true);
    env.getDynamicsWorld().addConstraint(senkrecht, true);
   
    env.addAgent(groundAgent);
    env.addAgent(armAgent1);
    env.addAgent(armAgent2);
    env.addAgent(gewichtAgent);
   
   
   
   
    ///////////////////////////////////////
    ////////////PENDEL
    ///////////////////////////////////////
    BoxShape pendelShape = new BoxShape (new Vector3f (.5f,10,.5f));
    env.getCollisionShapes().add(pendelShape);
   
    ConstraintDemoAgent pendelAgent = new ConstraintDemoAgent(
        idCounter++,
        env,
        env.getCollisionShapes().getQuick(2),
        new Vector3f (10,25,10),
        null,
        .5f);
   
    ConstraintDemoAgent pendelKugelAgent = new ConstraintDemoAgent(
        idCounter++,
        env,
        env.getCollisionShapes().getQuick(1),
        new Vector3f (10,5,10),
        null,
        5f);
   
    Point2PointConstraint pendelAufhaengung = new Point2PointConstraint(
        pendelAgent.getRigidBody(),
        new Vector3f (0,11,0));
   
    Point2PointConstraint pendelKugelBefestigung = new Point2PointConstraint(
        pendelAgent.getRigidBody(),
        pendelKugelAgent.getRigidBody(),
        new Vector3f (0,-10,0),
        new Vector3f (0,0,0));
   
    pendelKugelAgent.getRigidBody().setActivationState(CollisionObject.DISABLE_DEACTIVATION);
    pendelAgent.getRigidBody().setActivationState(CollisionObject.DISABLE_DEACTIVATION);
   
    env.addAgent(pendelAgent);
    env.addAgent(pendelKugelAgent);
    env.getDynamicsWorld().addConstraint(pendelAufhaengung, true);
    env.getDynamicsWorld().addConstraint(pendelKugelBefestigung, true);
   
   
   
    //////////////////////////////////
    ////////////// DOPSBALL
    //////////////////////////////////
   
    ConstraintDemoAgent dopsBall = new ConstraintDemoAgent(
        idCounter++,
        env,
        env.getCollisionShapes().getQuick(1),
        new Vector3f (-20,40,20),
        null,
        1);
   
    dopsBall.getRigidBody().setActivationState(CollisionObject.DISABLE_DEACTIVATION);
    dopsBall.getRigidBody().setRestitution(.8f);
    groundAgent.getRigidBody().setRestitution(.8f);
   
   
    localA.setIdentity();
    localB.setIdentity();
    localA.origin.set (new Vector3f (-20,0,20));
    localB.origin.set (new Vector3f (0,0,0));
   
    Generic6DofConstraint dopsBallConstraint = new Generic6DofConstraint(
        groundAgent.getRigidBody(),
        dopsBall.getRigidBody(),
        localA,
        localB,
        true);
   
    dopsBallConstraint.setLimit(1, 1, 100);
   
    env.addAgent(dopsBall);
    env.getDynamicsWorld().addConstraint(dopsBallConstraint, false);

   
   
   
    ////////////////////////////////////
    ///// SCHWEBENDER BALL
    ////////////////////////////////
   
    ConstraintDemoAgent schwebenderBallAgent = new ConstraintDemoAgent(
        idCounter++,
        env,
        env.getCollisionShapes().getQuick(1),
        new Vector3f (0,10,30),
        null,
        1);
   
    schwebenderBallAgent.getRigidBody().setActivationState(CollisionObject.DISABLE_DEACTIVATION);
    schwebenderBallAgent.getRigidBody().setRestitution(1);
    schwebenderBallAgent.getRigidBody().setFriction(0);
    schwebenderBallAgent.getRigidBody().setGravity(new Vector3f(0,0,0));
   
    localA.setIdentity();
    localB.setIdentity();
    localA.origin.set(new Vector3f (0,10,30));
    localB.origin.set(new Vector3f (0,0,0));
   
    Generic6DofConstraint schwebenderBallAgentConstraint = new Generic6DofConstraint(
        groundAgent.getRigidBody(),
View Full Code Here


   */
  @Override
  public LinkedList<Double> sense(EvolvableBoxAgent3DEnvironment env,
      EvolvableBoxAgent3D agent) {
   
    Transform worldTransform = new Transform();   
    agent.getAgentCore().getRigidBody().getMotionState().getWorldTransform(worldTransform)
   
    Quat4f rot = new Quat4f();   
   
    worldTransform.getRotation(rot);
   
    //Vector3f v = new Vector3f(1,1,1);
    Vector3f v = new Vector3f(1,0,0);
    v.normalize();
   
View Full Code Here

    if (!chessSurface) {
      System.out.println("Simple ground - no chess surface.");
      BoxShape groundShape = new BoxShape(new Vector3f(10000, 10, 10000));

      // Create transform to store ground's location.
      Transform transform = new Transform();
      transform.setIdentity();
      transform.origin.set(new Vector3f(0, -10, 0));

      // Create new MotionState to keep track of object.
      DefaultMotionState motionState = new DefaultMotionState(transform);
      Vector3f localInertia = new Vector3f(0, 0, 0);
      RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(0,
          motionState, groundShape, localInertia);

      // Create the rigid body and add it to the dynamicsworld.
      RigidBody body = new RigidBody(rbInfo);
      getDynamicsWorld().addRigidBody(body);

      // Set friction.
      //body.setFriction(1);

      // Store locally.
      this.ground = body;

    }

    else {
      System.out.println("Using chess surface ground");
      BoxShape bShape = new BoxShape(new Vector3f(20, 10, 20));

      for (int i = 0; i < 20; i++) {
        for (int j = 0; j < 21; j++) {
          // Create transform to store ground's location.
          Transform transform = new Transform();
          transform.setIdentity();
          float x = -10 * 40 + i * 40;
          float z = -10 * 40 + j * 40;
          transform.origin.set(new Vector3f(x, -10, z));

          // Create new MotionState to keep track of object.
View Full Code Here

    if (mass != 0) {
      isDynamic = true;
    }
   
    // Create agent's transform.
    transform = new Transform();
    // Set agent's transform to standard values.
    transform.setIdentity();
    // Move agent to its starting position.
    transform.origin.set(startPosition);
   
View Full Code Here

    return this.position;
  }
   
    public Vector3f getCenterOfMassPositionForFitness() {
      Vector3f out = null;
      Transform t = new Transform();
      this.getRigidBody().getCenterOfMassTransform(t);
      out = t.origin;
      return out;
    }
View Full Code Here

        ));
   
    // Create rigidbody in physicsworld.
    BoxShape box = new BoxShape(size);
    Vector3f localInertia = new Vector3f (0,0,0);
    Transform transform = new Transform();
    transform.setIdentity();
    transform.origin.set(this.position);   
    DefaultMotionState motionState = new DefaultMotionState(transform);
    box.calculateLocalInertia(mass, localInertia);
    RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
        this.mass, motionState, box, localInertia);
    RigidBody body = new RigidBody(rbInfo);
    this.getDynamicsWorld().addRigidBody(body);
    this.body = body;
   
   
   
   
    //// Add joint / constraint.
    // Point of attachment in predecessor.
    Transform frameInPredecessor = new Transform();
    frameInPredecessor.setIdentity();
    frameInPredecessor.origin.add(new Vector3f (
        positionOnPredecessor.x * predecessor.getSize().x,
        positionOnPredecessor.y * predecessor.getSize().y,
        positionOnPredecessor.z * predecessor.getSize().z
        ));
    // Local point of attachment.
    Transform frameInThis = new Transform();
    frameInThis.setIdentity();
    frameInThis.origin.add(new Vector3f (
        -positionOnPredecessor.x * this.getSize().x,
        -positionOnPredecessor.y * this.getSize().y,
        -positionOnPredecessor.z * this.getSize().z
        ));
 
View Full Code Here

        BoxShape shape = new BoxShape(halfExtents);
        // fix local inertia
        Vector3f localInertia = new Vector3f(0, 0, 0);
        shape.calculateLocalInertia(mass, localInertia);
        // set initial transform based on box
        Transform startTransform = new Transform();
        startTransform.setIdentity();
        startTransform.origin.set(box.getTranslation().getXf(), box.getTranslation().getYf(), box.getTranslation().getZf());
        MotionStateBind motionState = new MotionStateBind(startTransform);
        motionState.setSpatial(box);
//         create the RigidBody for our box
        RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass,
View Full Code Here

    public void addFloor(Box floor) {
        float mass = 0f; // make it static
        // create the CollisionShape
        CollisionShape groundShape = new BoxShape(new Vector3f((float) floor.getXExtent(), (float) floor.getYExtent(), (float) floor.getZExtent()));
        // set initial transform based on floor
        Transform groundTransform = new Transform();
        groundTransform.setIdentity();
        groundTransform.origin.set(new Vector3f(floor.getTranslation().getXf(), floor.getTranslation().getYf(), floor.getTranslation().getZf()));
        Vector3f localInertia = new Vector3f(0, 0, 0);
        // let's use DefaultMotionState b/c the floor won't need any movement
        // updates
        DefaultMotionState motionState = new DefaultMotionState(groundTransform);
View Full Code Here

      }

      return;
    }

    Transform orgtrans0 = body0.getWorldTransform(Stack.alloc(Transform.class));
    Transform orgtrans1 = body1.getWorldTransform(Stack.alloc(Transform.class));

    PairSet pairset = tmpPairset;
    pairset.clear();

    gimpact_vs_gimpact_find_pairs(orgtrans0, orgtrans1, shape0, shape1, pairset);

    if (pairset.size() == 0) {
      return;
    }
    if (shape0.getGImpactShapeType() == ShapeType.TRIMESH_SHAPE_PART &&
        shape1.getGImpactShapeType() == ShapeType.TRIMESH_SHAPE_PART) {
     
      GImpactMeshShapePart shapepart0 = (GImpactMeshShapePart) shape0;
      GImpactMeshShapePart shapepart1 = (GImpactMeshShapePart) shape1;
     
      //specialized function
      //#ifdef BULLET_TRIANGLE_COLLISION
      //collide_gjk_triangles(body0,body1,shapepart0,shapepart1,&pairset[0].m_index1,pairset.size());
      //#else
      collide_sat_triangles(body0, body1, shapepart0, shapepart1, pairset, pairset.size());
      //#endif

      return;
    }

    // general function

    shape0.lockChildShapes();
    shape1.lockChildShapes();

    GIM_ShapeRetriever retriever0 = new GIM_ShapeRetriever(shape0);
    GIM_ShapeRetriever retriever1 = new GIM_ShapeRetriever(shape1);

    boolean child_has_transform0 = shape0.childrenHasTransform();
    boolean child_has_transform1 = shape1.childrenHasTransform();

    Transform tmpTrans = Stack.alloc(Transform.class);

    int i = pairset.size();
    while ((i--) != 0) {
      Pair pair = pairset.get(i);
      triface0 = pair.index1;
      triface1 = pair.index2;
      CollisionShape colshape0 = retriever0.getChildShape(triface0);
      CollisionShape colshape1 = retriever1.getChildShape(triface1);

      if (child_has_transform0) {
        tmpTrans.mul(orgtrans0, shape0.getChildTransform(triface0));
        body0.setWorldTransform(tmpTrans);
      }

      if (child_has_transform1) {
        tmpTrans.mul(orgtrans1, shape1.getChildTransform(triface1));
        body1.setWorldTransform(tmpTrans);
      }

      // collide two convex shapes
      convex_vs_convex_collision(body0, body1, colshape0, colshape1);
View Full Code Here

    // Setup a big ground box
    {
      CollisionShape groundShape = new BoxShape(new Vector3f(200f, 10f, 200f));
      // TODO
      //m_collisionShapes.push_back(groundShape);
      Transform groundTransform = new Transform();
      groundTransform.setIdentity();
      groundTransform.origin.set(0f, -10f, 0f);
      localCreateRigidBody(0f, groundTransform, groundShape);
    }

    // Spawn one TestRig
View Full Code Here

TOP

Related Classes of com.bulletphysics.linearmath.Transform

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.