/** * Destroy a geom, removing it from any space. * * Destroy a geom, removing it from any space it is in first. This one * function destroys a geom of any type, but to create a geom you must call * a creation function for that type. * * When a space is destroyed, if its cleanup mode is 1 (the default) then all * the geoms in that space are automatically destroyed as well. * * @param geom the geom to be destroyed. */ //ODE_API public static void dGeomDestroy (DGeom geom) { geom.destroy(); }
/** * Return the axis-aligned bounding box. * * Return in aabb an axis aligned bounding box that surrounds the given geom. * The aabb array has elements (minx, maxx, miny, maxy, minz, maxz). If the * geom is a space, a bounding box that surrounds all contained geoms is * returned. * * This function may return a pre-computed cached bounding box, if it can * determine that the geom has not moved since the last time the bounding * box was computed. * * @param geom the geom to query * @param aabb the returned bounding box */ //ODE_API // void dGeomGetAABB (dGeom geom, double aabb[6]) { public static void dGeomGetAABB (DGeom geom, DAABB aabb) { aabb.set(geom.getAABB()); }
/** * Given a geom, this returns its class. * * The ODE classes are: * <ul> * <li> dSphereClass </li> * <li> dBoxClass </li> * <li> dCylinderClass </li> * <li> dPlaneClass </li> * <li> dRayClass </li> * <li> dConvexClass </li> * <li> dGeomTransformClass </li> * <li> dTriMeshClass </li> * <li> dSimpleSpaceClass </li> * <li> dHashSpaceClass </li> * <li> dQuadTreeSpaceClass </li> * <li> dFirstUserClass </li> * <li> dLastUserClass </li> * </ul> * * User-defined class will return their own number. * * @param geom the geom to query * @return The geom class ID. */ //ODE_API public static int dGeomGetClass (DGeom geom) { return geom.getClassID(); }
private void drawGeom(DGeom g) { //int gclass = dGeomGetClass(g); if (g instanceof DCapsule) { DVector3C pos = g.getPosition(); DMatrix3C rot = g.getRotation(); DCapsule cap = (DCapsule) g; dsDrawCapsule (pos, rot, cap.getLength(), cap.getRadius()); } }
if (obj[i].geom[k]!=null) obj[i].geom[k].destroy (); obj[i].geom[0].setData(new_tmdata); System.out.println("mass at " + c); c.scale(-1); obj[i].geom[0].setPosition( c ); m.translate( c ); obj[i].geom[k].setBody(obj[i].body); obj[i].geom[k].setOffsetPosition( dpos[k].reSub(c) ); obj[i].geom[k].setOffsetRotation( drot[k]); for (k=0; k < GPB; k++) { if (obj[i].geom[k]!=null) { obj[i].geom[k].setBody (obj[i].body);
contactgroup = OdeHelper.createJointGroup(); geom[GROUND] = OdeHelper.createPlane (space, 0,0,1,0); geom[GROUND].setCategoryBits (catBits[GROUND]); geom[GROUND].setCollideBits (catBits[ALL]); geom[OBS].setCategoryBits (catBits[OBS]); geom[OBS].setCollideBits (catBits[ALL]); geom[OBS].setRotation (R); geom[OBS].setPosition (1.95, -0.2, 0.5); m.adjust (Mass1); geom[BODY2] = OdeHelper.createBox (space, BODY2_SIDES[0], BODY2_SIDES[1], BODY2_SIDES[2]); geom[BODY2].setBody (body[BODY2]); geom[BODY2].setOffsetRotation(R); geom[BODY2].setCategoryBits (catBits[BODY2]); geom[BODY2].setCollideBits (catBits[ALL] & (~catBits[BODY1]) ); body[BODY2].setMass(m); m.adjust(Mass1); geom[BODY1] = OdeHelper.createCapsule (space, RADIUS, BODY1_LENGTH); geom[BODY1].setBody (body[BODY1]); geom[BODY1].setOffsetRotation (R); geom[BODY1].setCategoryBits (catBits[BODY1]); geom[BODY1].setCollideBits (catBits[ALL] & ~catBits[BODY2] & ~catBits[RECT]); geom[RECT].setBody (body[BODY1]); geom[RECT].setOffsetPosition ( (BODY1_LENGTH-RECT_SIDES[0]) /2.0,
if (obj[i].geom[k]!=null) obj[i].geom[k].destroy(); obj[i].geom[k] = null; obj[i].geom[k].setBody(obj[i].body); obj[i].geom[k].setOffsetPosition(dpos[k].reAdd(negC)); obj[i].geom[k].setOffsetRotation(drot[k]); for (k=0; k < GPB; k++) { if (obj[i].geom[k]!=null) { obj[i].geom[k].setBody(obj[i].body); random_pos = !random_pos; } else if (cmd == 'p'&& selected >= 0) { final DVector3C pos = obj[selected].geom[0].getPosition(); final DMatrix3C rot = obj[selected].geom[0].getRotation(); System.out.println("POSITION:\n\t" + pos); System.out.println("ROTATION:\n\t" + rot);
if (pos==null) pos = g.getPosition(); if (R==null) R = g.getRotation(); DAABBC aabb = g.getAABB(); DVector3 bbpos = aabb.getCenter(); DVector3 bbsides = aabb.getLengths();
private void drawGeom (DGeom g, DVector3C pos, DMatrix3C R, boolean show_aabb) if (pos == null) pos = g.getPosition (); if (R == null) R = g.getRotation (); DBody body = g.getBody (); if (body != null) { DVector3C bodypos = body.getPosition (); DAABBC aabb = g.getAABB(); DVector3 bbpos = aabb.getCenter(); DVector3 bbsides = aabb.getLengths();
segbodies[i].setMass (m); seggeoms[i] = OdeHelper.createBox (null, SEGMDIM[0], SEGMDIM[1], SEGMDIM[2]); seggeoms[i].setBody (segbodies[i]); space.add (seggeoms[i]); stackgeoms[i].setBody(stackbodies[i]); stackbodies[i].setPosition(0,0,8+2*i); space.add(stackgeoms[i]); seggeoms[i].destroy(); for (i=0; i<STACKCNT; i++) stackgeoms[i].destroy();
for ( k=0; k < GPB; k++ ) if ( obj[i].geom[k] != null ) obj[i].geom[k].destroy(); obj[i].geom[0].setPosition( mc ); m.translate( mc ); if ( obj[i].geom[k] != null ) obj[i].geom[k].setBody( obj[i].body );
bounds[i].setMax2( bounds[i].getMin2() + dRandReal()*scale ); if (geom[i]!=null) geom[i].destroy(); geom[i] = OdeHelper.createBox (space, bounds[i].len0(), bounds[i].len1(), bounds[i].len2()); geom[i].setPosition (bounds[i].getCenter()); geom[i].setData (i);//(void*)(size_t)(i));
dsDrawLine (origin,dir); dsSetColor (0,0,1); dsDrawSphere (origin,g.getRotation(),0.01); if (!(g instanceof DPlane)) {//dGeomGetClass (g) != dPlaneClass) { pos.set(g.getPosition()); pos.add2( Z_OFFSET ); switch (g.getClassID()) { dsDrawSphere (pos,g.getRotation(),radius); break; dsSetColorAlpha (1f,1f,0f,0.8f); DVector3C sides = ((DBox)g).getLengths (); dsDrawBox (pos,g.getRotation(), sides); break; double radius = ((DCapsule)g).getRadius(); double length = ((DCapsule)g).getLength(); dsDrawCapsule (pos,g.getRotation(),length,radius); break; double radius = ((DCylinder)g).getRadius(); double length = ((DCylinder)g).getLength(); dsDrawCylinder (pos,g.getRotation(),length,radius); break;
/** * Set the body associated with a placeable geom. * * Setting a body on a geom automatically combines the position vector and * rotation matrix of the body and geom, so that setting the position or * orientation of one will set the value for both objects. Setting a body * ID of zero gives the geom its own position and rotation, independent * from any body. If the geom was previously connected to a body then its * new independent position/rotation is set to the current position/rotation * of the body. * * Calling these functions on a non-placeable geom results in a runtime * error in the debug build of ODE. * * @param geom the geom to connect * @param body the body to attach to the geom */ //ODE_API public static void dGeomSetBody (DGeom geom, DBody body) { geom.setBody(body); }
ball1_geom.setBody(ball1_body); ball1_body.setMass(m); ball2_geom.setBody(ball2_body); ball2_body.setMass(m); trk.setPosition(ro.get0(), ro.get1() + balls_sep, ro.get2()); trk.setRotation(r3); trk.setPosition(so.get0(), so.get1() + balls_sep, so.get2()); trk.setRotation(s3);
TriMesh1.setData(TriData1); TriMesh2.setData(TriData2); TriMesh1.setPosition(0, 0, 0.9); DMatrix3 Rotation1 = new DMatrix3(); dRFromAxisAndAngle(Rotation1, 1, 0, 0, M_PI / 2.); TriMesh1.setRotation(Rotation1); TriMesh2.setPosition(1, 0, 0.9); DMatrix3 Rotation2 = new DMatrix3(); dRFromAxisAndAngle(Rotation2, 1, 0, 0, M_PI / 2.); TriMesh2.setRotation(Rotation2);
world_mesh.setPosition(0, 0, 0.5); dRFromAxisAndAngle (R, 0,1,0, 0.0); world_mesh.setRotation (R); boxgeom.destroy(); world_mesh.destroy ();
/** * Get the body associated with a placeable geom. * @param geom the geom to query. * @return body * @see #dGeomSetBody(DGeom, DBody) */ //ODE_API public static DBody dGeomGetBody (DGeom geom) { return geom.getBody(); }
/** General collide function */ // static int ccdCollide(dGeomID o1, dGeomID o2, int flags, // dContactGeom *contact, int skip, // void *obj1, ccd_support_fn supp1, ccd_center_fn cen1, // void *obj2, ccd_support_fn supp2, ccd_center_fn cen2); static void ccdGeomToObj(final DGeom g, ccd_obj_t o) { DVector3C ode_pos; DQuaternionC ode_rot; ode_pos = g.getPosition(); ode_rot = g.getQuaternion(); ccdVec3Set(o.pos, ode_pos); ccdQuatSet(o.rot, ode_rot.get1(), ode_rot.get2(), ode_rot.get3(), ode_rot.get0()); ccdQuatInvert2(o.rot_inv, o.rot); }
g1.setBody(top1); g2 = OdeHelper.createCylinder(space, topradius, toplength); g2.setBody(top2); pin1.setBody(top1); pin2 = OdeHelper.createCapsule(space, pinradius, pinlength); pin2.setBody(top2); g1.DESTRUCTOR();//delete g1; g2.DESTRUCTOR();//delete g2; pin1.DESTRUCTOR();//delete pin1; pin2.DESTRUCTOR();//delete pin2;