private static void nearCallback (Object data, DGeom o1, DGeom o2) { // exit without doing anything if the two bodies are connected by a joint DBody b1 = o1.getBody(); DBody b2 = o2.getBody(); DContactBuffer cb = new DContactBuffer(1); DContact contact = cb.get(0); contact.surface.mode = 0; contact.surface.mu = OdeConstants.dInfinity; if (0!=OdeHelper.collide (o1,o2,1,cb.getGeomBuffer()/* sizeof(dContactGeom) */ )) { DJoint c = OdeHelper.createContactJoint (world,contactgroup,contact); c.attach (b1,b2); } }
static void nearCallback (Object data, DGeom o1, DGeom o2) { // exit without doing anything if the two bodies are connected by a joint DBody b1 = dGeomGetBody(o1); DBody b2 = dGeomGetBody(o2); DContactBuffer cb = new DContactBuffer(1); DContact contact = cb.get(0); contact.surface.mode = 0; contact.surface.mu = dInfinity; if (0!=dCollide (o1,o2,1,cb.getGeomBuffer()/* sizeof(dContactGeom) */ )) { DJoint c = dJointCreateContact (world,contactgroup,contact); dJointAttach (c,b1,b2); } }
private void nearCallback (Object data, DGeom o1, DGeom o2) { int i,n; final int N = 10; //dContact contact[N]; DContactBuffer contacts = new DContactBuffer(N); n = OdeHelper.collide (o1,o2,N,contacts.getGeomBuffer());//,sizeof (dContact) ); if (n > 0) { for (i=0; i<n; i++) { DContact contact = contacts.get(i); contact.surface.mode = (dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1); contact.surface.mu = 0.1; contact.surface.slip1 = 0.02; contact.surface.slip2 = 0.02; contact.surface.soft_erp = 0.1; contact.surface.soft_cfm = 0.0001; DJoint c = OdeHelper.createContactJoint (world,contactgroup,contact); c.attach (contact.geom.g1.getBody(), contact.geom.g2.getBody() ); } } }
private void nearCallback (Object data, DGeom o1, DGeom o2) { // exit without doing anything if the two bodies are connected by a joint DBody b1 = o1.getBody(); DBody b2 = o2.getBody(); if (b1!=null && b2!=null && OdeHelper.areConnected (b1,b2)) return; // @@@ it's still more convenient to use the C interface here. DContactBuffer contacts = new DContactBuffer(1); DContact contact = contacts.get(0); contact.surface.mode = 0; contact.surface.mu = Double.POSITIVE_INFINITY;//TODO dInfinity; if (OdeHelper.collide (o1,o2,1,contacts.getGeomBuffer())!=0) {//&contact.geom,sizeof(dContactGeom))) { DJoint c = OdeHelper.createContactJoint (world,contactgroup,contact); c.attach(b1, b2); } }
private static void nearCallback (Object data, DGeom o1, DGeom o2) { // exit without doing anything if the two bodies are connected by a joint DBody b1 = dGeomGetBody(o1); DBody b2 = dGeomGetBody(o2); if (b1!=null && b2!=null && dAreConnected (b1,b2)) return; // @@@ it's still more convenient to use the C interface here. DContactBuffer contacts = new DContactBuffer(1); DContact contact = contacts.get(0); contact.surface.mode = 0; contact.surface.mu = dInfinity; if (dCollide (o1,o2,1,contacts.getGeomBuffer())!=0) {//&contact.geom,sizeof(dContactGeom))) { DJoint c = dJointCreateContact (world,contactgroup,contact); dJointAttach (c,b1,b2); } }
private void nearCallback (Object data, DGeom o1, DGeom o2) { int i; DBody b1 = o1.getBody(); DBody b2 = o2.getBody(); if (b1==null && b2==null) { return; } DContactBuffer contacts = new DContactBuffer(3); for (DContact contact: contacts) { contact.surface.mode = dContactApprox1 | dContactRolling; contact.surface.mu = mu; contact.surface.rho = rho; } int numc = OdeHelper.collide (o1,o2,3,contacts.getGeomBuffer()); if (numc != 0) { for (i=0; i<numc; i++) { DJoint c = OdeHelper.createContactJoint(world,contactgroup,contacts.get(i)); c.attach (b1,b2); } } }
/** * this is called by dSpaceCollide when two objects in space are * potentially colliding. */ private void nearCallback (Object data, DGeom o1, DGeom o2) { /* exit without doing anything if the two bodies are connected by a joint */ DBody b1,b2; //dContact contact; DContactBuffer contacts = new DContactBuffer(1); DContact contact = contacts.get(0); b1 = o1.getBody(); b2 = o2.getBody(); // if (b1!=null && b2!=null && dAreConnected (b1,b2)) return; contact.surface.mode = 0; contact.surface.mu = 0.1; contact.surface.mu2 = 0; if (0!=OdeHelper.collide (o1,o2,1,contacts.getGeomBuffer())) {//&contact.geom,sizeof(dContactGeom))) { DJoint c = OdeHelper.createContactJoint (world,contactgroup,contact); c.attach (b1,b2); } }
/** * this is called by dSpaceCollide when two objects in space are * potentially colliding. */ private void nearCallback (Object data, DGeom o1, DGeom o2) { /* exit without doing anything if the two bodies are connected by a joint */ DBody b1,b2; //dContact contact; DContactBuffer contacts = new DContactBuffer(1); DContact contact = contacts.get(0); b1 = dGeomGetBody(o1); b2 = dGeomGetBody(o2); // if (b1!=null && b2!=null && dAreConnected (b1,b2)) return; contact.surface.mode = 0; contact.surface.mu = 0.1; contact.surface.mu2 = 0; if (0!=dCollide (o1,o2,1,contacts.getGeomBuffer())) {//&contact.geom,sizeof(dContactGeom))) { DJoint c = dJointCreateContact (world,contactgroup,contact); dJointAttach (c,b1,b2); } }
private void nearCallback (Object data, DGeom o1, DGeom o2) { int i,n; final int N = 10; //dContact contact[N]; DContactBuffer contacts = new DContactBuffer(N); n = dCollide (o1,o2,N,contacts.getGeomBuffer());//,sizeof (dContact) ); if (n > 0) { for (i=0; i<n; i++) { DContact contact = contacts.get(i); contact.surface.mode = (dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1); contact.surface.mu = 0.1; contact.surface.slip1 = 0.02; contact.surface.slip2 = 0.02; contact.surface.soft_erp = 0.1; contact.surface.soft_cfm = 0.0001; DJoint c = dJointCreateContact (world,contactgroup,contact); dJointAttach (c,dGeomGetBody (contact.geom.g1),dGeomGetBody (contact.geom.g2) ); } } }
private static void nearCallback (Object data, DGeom o1, DGeom o2) { // exit without doing anything if the two bodies are connected by a joint DBody b1 = o1.getBody(); DBody b2 = o2.getBody(); final int MAX_CONTACTS = 8; //DContact contact[MAX_CONTACTS]; DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS); int numc = OdeHelper.collide (o1, o2, MAX_CONTACTS, contacts.getGeomBuffer()); for (int i=0; i<numc; i++) { contacts.get(i).surface.mode = dContactApprox1; contacts.get(i).surface.mu = 5; DJoint c = OdeHelper.createContactJoint (world, contactgroup, contacts.get(i));//contact+i); c.attach (b1, b2); } }
private static void nearCallback (Object data, DGeom o1, DGeom o2) { // exit without doing anything if the two bodies are connected by a joint DBody b1 = dGeomGetBody(o1); DBody b2 = dGeomGetBody(o2); final int MAX_CONTACTS = 8; //DContact contact[MAX_CONTACTS]; DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS); int numc = dCollide (o1, o2, MAX_CONTACTS, contacts.getGeomBuffer() );//sizeof(dContact)); for (int i=0; i<numc; i++) { contacts.get(i).surface.mode = dContactApprox1; contacts.get(i).surface.mu = 5; DJoint c = dJointCreateContact (world, contactgroup, contacts.get(i));//contact+i); dJointAttach (c, b1, b2); } }
private void nearCallback (Object data, DGeom o1, DGeom o2) { DBody b1 = o1.getBody(); DBody b2 = o2.getBody(); if (b1!=null && b2!=null && areConnectedExcluding (b1,b2,DContactJoint.class)) return; DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS); // up to MAX_CONTACTS contacts per box-box for (int i=0; i<MAX_CONTACTS; i++) { DContact contact = contacts.get(i); contact.surface.mode = dContactBounce | dContactRolling; contact.surface.mu = 250; contact.surface.rho = 0.2; contact.surface.bounce = 0.2; } int numc = OdeHelper.collide (o1,o2,MAX_CONTACTS,contacts.getGeomBuffer() ); if (numc != 0) { for (int i=0; i<numc; i++) { DContact contact = contacts.get(i); DJoint c = OdeHelper.createContactJoint (world,contactgroup,contact ); c.attach (b1,b2); } } }
private static void cb_near_collision (Object data, DGeom o1, DGeom o2) { DBody b1 = o1.getBody(); DBody b2 = o2.getBody(); //dContact contact = new dContact(); DContactBuffer contacts = new DContactBuffer(1); // exit without doing anything if the two bodies are static if (b1 == null && b2 == null) { return; } // exit without doing anything if the two bodies are connected by a joint if (b1!=null && b2!=null && OdeHelper.areConnected(b1, b2)) { /* MTRAP; */ return; } contacts.get(0).surface.mode = 0; contacts.get(0).surface.mu = 0; // frictionless if (OdeHelper.collide (o1, o2, 1, contacts.getGeomBuffer())!=0);//, sizeof (dContactGeom))) { DJoint c = OdeHelper.createContactJoint (dyn_world, coll_contacts, contacts.get(0)); c.attach (b1, b2); } }
private void nearCallback (Object data, DGeom o1, DGeom o2) { int i; // only collide things with the ground boolean g1 = (o1 == ground); boolean g2 = (o2 == ground); if (!(g1 ^ g2)) return; DBody b1 = dGeomGetBody(o1); DBody b2 = dGeomGetBody(o2); DContactBuffer contacts = new DContactBuffer(3); // up to 3 contacts per box for (i=0; i<3; i++) { contacts.get(i).surface.mode = dContactSoftCFM | dContactApprox1; contacts.get(i).surface.mu = MU; contacts.get(i).surface.soft_cfm = 0.01; } int numc = dCollide (o1,o2,3,contacts.getGeomBuffer()); if (numc!= 0) {//[0].geom,sizeof(dContact))) { for (i=0; i<numc; i++) { DJoint c = dJointCreateContact (world,contactgroup,contacts.get(i)); dJointAttach (c,b1,b2); } } }
private void nearCallback (Object data, DGeom o1, DGeom o2) { int i; // only collide things with the ground boolean g1 = (o1 == ground); boolean g2 = (o2 == ground); if (!(g1 ^ g2)) return; DBody b1 = o1.getBody(); DBody b2 = o2.getBody(); DContactBuffer contacts = new DContactBuffer(3); // up to 3 contacts per box for (i=0; i<3; i++) { contacts.get(i).surface.mode = OdeConstants.dContactSoftCFM | OdeConstants.dContactApprox1; contacts.get(i).surface.mu = MU; contacts.get(i).surface.soft_cfm = 0.01; } int numc = OdeHelper.collide (o1,o2,3,contacts.getGeomBuffer()); if (numc!= 0) {//[0].geom,sizeof(dContact))) { for (i=0; i<numc; i++) { DJoint c = OdeHelper.createContactJoint (world,contactgroup,contacts.get(i)); c.attach (b1,b2); } } }
private static void nearCallback (Object data, DGeom o1, DGeom o2) { int i,n; DBody b1 = o1.getBody(); DBody b2 = o2.getBody(); if (b1!=null && b2!=null && areConnectedExcluding (b1,b2,DContactJoint.class) ) return; final int N = 10; DContactBuffer contacts = new DContactBuffer(N); n = OdeHelper.collide (o1,o2,N,contacts.getGeomBuffer());//[0].geom,sizeof (dContact) ); if (n > 0) { for (i=0; i<n; i++) { DContact contact = contacts.get(i); contact.surface.mode = (dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1); contact.surface.mu = 0.1; contact.surface.slip1 = 0.02; contact.surface.slip2 = 0.02; contact.surface.soft_erp = 0.1; contact.surface.soft_cfm = 0.0001; DJoint c = OdeHelper.createContactJoint (world,contactgroup,contact); c.attach (contact.geom.g1.getBody(), contact.geom.g2.getBody() ); } } }
private void nearCallback(Object data, DGeom g1, DGeom g2) { if (g1 == ground) { queueRemoval(g2); return; } if (g2 == ground) { queueRemoval(g1); return; } DBody b1 = dGeomGetBody(g1); DBody b2 = dGeomGetBody(g2); if (b1!=null && b2!=null && dAreConnectedExcluding(b1, b2, DContactJoint.class)) return; final int MAX_CONTACTS = 10; //DContact contact[MAX_CONTACTS]; DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS); int n = dCollide(g1, g2, MAX_CONTACTS, contacts.getGeomBuffer());//, sizeof(dContact)); for (int i=0; i<n; ++i) { contacts.get(i).surface.mode = 0; contacts.get(i).surface.mu = 1; DJoint j = dJointCreateContact (world, joints, contacts.get(i)); dJointAttach(j, b1, b2); } }
private void nearCallback(Object data, DGeom g1, DGeom g2) { if (g1 == ground) { queueRemoval(g2); return; } if (g2 == ground) { queueRemoval(g1); return; } DBody b1 = g1.getBody(); DBody b2 = g2.getBody(); if (b1!=null && b2!=null && areConnectedExcluding(b1, b2, DContactJoint.class)) return; final int MAX_CONTACTS = 10; //DContact contact[MAX_CONTACTS]; DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS); int n = OdeHelper.collide(g1, g2, MAX_CONTACTS, contacts.getGeomBuffer());//, sizeof(dContact)); for (int i=0; i<n; ++i) { contacts.get(i).surface.mode = 0; contacts.get(i).surface.mu = 1; DJoint j = OdeHelper.createContactJoint (world, joints, contacts.get(i)); j.attach(b1, b2); } }
private void nearCallback (Object data, DGeom o1, DGeom o2) { // for drawing the contact points DMatrix3 RI = new DMatrix3(); RI.setIdentity (); DVector3C ss = new DVector3(0.02,0.02,0.02); DBody b1 = o1.getBody(); DBody b2 = o2.getBody(); DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS); int numc = OdeHelper.collide (o1,o2,MAX_CONTACTS,contacts.getGeomBuffer()); for (int i=0; i<numc; i++) { contacts.get(i).surface.mode = OdeConstants.dContactApprox1; contacts.get(i).surface.mu = 2; DJoint c = OdeHelper.createContactJoint (world,contactgroup,contacts.get(i)); c.attach (b1,b2); if (show_contacts) dsDrawBox (contacts.get(i).geom.pos, RI, ss); } }
private void nearCallback (Object data, DGeom o1, DGeom o2) { // for drawing the contact points DMatrix3 RI = new DMatrix3(); RI.setIdentity (); DVector3C ss = new DVector3(0.02,0.02,0.02); int i; DBody b1 = dGeomGetBody(o1); DBody b2 = dGeomGetBody(o2); //DContact contact[MAX_CONTACTS]; DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS); int numc = dCollide (o1,o2,MAX_CONTACTS,contacts.getGeomBuffer()); //sizeof(dContact)); for (i=0; i<numc; i++) { contacts.get(i).surface.mode = dContactApprox1; contacts.get(i).surface.mu = 2; DJoint c = dJointCreateContact (world,contactgroup,contacts.get(i)); dJointAttach (c,b1,b2); if (show_contacts) dsDrawBox (contacts.get(i).geom.pos, RI, ss); } }