Permalink
Browse files

added alt helicopter model, set enable_alt_model=true in properties t…

…o enable
  • Loading branch information...
1 parent 82800eb commit c6cddf92bf002b19f1b5cccf59376a14abd1aba8 @theoxylo committed May 9, 2012
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -51,6 +51,10 @@ public ThxEntityHelicopter(World world, double x, double y, double z, float yaw)
@Override
ThxEntityHelper createHelper()
{
+ if (mod_Thx.getBoolProperty("enable_alt_model"))
+ {
+ return new ThxEntityHelperClient(this, new ThxModelHelicopterAlt());
+ }
return new ThxEntityHelperClient(this, new ThxModelHelicopter());
}
@@ -101,7 +105,7 @@ void onUpdatePilot()
// adjust model rotor speed according to throttle
float power = (throttle - THROTTLE_MIN) / (THROTTLE_MAX - THROTTLE_MIN);
- ((ThxModelHelicopter) helper.model).rotorSpeed = power / 2f + .75f;
+ ((ThxModelHelicopterBase) helper.model).rotorSpeed = power / 2f + .75f;
return;
}
@@ -477,7 +481,7 @@ else if (Keyboard.isKeyDown(KEY_DESCEND) || (Keyboard.isKeyDown(KEY_BACK) && loo
// adjust model rotor speed according to throttle
float power = (throttle - THROTTLE_MIN) / (THROTTLE_MAX - THROTTLE_MIN);
- ((ThxModelHelicopter) helper.model).rotorSpeed = power / 2f + .75f;
+ ((ThxModelHelicopterBase) helper.model).rotorSpeed = power / 2f + .75f;
}
@Override
@@ -489,9 +493,9 @@ void onUpdateDrone()
// adjust model rotor speed according to throttle
float power = (throttle - THROTTLE_MIN) / (THROTTLE_MAX - THROTTLE_MIN);
- ((ThxModelHelicopter) helper.model).rotorSpeed = power / 2f + .75f;
+ ((ThxModelHelicopterBase) helper.model).rotorSpeed = power / 2f + .75f;
- float rotorSpeed = ((ThxModelHelicopter) helper.model).rotorSpeed;
+ float rotorSpeed = ((ThxModelHelicopterBase) helper.model).rotorSpeed;
plog("drone rotorSpeed: " + rotorSpeed);
}
@@ -501,7 +505,7 @@ void onUpdateVacant()
super.onUpdateVacant();
// power down rotor
- ((ThxModelHelicopter) helper.model).rotorSpeed = 0f;
+ ((ThxModelHelicopterBase) helper.model).rotorSpeed = 0f;
}
@Override
@@ -559,7 +563,7 @@ void pilotExit()
super.pilotExit();
- ThxModelHelicopter model = (ThxModelHelicopter) helper.model;
+ ThxModelHelicopterBase model = (ThxModelHelicopterBase) helper.model;
model.visible = true;
model.rotorSpeed = 0f;
}
@@ -1,30 +1,15 @@
package net.minecraft.src;
-public class ThxModelHelicopter extends ThxModel
+public class ThxModelHelicopter extends ThxModelHelicopterBase
{
- boolean bottomVisible = true;
-
- float scale = 0.0625f;
+ //float scale = 0.0625f;
float x2scale = 0.125f;
float centerScale = 1.0f;
- float rotorSpeed = 0f;
- float lastRotorRad = 0f;
- float lastTailRotorRad = 0f;
- float MAX_ROTOR_SPEED = 18f * ((float)mod_Thx.getIntProperty("rotor_speed_percent")) / 100f;
-
- float SPIN_UP_TIME = 10f;
- float timeSpun = 0f;
-
- boolean ENABLE_ROTOR;
public ModelRenderer mainRotor;
public ModelRenderer rotor2;
public ModelRenderer rotor3;
- //public ModelRenderer cockpit1;
- //public ModelRenderer cockpit2;
- //public ModelRenderer cockpit3;
-
public ModelRenderer windshield;
public ModelRenderer bottom;
public ModelRenderer frontWall;
@@ -35,16 +20,11 @@
public ModelRenderer tail;
public ModelRenderer tailRotor;
- //public ModelRenderer body;
-
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)
+ // All model boxes are now scaled x2 at rendering time to conserve texture space
bottom:
{
@@ -156,6 +136,7 @@ public ThxModelHelicopter()
}
windshield:
{
+ // will be scaled x2 at render
float length = 9f;
float height = 7f;
float width = 0f;
@@ -168,23 +149,17 @@ public ThxModelHelicopter()
public void render()
{
- update();
-
- //System.out.println("Model delta time sec: " + deltaTime);
+ super.render();
if (!visible) return;
- if (bottomVisible) bottom.render(x2scale);
+ 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
@@ -193,75 +168,14 @@ public void render()
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);
+ mainRotor.rotateAngleY = mainRotorAngle;
+ mainRotor.render(x2scale);
+ mainRotor.rotateAngleY += 1.5707f;
+ mainRotor.render(x2scale);
- tailRotor.rotateAngleZ = 0.7854f;
- tailRotor.render(x2scale);
- tailRotor.rotateAngleZ += 1.5707f;
- tailRotor.render(x2scale);
- }
+ tailRotor.rotateAngleZ = tailRotorAngle;
+ tailRotor.render(x2scale);
+ tailRotor.rotateAngleZ += 1.5707f;
+ tailRotor.render(x2scale);
}
}
@@ -1,55 +1,82 @@
package net.minecraft.src;
-public class ThxModelHelicopterAlt extends ThxModelHelicopter
+public class ThxModelHelicopterAlt extends ThxModelHelicopterBase
{
- public ModelRenderer body1;
- public ModelRenderer body2;
+ public ModelRenderer body;
+ public ModelRenderer mainRotor;
+ public ModelRenderer tailRotor;
+ public ModelRenderer windshield;
public ThxModelHelicopterAlt()
{
renderTexture = "/thx/helicopter-alt.png";
- // new body, large enough to hide player model in 3rd person view.
- // in 1st person view, it is invisible
- float length = 16f;
- float height = 4f;
- float width = 4f;
- float heightOffset = -9f; //9 units off ground
-
- body1 = new ModelRenderer(this, 8, 2); // texture start at upper-left pixel (8,4) of png
- body1.setRotationPoint(0f, 0f + heightOffset, 8f); // 8 units right
- body1.addBox(-length/2f, -height/2f, -width/2f, (int)length, (int)height, (int)width); // box is centered at rotation point)
- body1.rotateAngleZ = -.3f; // ~20 degrees pitch forward
-
- length = 16f;
- height = 8f;
- width = 6f;
-
- body2 = new ModelRenderer(this, 6, 12);
- body2.setRotationPoint(0f, 0f + heightOffset, -8f); // 8 units left
- body2.addBox(-length/2f, -height/2f, -width/2f, (int)length, (int)height, (int)width);
-
- //body2.rotateAngleZ = -.7f; // Pitch rad, ~40 degrees pitch forward or down
- //body2.rotateAngleY = -1.5f; // Yaw rad, ~90 degrees yaw left (counter-clockwise)
- //body2.rotateAngleX = -.3f; // Roll rad,
+ body:
+ {
+ // large enough to hide player model in 3rd person view.
+ // in 1st person view, it is invisible
+
+ // will be scaled x2 at render
+ float length = 12f;
+ float height = 8f;
+ float width = 6f;
+ body = new ModelRenderer(this, 0, 12);
+ body.addBox(-length/2f, -height/2f, -width/2f, (int)length, (int)height, (int)width);
+ body.setRotationPoint(-2f, -1f, 0f);
+ }
+ 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, -11.7f, 0f); // 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, -7f, .7f);
+ }
+ windshield:
+ {
+ // will be scaled x2 at render
+ float length = 9f;
+ float height = 7f;
+ float width = 0f;
+ windshield = new ModelRenderer(this, 0, 4);
+ windshield.addBox(-length/2f, -height/2f, -width/2f, (int)length, (int)height, (int)width);
+ windshield.setRotationPoint(-5.5f, -4.5f, 0f);
+ windshield.rotateAngleY = PI * 1.5f; // rotate 270 deg yaw for proper orientation
+ }
}
public void render()
{
- update();
+ super.render();
- //float scale = 0.0625f;
- float scale = 0.07f;
+ if (!visible) return;
- //System.out.println("Model delta time sec: " + deltaTime);
+ float scale = 0.125f;
+
+ body.render(scale * 2f);
- if (!visible) return;
+ mainRotor.rotateAngleY = mainRotorAngle;
+ mainRotor.render(scale);
+ mainRotor.rotateAngleY += 1.5707f;
+ mainRotor.render(scale);
- body1.render(scale);
+ tailRotor.rotateAngleZ = tailRotorAngle;
+ tailRotor.render(scale);
+ tailRotor.rotateAngleZ += 1.5707f;
+ tailRotor.render(scale);
- body2.rotateAngleX += deltaTime * .4f; // slow roll
- body2.rotateAngleY += deltaTime * .4f; // slow yaw
- body2.rotateAngleZ += deltaTime * .4f; // slow pitch
- body2.render(scale);
+ windshield.render(scale);
}
}
Oops, something went wrong.

0 comments on commit c6cddf9

Please sign in to comment.