Package jinngine.collision

Examples of jinngine.collision.SAP2


  private final Scene scene;
 
  public BasicExample() {
   
    // start jinngine
    scene = new DefaultScene(new SAP2(), new NonsmoothNonlinearConjugateGradient(44), new DisabledDeactivationPolicy());
    scene.setTimestep(0.1);
   
    // add boxes to bound the world
    Body floor = new Body("floor", new Box(1500,20,1500));
    floor.setPosition(new Vector3(0,-30,0));
View Full Code Here


  private final Scene scene;
 
  public CapsuleExample() {
   
    // start jinngine
    scene = new DefaultScene(new SAP2(), new NonsmoothNonlinearConjugateGradient(44), new DisabledDeactivationPolicy());
    scene.setTimestep(0.1);
   
    // add boxes to bound the world
    Body floor = new Body("floor", new Box(1500,20,1500));
    floor.setPosition(new Vector3(0,-30,0));
View Full Code Here

  private final Scene scene;
 
  public RagdollExample() {
   
    // start jinngine
    scene = new DefaultScene(new SAP2(), new NonsmoothNonlinearConjugateGradient(75), new DefaultDeactivationPolicy());
    scene.setTimestep(0.1);
   
    // add boxes to bound the world
    Body floor = new Body("floor", new Box(1500,20,1500));
    floor.setPosition(new Vector3(0,-30,0));
View Full Code Here

      public void separation(Pair<Geometry> pair) {
      }
    };

    //create the detector with handler
    BroadphaseCollisionDetection sweep = new SAP2();
    sweep.addHandler(handler);

    //add both boxes
    sweep.add(box1);
    sweep.add(box2);
   
    // expect an overlap
    sweep.run();
    assertTrue( sweep.getOverlappingPairs().contains(new Pair<Geometry>(box1,box2)));
   
    // remove box2
    sweep.remove(box2);
   
    // expect no overlaps
    sweep.run();
    assertTrue( sweep.getOverlappingPairs().size() == 0);

    // add box2 again
    sweep.add(box2);
   
    // expect an overlap
    sweep.run();
    assertTrue( sweep.getOverlappingPairs().contains(new Pair<Geometry>(box1,box2)));

    //move box2 1.0 along z axis
    b2.setPosition(0,0,1.0);
   
    // expect an overlap
    sweep.run();
    assertTrue( sweep.getOverlappingPairs().contains(new Pair<Geometry>(box1,box2)));

    // move box2 by 1.0 + twice the envelope + epsilon
    // this will make bounding boxes only just separated
    b2.setPosition(0,0,1.0+2*env+epsilon);
   
    // expect no overlap
    sweep.run();
    assertTrue( !sweep.getOverlappingPairs().contains(new Pair<Geometry>(box1,box2)) );

    // move box2 by 1 + 2 env - epsilon
    // such that boxes will only just overlap by epsilon
    b2.setPosition(new Vector3(0,0,1.0+2*env-epsilon));

    // expect an overlap
    sweep.run();
    assertTrue( sweep.getOverlappingPairs().contains(new Pair<Geometry>(box1,box2)));
  }
View Full Code Here

TOP

Related Classes of jinngine.collision.SAP2

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.