Package jinngine.geometry.contact

Examples of jinngine.geometry.contact.SupportMapContactGenerator


    // boxes by changing the transform of the bodies)
    final Body body1 = new Body("box1", box1);   
    final Body body2 = new Body("box2", box2);
       
    // contact generator
    ContactGenerator g = new SupportMapContactGenerator(box1,box1,box2,box2);
   

    /*
     * Test 1, displace along positive y-axis
     */
   
    // displace box2
    body2.setPosition(0, 1.5, 0);
   
    // run contact point generation
    g.run();
   
    // extract contact points
    result.clear();
    Iterator<ContactPoint> i = g.getContacts();
    while (i.hasNext()) {
      ContactPoint cp = i.next();
      System.out.println(cp.point);
      System.out.println("dist="+cp.distance);
      result.add(new Vector3(cp.point));
    }
   
    // expected contact points, in counter clock-wise order
    expect.clear();
    expect.add(new Vector3(0.5,0.75,0.5));
    expect.add(new Vector3(-0.5,0.75,0.5));
    expect.add(new Vector3(-0.5,0.75,-0.5));
    expect.add(new Vector3(0.5,0.75,-0.5));

    // check
    assertTrue(verifyPolygon(expect, result));

 
    /*
     * Test 2, displace along negative y-axis
     */
   
    // displace box2
    body2.setPosition(0, -1.5, 0);
   
    // run contact point generation
    g.run();
   
    // extract contact points
    result.clear();
    i = g.getContacts();
    while (i.hasNext()) {
      ContactPoint cp = i.next();
      System.out.println(cp.point);
      System.out.println("dist="+cp.distance);
      result.add(new Vector3(cp.point));
    }
   
    // expected contact points, in counter clock-wise order
    expect.clear();
    expect.add(new Vector3( 0.5,-0.75,-0.5));
    expect.add(new Vector3(-0.5,-0.75,-0.5));
    expect.add(new Vector3(-0.5,-0.75, 0.5));
    expect.add(new Vector3( 0.5,-0.75, 0.5));

    // check
    assertTrue(verifyPolygon(expect, result));

 
    /*
     * Test 3, displace along positive x-axis
     */
   
    // displace box2
    body2.setPosition(1.5, 0, 0);
   
    // run contact point generation
    g.run();
   
    // extract contact points
    result.clear();
    i = g.getContacts();
    while (i.hasNext()) {
      ContactPoint cp = i.next();
      System.out.println(cp.point);
      System.out.println("dist="+cp.distance);
      result.add(new Vector3(cp.point));
View Full Code Here


    geometryClassifiers.add(new ContactGeneratorClassifier() {
      @Override
      public final ContactGenerator getGenerator(Geometry a,
          Geometry b) {
        if ( a instanceof SupportMap3 && b instanceof SupportMap3) {
          return new SupportMapContactGenerator((SupportMap3)a, a,  (SupportMap3)b, b);
//          return new BulletNativeContactGenerator(a,b);
        }
        //not recognised
        return null
      }
View Full Code Here

TOP

Related Classes of jinngine.geometry.contact.SupportMapContactGenerator

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.