예제 #1
0
파일: Bullet.java 프로젝트: xranby/jogltest
 public void render(GLAutoDrawable drawable) {
   GL2 gl = drawable.getGL().getGL2();
   gl.glPushMatrix();
   gl.glTranslated(
       body.getPosition().get0(), body.getPosition().get1(), body.getPosition().get2());
   GLUquadric bulletGeom = glu.gluNewQuadric();
   glu.gluQuadricDrawStyle(bulletGeom, GLU.GLU_FILL);
   glu.gluQuadricNormals(bulletGeom, GLU.GLU_SMOOTH);
   glu.gluDisk(bulletGeom, 0.3, 0.4, 5, 5);
   gl.glPopMatrix();
 }
예제 #2
0
  /** The call to ragdoll.destroy() used to cause an NPE. */
  @Test
  public void testIssue31() {
    DWorld world = OdeHelper.createWorld();
    world.setGravity(0, 0, -9.8);
    world.setDamping(1e-4, 1e-5);
    //    dWorldSetERP(world, 1);
    DSpace space = OdeHelper.createSimpleSpace();
    OdeHelper.createPlane(space, 0, 0, 1, 0);

    DxRagdoll ragdoll = new DxRagdoll(world, space, new DxDefaultHumanRagdollConfig());
    ragdoll.setAngularDamping(0.1);
    DQuaternion q = new DQuaternion(1, 0, 0, 0);
    Rotation.dQFromAxisAndAngle(q, new DVector3(1, 0, 0), -0.5 * Math.PI);
    for (int i = 0; i < ragdoll.getBones().size(); i++) {
      DxRagdollBody bone = ragdoll.getBones().get(i);
      DGeom g = OdeHelper.createCapsule(space, bone.getRadius(), bone.getLength());
      DBody body = bone.getBody();
      DQuaternion qq = new DQuaternion();
      OdeMath.dQMultiply1(qq, q, body.getQuaternion());
      body.setQuaternion(qq);
      DMatrix3 R = new DMatrix3();
      OdeMath.dRfromQ(R, q);
      DVector3 v = new DVector3();
      OdeMath.dMultiply0_133(v, body.getPosition(), R);
      body.setPosition(v.get0(), v.get1(), v.get2());
      g.setBody(body);
    }

    ragdoll.destroy();
  }
예제 #3
0
파일: Bullet.java 프로젝트: xranby/jogltest
 public void update(float deltams) {
   // acceleration.set(velocity);
   // acceleration.negate();
   // acceleration.scale(0.1f);
   // acceleration.y += -0.98f;
   // velocity.x += acceleration.x * deltams;
   // velocity.y += acceleration.y * deltams;
   // velocity.z += acceleration.z * deltams;
   // float step = deltams;
   // location.x += velocity.x * deltams;
   // location.y += velocity.y * deltams;
   // location.z += velocity.z * deltams;
   if (body.getPosition().get1() < 0 || body.getPosition().get1() > 100) {
     // FIXME
     toRemove = true;
   }
 }