コード例 #1
0
ファイル: ModelVillager.java プロジェクト: UserCake/Gallifrey
 /** Sets the models various rotation angles. */
 public void setRotationAngles(
     float par1, float par2, float par3, float par4, float par5, float par6) {
   field_40340_a.rotateAngleY = par4 / (180F / (float) Math.PI);
   field_40340_a.rotateAngleX = par5 / (180F / (float) Math.PI);
   field_40339_c.rotationPointY = 3F;
   field_40339_c.rotationPointZ = -1F;
   field_40339_c.rotateAngleX = -0.75F;
   field_40336_d.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2 * 0.5F;
   field_40337_e.rotateAngleX =
       MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 1.4F * par2 * 0.5F;
   field_40336_d.rotateAngleY = 0.0F;
   field_40337_e.rotateAngleY = 0.0F;
 }
コード例 #2
0
ファイル: ModelBlaze.java プロジェクト: Jay92/TestClient
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) {
    float f6 = f2 * 3.141593F * -0.1F;
    for (int i = 0; i < 4; i++) {
      field_40323_a[i].rotationPointY = -2F + MathHelper.cos(((float) (i * 2) + f2) * 0.25F);
      field_40323_a[i].rotationPointX = MathHelper.cos(f6) * 9F;
      field_40323_a[i].rotationPointZ = MathHelper.sin(f6) * 9F;
      f6 += 1.570796F;
    }

    f6 = 0.7853982F + f2 * 3.141593F * 0.03F;
    for (int j = 4; j < 8; j++) {
      field_40323_a[j].rotationPointY = 2.0F + MathHelper.cos(((float) (j * 2) + f2) * 0.25F);
      field_40323_a[j].rotationPointX = MathHelper.cos(f6) * 7F;
      field_40323_a[j].rotationPointZ = MathHelper.sin(f6) * 7F;
      f6 += 1.570796F;
    }

    f6 = 0.4712389F + f2 * 3.141593F * -0.05F;
    for (int k = 8; k < 12; k++) {
      field_40323_a[k].rotationPointY = 11F + MathHelper.cos(((float) k * 1.5F + f2) * 0.5F);
      field_40323_a[k].rotationPointX = MathHelper.cos(f6) * 5F;
      field_40323_a[k].rotationPointZ = MathHelper.sin(f6) * 5F;
      f6 += 1.570796F;
    }

    field_40322_b.rotateAngleY = f3 / 57.29578F;
    field_40322_b.rotateAngleX = f4 / 57.29578F;
  }
コード例 #3
0
 public void setRotationAngles(
     float par1, float par2, float par3, float par4, float par5, float par6) {
   // head.rotateAngleX = par5 / (180F / (float)Math.PI);
   head.rotateAngleY = par4 / (180F / (float) Math.PI);
   body.rotateAngleX = ((float) Math.PI / 2F);
   leg1.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.2F * par2;
   leg2.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 1.2F * par2;
   leg3.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 1.2F * par2;
   leg4.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.2F * par2;
 }
コード例 #4
0
 private void setRotation(ModelRenderer model, float x, float y, float z) {
   model.rotateAngleX = x;
   model.rotateAngleY = y;
   model.rotateAngleZ = z;
 }
