private void drawBox (DBox id, int R, int G, int B) { if (id==null) return; DVector3C pos = id.getPosition (); DMatrix3C rot = id.getRotation (); dsSetColor (R,G,B); dsDrawBox (pos, rot, id.getLengths()); }
/** * Return the depth of a point in a box. * * @param box the box to query * @param x the X coordinate of the point to test. * @param y the Y coordinate of the point to test. * @param z the Z coordinate of the point to test. * * @return The depth of the point. Points inside the box will have a * positive depth, points outside it will have a negative depth, and points * on the surface will have a depth of zero. */ //ODE_API public static double dGeomBoxPointDepth (DBox box, double x, double y, double z) { return box.getPointDepth(new DVector3(x, y, z)); }
/** * Get the side lengths of a box. * * @param box the box to query * @param result the returned side lengths * * @see #dGeomBoxSetLengths(DBox, double, double, double) */ //ODE_API public static void dGeomBoxGetLengths (DBox box, DVector3 result) { box.getLengths(result); }
box.setLengths (s); dMakeRandomVector (p,1.0); box.setPosition (p); dRFromAxisAndAngle (R,dRandReal()*2-1,dRandReal()*2-1, dRandReal()*2-1,dRandReal()*10-5); box.setRotation (R); if (dFabs(box.getPointDepth (p) - 0.5*ss) > tol) if (testFAILED()) return false; i = dRandInt (3); if (dRandReal() > 0.5) q.set( i, 0.5*s.get(i) ); else q.set( i, -0.5*s.get(i) ); dMultiply0 (q2,box.getRotation(),q); if (dFabs(box.getPointDepth (q2)) > tol) if (testFAILED()) return false; dMultiply0 (q2,box.getRotation(),q); q2.add(p); if (box.getPointDepth (q2) >= 0) if (testFAILED()) return false; dMultiply0 (q2,box.getRotation(),q); q2.add(p); if (box.getPointDepth (q2) <= 0) if (testFAILED()) return false; q.set(i, s.get(i)*0.5 - d ); if (dRandReal() > 0.5) q.scale( i, -1 ); dMultiply0 (q2,box.getRotation(),q); q2.add(p); if (dFabs(box.getPointDepth (q2) - d) >= tol) if (testFAILED()) return false;
b = wall_boxes[i].getBody(); if (b.isEnabled()) dsSetColor(0.4f,0.4f,0.4f); DVector3 ss = new DVector3(); wall_boxes[i].getLengths (ss); dsDrawBox(wall_boxes[i].getPosition(), wall_boxes[i].getRotation(), ss); b = wall_boxes[i].getBody(); if (b.isEnabled()) dsSetColor(1,1,1); dsSetColor(0.4f,0.4f,0.4f); DVector3 ss = new DVector3(); wall_boxes[i].getLengths (ss); dsDrawBox(wall_boxes[i].getPosition(), wall_boxes[i].getRotation(), ss); DVector3 sides = new DVector3(LENGTH,WIDTH,HEIGHT); for (i = 0; i < boxes; i++) dsDrawBox (box[i].getPosition(),box[i].getRotation(),sides); dsSetColor (1,1,1); for (i=0; i< spheres; i++) dsDrawSphere (sphere[i].getPosition(),
m.adjust (Mass1); geomW = OdeHelper.createBox (space, boxDim.get(X), boxDim.get(Y), boxDim.get(Z)); geomW.setBody (bodyW); geomW.setCategoryBits (catBits[W]); geomW.setCollideBits (catBits[ALL] & (~catBits[W]) & (~catBits[JOINT]) ); bodyW.setMass(m); m.adjust (Mass1); geomD = OdeHelper.createBox (space, boxDim.get(X), boxDim.get(Y), boxDim.get(Z)); geomD.setBody (bodyD); geomD.setCategoryBits (catBits[D]); geomD.setCollideBits (catBits[ALL] & (~catBits[D]) & (~catBits[JOINT]) ); bodyD.setMass(m); geomEXT.setCategoryBits (catBits[EXT]); geomEXT.setCollideBits ( catBits[ALL] & (~catBits[JOINT]) & (~catBits[W]) & (~catBits[D]) ); INT_EXT_RATIO*extDim.get(Y), INT_EXT_RATIO*extDim.get(Z)); geomINT.setCategoryBits (catBits[INT]); geomINT.setCollideBits ( catBits[ALL] & (~catBits[JOINT]) & (~catBits[W]) & (~catBits[D]) ); geomANCHOR.setCategoryBits (catBits[ANCHOR]); geomANCHOR.setCollideBits ( catBits[ALL] & (~catBits[JOINT]) & (~catBits[W]) & (~catBits[D]) ); geomEXT.setPosition (0,0,3.8);
body[0].setMass(m); box[0] = OdeHelper.createBox (null,LENGTH,WIDTH,HEIGHT); box[0].setBody(body[0]); DMatrix3 R = new DMatrix3(); OdeMath.dRFromAxisAndAngle (R,0,1,0,-0.15); ground_box.setPosition(2,0,-0.34); ground_box.setRotation(R); box[0].destroy(); sphere[0].destroy(); sphere[1].destroy();
kbody.setPosition(kx, ky, kz); kbox = OdeHelper.createBox(space, 3, 3, .5); kbox.setBody(kbody); kpole = OdeHelper.createCylinder(space, .125, 1.5); kpole.setBody(kbody); matraca.setPosition(kx+0, ky+1, kz+1); matraca_geom = OdeHelper.createBox(space, 0.5, 2, 0.75); matraca_geom.setBody(matraca); DMass mass = OdeHelper.createMass(); mass.setBox(1, 0.5, 2, 0.75);
dRandReal()*2.0-1.0,dRandReal()*10.0-5.0); box1.setLengths (side1); box2.setLengths (side2); box1.setPosition (p1); box1.setRotation (R1); box2.setPosition (p2); box2.setRotation (R2); draw_all_objects (space);
/** * Set the side lengths of the given box. * * @param box the box to set * @param lx the length of the box along the X axis * @param ly the length of the box along the Y axis * @param lz the length of the box along the Z axis * * @see #dGeomBoxGetLengths(DBox, DVector3) */ //ODE_API public static void dGeomBoxSetLengths (DBox box, double lx, double ly, double lz) { box.setLengths(new DVector3(lx, ly, lz)); }
/** * Get the side lengths of a box. * * @param box the box to query * @param result the returned side lengths * * @see #dGeomBoxSetLengths(DBox, double, double, double) */ //ODE_API public static void dGeomBoxGetLengths (DBox box, DVector3 result) { box.getLengths(result); }
box.setLengths (s); dMakeRandomVector (p,1.0); box.setPosition (p); dRFromAxisAndAngle (R,dRandReal()*2-1,dRandReal()*2-1, dRandReal()*2-1,dRandReal()*10-5); box.setRotation (R); i = dRandInt (3); if (dRandReal() > 0.5) q.set(i, 0.99*0.5*s.get(i) ); else q.set(i, -0.99*0.5*s.get(i) ); dMultiply0 (q2,box.getRotation(),q); q2.add(p); ray.setPosition (q2); i = dRandInt (3); if (dRandReal() > 0.5) q.set(i, 1.01*0.5*s.get(i)); else q.set(i, -1.01*0.5*s.get(i)); dMultiply0 (q2,box.getRotation(),q); q2.add( p ); ray.setPosition (q2); dMultiply0 (q2,box.getRotation(),q); q2.add( p ); for (j=0; j<3; j++) q3.set(j, (dRandReal()-0.5)*0.99*s.get(j) ); dMultiply0 (q4,box.getRotation(),q3); q4.add( p ); n.eqDiff( q4, q2 ); i = dRandInt (3); if (dRandReal() > 0.5) q.set(i, 1.01*0.5*s.get(i)); else q.set(i, -1.01*0.5*s.get(i)); dMultiply0 (q2,box.getRotation(),q);
kbody.setPosition(kx, ky, kz); kbox = OdeHelper.createBox(space, 3, 3, .5); kbox.setBody(kbody); kpole = OdeHelper.createCylinder(space, .125, 1.5); kpole.setBody(kbody); matraca.setPosition(kx+0, ky+1, kz+1); matraca_geom = OdeHelper.createBox(space, 0.5, 2, 0.75); matraca_geom.setBody(matraca); DMass mass = OdeHelper.createMass(); mass.setBox(1, 0.5, 2, 0.75);
box1.setLengths (side1); box2.setLengths (side2); box1.setPosition (p1); box1.setRotation (R1); box2.setPosition (p2); box2.setRotation (R2); box2.setPosition (p2); draw_all_objects (space);
/** * Set the side lengths of the given box. * * @param box the box to set * @param lx the length of the box along the X axis * @param ly the length of the box along the Y axis * @param lz the length of the box along the Z axis * * @see #dGeomBoxGetLengths(DBox, DVector3) */ //ODE_API public static void dGeomBoxSetLengths (DBox box, double lx, double ly, double lz) { box.setLengths(new DVector3(lx, ly, lz)); }
private static void drawBox (DBox id, int R, int G, int B) { if (id==null) return; DVector3C pos = id.getPosition(); DMatrix3C rot = id.getRotation(); dsSetColor (R,G,B); DVector3C l = id.getLengths(); dsDrawBox (pos, rot, l); }
private double getVolume(DBox geom) { DVector3C lengths = geom.getLengths(); return lengths.get0() * lengths.get1() * lengths.get2(); }