use of club.nsdn.nyasamarailway.entity.ILocomotive in project NyaSamaRailway by NSDN.
the class NSCxMRenderer method doRenderHUD.
private void doRenderHUD(EntityMinecart cart) {
if (cart instanceof ILocomotive) {
ILocomotive loco = (ILocomotive) cart;
if (cart instanceof ILimitVelCart) {
ILimitVelCart velLoco = (ILimitVelCart) cart;
float v = (float) loco.getEngineVel();
float lim = (float) velLoco.getMaxVelocity();
float a = v - (float) loco.getEnginePrevVel();
float angle;
int d = loco.getEngineDir(), p = loco.getEnginePower(), r = loco.getEngineBrake();
String dir = d == 1 ? "F" : (d == 0 ? "N" : "R");
String pwr = String.format("%2d", p);
String brk = String.format("%2d", 10 - r);
String sv = String.format("%1.2f", v);
String sl = String.format("%1.2f", lim);
GL11.glPushMatrix();
GL11.glRotated(45, 0, 1, 0);
RendererHelper.renderPartWithResource(modelScreen, "base", textureScreen);
// HUD1406
doRenderText(0, "-= NSR--NTP =-");
doRenderText(1, "dir: " + dir);
doRenderText(2, "pwr: " + pwr + (r <= 1 ? " STOP" : " RUN"));
doRenderText(3, "brk: " + brk + (r == 1 ? " EME" : ""));
doRenderText(4, "vel:" + sv + "m/t");
doRenderText(5, "lim:" + sl + "m/t");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotated(-45, 0, 1, 0);
RendererHelper.renderPartWithResource(modelScreen, "base", textureScreen);
// HUD1406
doRenderText(0, "-= NTP--EXT =-");
doRenderText(1, "vel:" + String.format("%1.2f", v * 72) + "km/h");
doRenderText(2, "acc:" + String.format("%1.2f", a * 400) + "m/s2");
doRenderText(3, "id: " + String.format("%x", cart.getEntityId()));
doRenderText(4, "dim:" + String.format("%x", cart.dimension));
doRenderText(5, "yaw:" + String.format("%1.2f", cart.rotationYaw));
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotated(30, 0, 0, 1);
GL11.glTranslated(0.5, 0, 0);
RendererHelper.renderWithResource(modelMeterV, textureMeterV);
angle = v / 9.0F * ANGLE_HALF * 2 - ANGLE_HALF;
if (angle > ANGLE_HALF)
angle = ANGLE_HALF;
GL11.glPushMatrix();
GL11.glTranslatef(0.625F, 0.9375F, -0.625F);
GL11.glTranslatef(-0.00625F, 0.0F, 0.00625F);
GL11.glPushMatrix();
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glPushMatrix();
GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
RendererHelper.renderWithResource(modelMeterPointer, textureMeterPointer);
GL11.glPopMatrix();
GL11.glPopMatrix();
GL11.glPopMatrix();
RendererHelper.renderWithResource(modelMeterA, textureMeterA);
angle = a / 0.03F * ANGLE_HALF;
if (Math.abs(angle) > ANGLE_HALF)
angle = Math.signum(angle) * ANGLE_HALF;
GL11.glPushMatrix();
GL11.glTranslatef(0.625F, 0.9375F, 0.625F);
GL11.glTranslatef(-0.00625F, 0.0F, -0.00625F);
GL11.glPushMatrix();
GL11.glRotatef(-45.0F, 0.0F, 1.0F, 0.0F);
GL11.glPushMatrix();
GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
RendererHelper.renderWithResource(modelMeterPointer, textureMeterPointer);
GL11.glPopMatrix();
GL11.glPopMatrix();
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
}
Aggregations