private DJoint addHingeJoint(DxRagdollBody body1, DxRagdollBody body2, DVector3 anchor, DVector3 axis, double loStop, double hiStop) { DHingeJoint joint = OdeHelper.createHingeJoint(world); joint.attach(body1.body, body2.body); joint.setAnchor(anchor); joint.setAxis(axis); joint.setParam(PARAM_N.dParamLoStop1, loStop); joint.setParam(PARAM_N.dParamHiStop1, hiStop); joints.add(joint); return joint; }
/** * Get the hinge angle. * * The angle is measured between the two bodies, or between the body and * the static environment. * The angle will be between -pi..pi. * Give the relative rotation with respect to the Hinge axis of Body 1 with * respect to Body 2. * When the hinge anchor or axis is set, the current position of the attached * bodies is examined and that position will be the zero angle. * @param j j * @return r */ //ODE_API public static double dJointGetHingeAngle (DHingeJoint j) { return j.getAngle(); }
/** * Get the hinge angle time derivative. * @param j j * @return r */ //ODE_API public static double dJointGetHingeAngleRate (DHingeJoint j) { return j.getAngleRate(); }
1,1,0, 1,1,0, 0.25*M_PI,0.25*M_PI); jointHinge = OdeHelper.createHingeJoint (world,null); jointHinge.attach (body[0],body[1]); jointHinge.setAnchor (0,0,1); jointHinge.setAxis (1,-1,1.41421356); return 1; 1,0,0, 1,0,0, 0,0); jointHinge = OdeHelper.createHingeJoint (world,null); jointHinge.attach (body[0],body[1]); jointHinge.setAnchor (0,0,1); jointHinge.setAxis (0,0,1); max_iterations = 50; return 1; 1,0,0, 1,0,0, 0,0); jointHinge = OdeHelper.createHingeJoint (world,null); jointHinge.attach (body[0],body[1]); jointHinge.setAnchor (0,0,1); jointHinge.setAxis (0,0,1); jointHinge.setParamFMax (1); if (n==231) { jointHinge.setParamLoStop (-0.5); jointHinge.setParamHiStop (0.5); 1,0,0, 1,0,0, 0,0); jointHinge = OdeHelper.createHingeJoint (world,null); jointHinge.attach (body[0],body[1]); jointHinge.setAnchor (0,0,1);
hinges[i].attach (segbodies[i],segbodies[i+1]); hinges[i].setAnchor (i + 0.5 - SEGMCNT/2.0, 0, 5); hinges[i].setAxis (0,1,0); hinges[i].setParamFMax (8000.0); hinges[i].setFeedback (jfeedbacks[i]); stress[i]=0;
body2.setRotation(R); hinge2.setAnchor(-1, 0, 1); hinge2.setAxis(0, 0, 1); hinge1.setAnchor(1, 0, 1); hinge1.setAxis(0, 0, 1); body2.setRotation(R); hinge2.setAnchor(-1, 0, 2); hinge2.setAxis(Math.cos(theta), 0, Math.sin(theta)); hinge1.setAnchor(1, 0, 1); hinge1.setAxis(0, 0, 1); hinge2.setAnchor(-2, 0, 1); hinge2.setAxis(0, 0, 1); hinge1.setAnchor(2, 0, 1); hinge1.setAxis(0, 0, 1); hinge2.setParam(PARAM_N.dParamVel1, speed); hinge2.setParam(PARAM_N.dParamFMax1, 50); hinge1.setParam(PARAM_N.dParamVel1, 0); hinge1.setParam(PARAM_N.dParamFMax1, 2);
/** * Set hinge axis. * @param j j * @param x x * @param y y * @param z z */ //ODE_API public static void dJointSetHingeAxis (DHingeJoint j, double x, double y, double z) { j.setAxis(x, y, z); }
/** * Set hinge anchor parameter. * @param j j * @param x x * @param y y * @param z z */ //ODE_API public static void dJointSetHingeAnchor (DHingeJoint j, double x, double y, double z) { j.setAnchor(x, y, z); }
private static void inspectJoints() { final double forcelimit = 2000.0; int i; for (i=0; i<SEGMCNT-1; i++) { if (hinges[i].getBody(0)!=null) { // This joint has not snapped already... inspect it. double l0 = jfeedbacks[i].f1.length();// dLENGTH(jfeedbacks[i].f1); double l1 = jfeedbacks[i].f2.length();// dLENGTH(jfeedbacks[i].f2); colours[i+0] = 0.95*colours[i+0] + 0.05 * l0/forcelimit; colours[i+1] = 0.95*colours[i+1] + 0.05 * l1/forcelimit; if (l0 > forcelimit || l1 > forcelimit) stress[i]++; else stress[i]=0; if (stress[i]>4) { // Low-pass filter the noisy feedback data. // Only after 4 consecutive timesteps with excessive load, snap. System.err.println("SNAP! (that was the sound of joint " + i + " breaking)"); hinges[i].attach (null, null); } } } }
body[1].addTorque (0,0,-0.01); if (iteration == 40) { double a = jointHinge.getAngle (); if (a > 0.5 && a < 1) return 0; else return 10; double a = jointHinge.getAngle(); double r = jointHinge.getAngleRate(); double er = (a-last_angle_221)/STEPSIZE; // estimated rate last_angle_221 = a; case 231: { // ...with stops double r = jointHinge.getAngleRate(); double err = Math.abs (Math.cos(a_231) - r); if (a_231==0) err = 0; a_231 += 0.03; jointHinge.setParamVel (Math.cos(a_231)); if (n==231) return dInfinity; return err * 1e6;
/** * Set joint parameter. * @param j j * @param parameter p * @param value v */ //ODE_API public static void dJointSetHingeParam (DHingeJoint j, int parameter, double value) { j.setParam(PARAM_N.toEnum(parameter), value); }
/** * Get joint parameter * @param j j * @param parameter p * @return r */ //ODE_API public static double dJointGetHingeParam (DHingeJoint j, int parameter) { return j.getParam(PARAM_N.toEnum(parameter)); }
/** * Set hinge axis. * @param j j * @param x x * @param y y * @param z z */ //ODE_API public static void dJointSetHingeAxis (DHingeJoint j, double x, double y, double z) { j.setAxis(x, y, z); }
/** * Set hinge anchor parameter. * @param j j * @param x x * @param y y * @param z z */ //ODE_API public static void dJointSetHingeAnchor (DHingeJoint j, double x, double y, double z) { j.setAnchor(x, y, z); }
/** * Set joint parameter. * @param j j * @param parameter p * @param value v */ //ODE_API public static void dJointSetHingeParam (DHingeJoint j, int parameter, double value) { j.setParam(PARAM_N.toEnum(parameter), value); }
/** * Get joint parameter * @param j j * @param parameter p * @return r */ //ODE_API public static double dJointGetHingeParam (DHingeJoint j, int parameter) { return j.getParam(PARAM_N.toEnum(parameter)); }