Search in sources :

Example 1 with InterfaceTexture

use of com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture in project j6dof-flight-sim by chris-ali.

the class AirspeedIndicator method setGaugeValue.

@Override
public void setGaugeValue(Map<FlightDataType, Double> flightData) {
    if (flightData != null) {
        double airspeed = flightData.get(FlightDataType.IAS);
        double rotationAngle = 0.0;
        if (airspeed <= 200 && airspeed > 0) {
            if (airspeed < 30)
                // Change scale so that gauge points up at 0 kts
                rotationAngle = -(2.0 * Math.PI / 200) * (airspeed / 3);
            else
                rotationAngle = -(2.0 * Math.PI / 200) * (airspeed - 20);
        } else {
            rotationAngle = -(2.0 * Math.PI / 200) * 180;
        }
        InterfaceTexture pointer = gaugeTextures.get(POINTER);
        if (pointer != null)
            pointer.setRotation((float) Math.toDegrees(rotationAngle));
    }
}
Also used : InterfaceTexture(com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture)

Example 2 with InterfaceTexture

use of com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture in project j6dof-flight-sim by chris-ali.

the class Altimeter method setGaugeValue.

@Override
public void setGaugeValue(Map<FlightDataType, Double> flightData) {
    if (flightData != null) {
        double altitude = flightData.get(FlightDataType.ALTITUDE);
        double angleStep100ft = (2 * Math.PI) / 10.0, angleStep1000ft = angleStep100ft / 10.0, angleStep10000ft = angleStep1000ft / 10.0;
        double angleRad100ft = -((altitude % 1000) / 100) * angleStep100ft, angleRad1000ft = -((altitude % 10000) / 100) * angleStep1000ft, angleRad10000ft = -((altitude % 100000) / 100) * angleStep10000ft;
        InterfaceTexture pointer100ft = gaugeTextures.get(POINTER_100), pointer1000ft = gaugeTextures.get(POINTER_1000), pointer10000ft = gaugeTextures.get(POINTER_10000);
        if (pointer100ft != null)
            pointer100ft.setRotation((float) Math.toDegrees(angleRad100ft));
        if (pointer1000ft != null)
            pointer1000ft.setRotation((float) Math.toDegrees(angleRad1000ft));
        if (pointer10000ft != null)
            pointer10000ft.setRotation((float) Math.toDegrees(angleRad10000ft));
    }
}
Also used : InterfaceTexture(com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture)

Example 3 with InterfaceTexture

use of com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture in project j6dof-flight-sim by chris-ali.

the class DirectionalGyro method setGaugeValue.

@Override
public void setGaugeValue(Map<FlightDataType, Double> flightData) {
    if (flightData != null) {
        double heading = flightData.get(FlightDataType.HEADING);
        double rotationAngle = (2.0 * Math.PI / 360.0) * (heading % 360);
        InterfaceTexture pointer = gaugeTextures.get(CARD);
        if (pointer != null)
            pointer.setRotation((float) Math.toDegrees(rotationAngle));
    }
}
Also used : InterfaceTexture(com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture)

Example 4 with InterfaceTexture

use of com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture in project j6dof-flight-sim by chris-ali.

the class Tachometer method setGaugeValue.

@Override
public void setGaugeValue(Map<FlightDataType, Double> flightData) {
    if (flightData != null) {
        double rpmLeft = flightData.get(FlightDataType.RPM_1), rpmRight = flightData.get(FlightDataType.RPM_2);
        double leftRotationAngle = Math.PI / 1.45, rightRotationAngle = Math.PI / 1.45;
        if (rpmLeft <= 3500)
            leftRotationAngle = -((1.8 * Math.PI / 4300) * rpmLeft) + Math.PI / 1.45;
        else if (rpmLeft > 3500)
            leftRotationAngle = -((1.8 * Math.PI / 4300) * 3500) + Math.PI / 1.45;
        if (rpmRight <= 3500)
            rightRotationAngle = -((1.8 * Math.PI / 4300) * rpmRight) + Math.PI / 1.45;
        else if (rpmRight > 3500)
            rightRotationAngle = -((1.8 * Math.PI / 4300) * 3500) + Math.PI / 1.45;
        InterfaceTexture pointerLeft = gaugeTextures.get(POINTER_L), pointerRight = gaugeTextures.get(POINTER_R);
        if (pointerLeft != null)
            pointerLeft.setRotation((float) Math.toDegrees(leftRotationAngle));
        if (pointerRight != null)
            pointerRight.setRotation((float) Math.toDegrees(rightRotationAngle));
    }
}
Also used : InterfaceTexture(com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture)

Example 5 with InterfaceTexture

use of com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture in project j6dof-flight-sim by chris-ali.

the class TurnCoordinator method setGaugeValue.

@Override
public void setGaugeValue(Map<FlightDataType, Double> flightData) {
    if (flightData != null) {
        double slipAngle = flightData.get(FlightDataType.TURN_COORD);
        double turnRate = flightData.get(FlightDataType.TURN_RATE);
        Vector2f ballPosition = new Vector2f((float) slipAngle * 0.0625f + position.x, position.y);
        double turnRateAngle = (turnRate > 12) ? -60 : (turnRate < -12) ? 60 : -turnRate * 5;
        InterfaceTexture pointerBall = gaugeTextures.get(BALL), pointerAircraft = gaugeTextures.get(AIRCRAFT);
        if (pointerBall != null)
            pointerBall.setPosition(ballPosition);
        if (pointerAircraft != null)
            pointerAircraft.setRotation((float) turnRateAngle);
    }
}
Also used : InterfaceTexture(com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture) Vector2f(org.lwjgl.util.vector.Vector2f)

Aggregations

InterfaceTexture (com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture)10 Vector2f (org.lwjgl.util.vector.Vector2f)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Matrix4f (org.lwjgl.util.vector.Matrix4f)1 Texture (org.newdawn.slick.opengl.Texture)1