/** * Get the position of a body. * * <p>REMARKS: * When getting, the returned values are pointers to internal data structures, * so the vectors are valid until any changes are made to the rigid body * system structure. * @param b b * @return ret * @see #dBodyCopyPosition(DBody, DVector3) */ //ODE_API //const public static DVector3C dBodyGetPosition (DBody b){ return b.getPosition(); }
/** * Get the position of a body. * * <p>REMARKS: * When getting, the returned values are pointers to internal data structures, * so the vectors are valid until any changes are made to the rigid body * system structure. * @param b b * @return ret * @see #dBodyCopyPosition(DBody, DVector3) */ //ODE_API //const public static DVector3C dBodyGetPosition (DBody b){ return b.getPosition(); }
/** * Copy the position of a body into a vector. * * @param body the body to query * @param pos a copy of the body position * @see #dBodyGetPosition(DBody) */ //ODE_API public static void dBodyCopyPosition (DBody body, DVector3 pos){ pos.set(body.getPosition()); }
/** * Copy the position of a body into a vector. * * @param body the body to query * @param pos a copy of the body position * @see #dBodyGetPosition(DBody) */ //ODE_API public static void dBodyCopyPosition (DBody body, DVector3 pos){ pos.set(body.getPosition()); }
void draw() { dsDrawBox(body.getPosition(), body.getRotation(), sides); } };
private static void track_to_pos (DBody body, DPlane2DJoint joint_id, double target_x, double target_y) { double curr_x = body.getPosition().get0(); double curr_y = body.getPosition().get1(); joint_id.setXParamVel (1 * (target_x - curr_x)); joint_id.setYParamVel (1 * (target_y - curr_y)); }
private static void track_to_pos (DBody body, DPlane2DJoint joint_id, double target_x, double target_y) /************************************************************************/ { double curr_x = body.getPosition().get0(); double curr_y = body.getPosition().get1(); dJointSetPlane2DXParam (joint_id, dParamVel, 1 * (target_x - curr_x)); dJointSetPlane2DYParam (joint_id, dParamVel, 1 * (target_y - curr_y)); }
private void addSpringForce (double ks) { DVector3C p1 = body[0].getPosition(); DVector3C p2 = body[1].getPosition(); DVector3 tmp = new DVector3(); //dBodyAddForce (body[0],ks*(p2.v[0]-p1.v[0]),ks*(p2.v[1]-p1.v[1]),ks*(p2.v[2]-p1.v[2])); tmp.eqDiff(p2, p1).scale(ks); body[0].addForce(tmp); //dBodyAddForce (body[1],ks*(p1.v[0]-p2.v[0]),ks*(p1.v[1]-p2.v[1]),ks*(p1.v[2]-p2.v[2])); tmp.eqDiff(p1, p2).scale(ks); body[1].addForce(tmp); }
@Override public void step(boolean pause) { if (!pause) { expStep(expGyroBody); world.step(dt); } dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); dsSetColor(1,0,0); dsDrawBox(noGyroBody.getPosition(), noGyroBody.getRotation(), sides); dsSetColor(1,1,0); dsDrawBox(expGyroBody.getPosition(), expGyroBody.getRotation(), sides); dsSetColor(0,1,0); dsDrawBox(impGyroBody.getPosition(), impGyroBody.getRotation(), sides); }
private void simLoop (boolean pause) { dsSetColor (0,0,2); space.collide(0,nearCallback); if (!pause) { //world.quickStep(0.02); world.step(0.02); } // remove all contact joints contactgroup.empty(); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); dsSetColor (1,0.5f,0); dsDrawCylinder(top1.getPosition(), top1.getRotation(), toplength, topradius); dsDrawCapsule(top1.getPosition(), top1.getRotation(), pinlength, pinradius); dsSetColor (0.5f,1,0); dsDrawCylinder(top2.getPosition(), top2.getRotation(), toplength, topradius); dsDrawCapsule(top2.getPosition(), top2.getRotation(), pinlength, pinradius); }
private void simLoop (boolean pause) { OdeHelper.spaceCollide (space,0,nearCallback); if (!pause) { world.quickStep (0.01); // 100 Hz } contactgroup.empty (); dsSetColorAlpha (1f,1f,0f,0.5f); dsDrawCylinder ( cylbody.getPosition(), cylbody.getRotation(), CYLLENGTH, CYLRADIUS ); dsDrawSphere ( sphbody.getPosition(), sphbody.getRotation(), SPHERERADIUS ); }
private static void simLoop (boolean pause) { if (!pause) { OdeHelper.spaceCollide(space,null,nearCallback); world.quickStep (0.05); contactgroup.empty (); } DVector3C sides1 = geom[0].getLengths(); DVector3C sides2 = geom[1].getLengths(); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); dsSetColor (1,1,0); dsDrawBox (body[0].getPosition(), body[0].getRotation(), sides1); dsSetColor (0,1,1); dsDrawBox (body[1].getPosition(), body[1].getRotation(), sides2); }
@Override public void step (boolean pause) { int i; if (!pause) { //static double angle = 0; angle += 0.05; body[NUM-1].addForce(0,0,1.5*(Math.sin(angle)+1.0)); space.collide(0,myNearCallback); world.step(0.05); /* remove all contact joints */ contactgroup.empty(); } dsSetColor (1,1,0); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); for (i=0; i<NUM; i++) dsDrawSphere (body[i].getPosition(), body[i].getRotation(),RADIUS); }
@Override public void step (boolean pause) { if (!pause) { // static double angle = 0; angle += 0.05; body[NUM-1].addForce (0,0,1.5*(Math.sin(angle)+1.0)); space.collide (0,nearCallback); world.step (0.05); // remove all contact joints contactgroup.empty(); } DVector3 sides = new DVector3(SIDE,SIDE,SIDE); dsSetColor (1,1,0); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); for (int i=0; i<NUM; i++) dsDrawBox (body[i].getPosition(),body[i].getRotation(),sides); }
DVector3 sides3 = new DVector3(3*SIDE,3*SIDE,3*SIDE); dsSetColor (1,1,1); dsDrawBox (anchor_body.getPosition(), anchor_body.getRotation(), sides3); dsSetColor (1,0,0); dsDrawBox (test_body.getPosition(), test_body.getRotation(), sides2); dsSetColor (1,1,0); for (int i=0; i<NUM; i++) dsDrawBox (particle[i].getPosition (), particle[i].getRotation (), sides);
@Override public void step (boolean pause) { if (!pause) { // static double angle = 0; angle += 0.05; body[NUM-1].addForce (0,0,1.5*(sin(angle)+1.0)); space.collide (0,nearCallback); world.step (0.05); // remove all contact joints contactgroup.empty(); } DVector3 sides = new DVector3(SIDE,SIDE,SIDE); dsSetColor (1,1,0); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); for (int i=0; i<NUM; i++) dsDrawBox (body[i].getPosition(),body[i].getRotation(),sides); }
void simLoop (boolean pause) { if (!pause) { final double step = 0.02; final int nsteps = 1; for (int i=0; i<nsteps; ++i) { OdeHelper.spaceCollide(space, null, nearCallback); world.quickStep(step); contact_group.empty(); } } else { OdeHelper.spaceCollide(space, null, nearCallback); contact_group.empty(); } // now we draw everything for (DGeom g : space.getGeoms()) { if (g == ground) continue; // drawstuff is already drawing it for us drawGeom(g); } if (ball1_body.getPosition().get0() < -track_len) resetSim(); }
DVector3C spos = sphbody.getPosition(); DMatrix3C srot = sphbody.getRotation(); dsDrawSphere ( spos, srot, RADIUS );
dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); DVector3 sides = new DVector3(LENGTH,WIDTH,HEIGHT); dsDrawBox (body[0].getPosition(), body[0].getRotation(), sides); dsSetColor (1,1,1); for (i=1; i<=3; i++) dsDrawCylinder (body[i].getPosition(), body[i].getRotation(),0.02f,RADIUS);
@Override public void step (boolean pause) { if (!pause) { // add random forces and torques to all bodies int i; final double scale1 = 5; final double scale2 = 5; for (i=0; i<NUM; i++) { body[i].addForce ( scale1*(dRandReal()*2-1), scale1*(dRandReal()*2-1), scale1*(dRandReal()*2-1)); body[i].addTorque ( scale2*(dRandReal()*2-1), scale2*(dRandReal()*2-1), scale2*(dRandReal()*2-1)); } world.step (0.05); createTest(); } // float sides[3] = {SIDE,SIDE,SIDE}; dsSetColor (1,1,0); for (int i=0; i<NUM; i++) dsDrawSphere (body[i].getPosition(), body[i].getRotation(), RADIUS); }