コード例 #5
0
  public ThxModelHelicopter() {
    renderTexture = "/thx/helicopter.png";

    ENABLE_ROTOR = mod_Thx.getBoolProperty("enable_rotor");

    // All model boxes are now scaled x2 at rendering time to save texture space
    // (with the exception of the windsheield which is already min size)

    bottom:
    {
      // 1. to save texture space, create piece in upright orientation
      // 2. then we have to rotate piece back into place
      // 3. make half size and then scale later to save texture area
      // 4. also have to adjust ("reduce") position (rotationPt) since it moves when we scale
      float length = 10f;
      float height = 8f;
      float width = 2f;
      bottom = new ModelRenderer(this, 0, 22); // texture offset:
      bottom.addBox(
          -length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      bottom.setRotationPoint(
          0f * centerScale, 2f * centerScale, 0f * centerScale); // halved to adjust for scale
      bottom.rotateAngleX = PI / 2f; // 90 deg roll left to lay flat
    }
    frontWall:
    {
      // rotate about Y, so 2x6x20 -> 20x6x2
      // will be scaled x2 at render
      float length = 10f;
      float height = 3f;
      float width = 1f;
      frontWall = new ModelRenderer(this, 0, 4);
      frontWall.addBox(
          -length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      frontWall.setRotationPoint(
          -5.5f * centerScale, 0f * centerScale, 0f * centerScale); // placed 11 unit in front
      frontWall.rotateAngleY = PI * 1.5f; // 270 deg yaw
    }
    backWall:
    {
      // will be scaled x2 at render
      float length = 10f;
      float height = 3f;
      float width = 1f;
      backWall = new ModelRenderer(this, 0, 9);
      backWall.addBox(
          -length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      backWall.setRotationPoint(5.5f * centerScale, 0f * centerScale, 0f * centerScale);
      backWall.rotateAngleY = PI / 2f; // 90 deg yaw
    }
    leftWall:
    {
      // will be scaled x2 at render
      float length = 10f;
      float height = 3f;
      float width = 1f;
      leftWall = new ModelRenderer(this, 25, 19);
      leftWall.addBox(
          -length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      leftWall.setRotationPoint(0f * centerScale, 0f * centerScale, -4.5f * centerScale);
    }
    rightWall:
    {
      // will be scaled x2 at render
      float length = 10f;
      float height = 3f;
      float width = 1f;
      rightWall = new ModelRenderer(this, 25, 24);
      rightWall.addBox(
          -length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      rightWall.setRotationPoint(0f * centerScale, 0f * centerScale, 4.5f * centerScale);
      rightWall.rotateAngleY = PI; // flip 180 deg so decal is on outside
    }
    mainRotor:
    {
      // will be scaled x2 at render
      float length = 30f;
      float height = 0f;
      float width = 1f;
      mainRotor = new ModelRenderer(this, 0, 0);
      mainRotor.addBox(
          -length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      mainRotor.setRotationPoint(
          2f * centerScale,
          -11.7f * centerScale,
          0f * centerScale); // halved to adjust for scale, and a little subtracted
    }
    tailRotor:
    {
      // will be scaled x2 at render
      float length = 8f;
      float height = 1f;
      float width = 0f;
      tailRotor = new ModelRenderer(this, 0, 2);
      tailRotor.addBox(
          -length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      tailRotor.setRotationPoint(16f * centerScale, -7f * centerScale, .7f * centerScale);
    }
    tail:
    {
      // will be scaled x2 at render
      float length = 10f;
      float height = 2f;
      float width = 1f;
      tail = new ModelRenderer(this, 42, 29);
      tail.addBox(-length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      tail.setRotationPoint(12f * centerScale, -7f * centerScale, 0f * centerScale);
    }
    rotorVerticalSupport:
    {
      // will be scaled x2 at render
      float length = 1f;
      float height = 11f;
      float width = 2f;
      rotor2 = new ModelRenderer(this, 58, 11);
      rotor2.addBox(
          -length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      rotor2.setRotationPoint(6.5f * centerScale, -5f * centerScale, 0f * centerScale);
    }
    rotorHorizontalSupport:
    {
      // will be scaled x2 at render
      float length = 6f;
      float height = 1f;
      float width = 2f;
      rotor3 = new ModelRenderer(this, 48, 25);
      rotor3.addBox(
          -length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      rotor3.setRotationPoint(4f * centerScale, -11f * centerScale, 0f * centerScale);
    }
    windshield:
    {
      float length = 9f;
      float height = 7f;
      float width = 0f;
      windshield = new ModelRenderer(this, 22, 2);
      windshield.addBox(
          -length / 2f, -height / 2f, -width / 2f, (int) length, (int) height, (int) width);
      windshield.setRotationPoint(-5.5f * centerScale, -4.5f * centerScale, 0f * centerScale);
      windshield.rotateAngleY = PI * 1.5f; // 270 deg yaw
    }
  }
コード例 #6
0
  public void render() {
    update();

    // System.out.println("Model delta time sec: " + deltaTime);

    if (!visible) return;

    if (bottomVisible) bottom.render(x2scale);

    frontWall.render(x2scale);
    backWall.render(x2scale);
    leftWall.render(x2scale);
    rightWall.render(x2scale);

    // windshield
    // cockpit1.render(scale);
    // cockpit2.render(scale);
    // cockpit3.render(scale);
    windshield.render(x2scale);

    // rotor supports
    rotor2.render(x2scale);
    rotor3.render(x2scale);

    tail.render(x2scale);

    if (ENABLE_ROTOR && !paused) {
      if (rotorSpeed > 0f) {
        if (timeSpun < SPIN_UP_TIME) {
          timeSpun += deltaTime * 3f; // spin up faster than spin down

          mainRotor.rotateAngleY +=
              deltaTime * MAX_ROTOR_SPEED * rotorSpeed * timeSpun / SPIN_UP_TIME;
          tailRotor.rotateAngleZ -=
              deltaTime * MAX_ROTOR_SPEED * timeSpun / SPIN_UP_TIME; // not linked to throttle
        } else {
          mainRotor.rotateAngleY += deltaTime * MAX_ROTOR_SPEED * rotorSpeed;
          tailRotor.rotateAngleZ -= deltaTime * MAX_ROTOR_SPEED;
        }

        if (mainRotor.rotateAngleY > 2 * PI) mainRotor.rotateAngleY -= 2 * PI;
        mainRotor.render(x2scale);
        mainRotor.rotateAngleY += 1.5707f; // add second blade perp
        mainRotor.render(x2scale);

        if (tailRotor.rotateAngleZ < 2 * PI) tailRotor.rotateAngleZ += 2 * PI;
        tailRotor.render(x2scale);
        tailRotor.rotateAngleZ -= 1.5707f; // add second blade perp
        tailRotor.render(x2scale);
      } else {
        rotorSpeed = 0f;

        if (timeSpun > 0f) {
          timeSpun -= deltaTime;

          mainRotor.rotateAngleY +=
              deltaTime * MAX_ROTOR_SPEED * (1 - MathHelper.cos(timeSpun / SPIN_UP_TIME));
          tailRotor.rotateAngleZ +=
              deltaTime * MAX_ROTOR_SPEED * (1 - MathHelper.cos(timeSpun / SPIN_UP_TIME));

          // remember stopping position
          lastRotorRad = mainRotor.rotateAngleY;
          lastTailRotorRad = tailRotor.rotateAngleZ;
        } else {
          mainRotor.rotateAngleY = lastRotorRad;
          tailRotor.rotateAngleZ = lastTailRotorRad;
        }

        mainRotor.render(x2scale);
        mainRotor.rotateAngleY += 1.5707f; // add second blade perp
        mainRotor.render(x2scale);

        tailRotor.render(x2scale);
        tailRotor.rotateAngleZ -= 1.5707f; // add second blade perp
        tailRotor.render(x2scale);
      }
    } else {
      // show fixed rotor by rendering twice
      mainRotor.rotateAngleY = 0.7854f;
      mainRotor.render(x2scale);
      mainRotor.rotateAngleY += 1.5707f;
      mainRotor.render(x2scale);

      tailRotor.rotateAngleZ = 0.7854f;
      tailRotor.render(x2scale);
      tailRotor.rotateAngleZ += 1.5707f;
      tailRotor.render(x2scale);
    }
  }