diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/VehicleShape.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/VehicleShape.java')
| -rw-r--r-- | NET/worlds/scape/VehicleShape.java | 571 |
1 files changed, 571 insertions, 0 deletions
diff --git a/NET/worlds/scape/VehicleShape.java b/NET/worlds/scape/VehicleShape.java new file mode 100644 index 0000000..2196448 --- /dev/null +++ b/NET/worlds/scape/VehicleShape.java @@ -0,0 +1,571 @@ +package NET.worlds.scape; + +import NET.worlds.console.Console; +import NET.worlds.console.DialogReceiver; +import NET.worlds.console.OkCancelDialog; +import NET.worlds.core.IniFile; +import NET.worlds.network.URL; +import java.io.IOException; + +public class VehicleShape extends PosableShape implements MouseDownHandler, DialogReceiver { + static final int fourWheelDrive = 0; + static final int frontWheelDrive = 1; + static final int rearWheelDrive = 2; + private String promptString = "Take her for a spin?"; + public float rearEndRatio = 3.07F; + public float frontalArea = 42.5F; + public float wheelDiameter = 2.167F; + public float coeffKineticFriction = 0.05F; + public float coeffStaticFriction = 0.2F; + public float mass = 100.0F; + public float gearRatio1 = 2.88F; + public float gearRatio2 = 1.91F; + public float gearRatio3 = 1.33F; + public float gearRatio4 = 1.0F; + public float gearRatio5 = 0.7F; + public float maxEngineTorque = 300.0F; + public float tireAdhesiveLimit = 1.1F; + public float shockDampingCoeff = 3.0F; + public float shockLength = 0.15F; + public float rpmTorquePeak = 4200.0F; + public float idleRPM = 1000.0F; + public boolean stickShift = false; + public float initialGas = -1.0F; + public float adjustCogX = 0.0F; + public float adjustCogY = 0.0F; + public float adjustCogZ = 0.0F; + public int driveType = 2; + public boolean fixedCamera = true; + public float camX = 0.0F; + public float camY = -80.0F; + public float camZ = -120.0F; + public float camRoll = -10.0F; + public float camPitch = 0.0F; + public float camYaw = 0.0F; + public float camAimX = 15.0F; + public float camAimY = 0.0F; + public float camAimZ = 10.0F; + public float eyeHeight = 150.0F; + public String lastURL = ""; + public Point3 centerOfGravity; + public Point3 momentsOfInertia; + public Point3[] tirePositions; + private boolean avatarSwitchPending = false; + private static String[] vehicleShapeNames = new String[]{"dash"}; + private static Object classCookie = new Object(); + + VehicleShape() { + } + + VehicleShape(URL url) { + super(url); + } + + public static boolean isVehicle(URL url) { + if (IniFile.gamma().getIniInt("enableVehicleShapes", 0) == 0) { + return false; + } else { + String s = url.toString(); + + for (int i = 0; i < vehicleShapeNames.length; i++) { + if (url.toString().indexOf(vehicleShapeNames[i]) != -1) { + return true; + } + } + + return false; + } + } + + @Override + public boolean handle(MouseDownEvent event) { + if ((event.key & 1) == 1) { + new OkCancelDialog(Console.getFrame(), this, "Change Avatar", "No", "Yes", this.promptString, true); + } + + return true; + } + + @Override + public void dialogDone(Object who, boolean confirmed) { + if (who instanceof OkCancelDialog && confirmed) { + this.avatarSwitchPending = true; + boolean oldVIP = Console.getActive().getVIP(); + Console.getActive().setVIP(true); + Console.getActive().setAvatar(this.url); + Console.getActive().setVIP(oldVIP); + } + } + + protected native void nativeAnalyzeShape(int var1, float var2); + + protected native float nativeGetTirePosX(int var1); + + protected native float nativeGetTirePosY(int var1); + + protected native float nativeGetTirePosZ(int var1); + + protected native float nativeGetCogX(); + + protected native float nativeGetCogY(); + + protected native float nativeGetCogZ(); + + protected native float nativeGetMoiX(); + + protected native float nativeGetMoiY(); + + protected native float nativeGetMoiZ(); + + @Override + public void prerender(Camera cam) { + if (!this.lastURL.equals(this.url.toString()) || this.avatarSwitchPending) { + this.lastURL = new String(this.url.toString()); + System.out.println("Analyze shape " + this.lastURL); + this.nativeAnalyzeShape(this.clumpID, this.mass); + this.tirePositions = new Point3[4]; + + for (int i = 0; i < 4; i++) { + this.tirePositions[i] = new Point3(this.nativeGetTirePosX(i), this.nativeGetTirePosY(i), this.nativeGetTirePosZ(i)); + } + + this.centerOfGravity = new Point3(this.nativeGetCogX(), this.nativeGetCogY(), this.nativeGetCogZ()); + this.centerOfGravity.x = this.centerOfGravity.x + this.adjustCogX; + this.centerOfGravity.y = this.centerOfGravity.y + this.adjustCogY; + this.centerOfGravity.z = this.centerOfGravity.z + this.adjustCogZ; + this.momentsOfInertia = new Point3(this.nativeGetMoiX(), this.nativeGetMoiY(), this.nativeGetMoiZ()); + if (this.avatarSwitchPending) { + Pilot p = Console.getActive().getPilot(); + if (p instanceof HoloPilot) { + HoloPilot hp = (HoloPilot)p; + Drone d = hp.getInternalDrone(); + if (d != null && d instanceof PosableDrone) { + PosableDrone pd = (PosableDrone)d; + PosableShape ps = pd.getInternalPosableShape(); + if (ps != null && ps instanceof VehicleShape) { + VehicleShape vs = (VehicleShape)ps; + vs.fixedCamera = this.fixedCamera; + vs.camX = this.camX; + vs.camY = this.camY; + vs.camZ = this.camZ; + vs.camRoll = this.camRoll; + vs.camPitch = this.camPitch; + vs.camYaw = this.camYaw; + vs.camAimX = this.camAimX; + vs.camAimY = this.camAimY; + vs.camAimZ = this.camAimZ; + vs.eyeHeight = this.eyeHeight; + hp.setOutsideCameraMode(99, 4); + } + } + } + + this.avatarSwitchPending = false; + } + } + } + + @Override + public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException { + Object ret = null; + switch (index - offset) { + case 0: + if (mode == 0) { + ret = StringPropertyEditor.make(new Property(this, index, "Prompt String")); + } else if (mode == 1) { + ret = new String(this.promptString); + } else if (mode == 2) { + this.promptString = new String((String)value); + } + break; + case 1: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Rear End Ratio")); + } else if (mode == 1) { + ret = new Float(this.rearEndRatio); + } else if (mode == 2) { + this.rearEndRatio = (Float)value; + } + break; + case 2: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Frontal Area (sq.ft.)")); + } else if (mode == 1) { + ret = new Float(this.frontalArea); + } else if (mode == 2) { + this.frontalArea = (Float)value; + } + break; + case 3: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Wheel Diameter (ft.)")); + } else if (mode == 1) { + ret = new Float(this.wheelDiameter); + } else if (mode == 2) { + this.wheelDiameter = (Float)value; + } + break; + case 4: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Coefficient of Kinetic Friction")); + } else if (mode == 1) { + ret = new Float(this.coeffKineticFriction); + } else if (mode == 2) { + this.coeffKineticFriction = (Float)value; + } + break; + case 5: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Coefficient of Static Friction")); + } else if (mode == 1) { + ret = new Float(this.coeffStaticFriction); + } else if (mode == 2) { + this.coeffStaticFriction = (Float)value; + } + break; + case 6: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Mass (slugs)")); + } else if (mode == 1) { + ret = new Float(this.mass); + } else if (mode == 2) { + this.mass = (Float)value; + } + break; + case 7: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "1st Gear Ratio")); + } else if (mode == 1) { + ret = new Float(this.gearRatio1); + } else if (mode == 2) { + this.gearRatio1 = (Float)value; + } + break; + case 8: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "2nd Gear Ratio")); + } else if (mode == 1) { + ret = new Float(this.gearRatio2); + } else if (mode == 2) { + this.gearRatio2 = (Float)value; + } + break; + case 9: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "3rd Gear Ratio")); + } else if (mode == 1) { + ret = new Float(this.gearRatio3); + } else if (mode == 2) { + this.gearRatio3 = (Float)value; + } + break; + case 10: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "4th Gear Ratio")); + } else if (mode == 1) { + ret = new Float(this.gearRatio4); + } else if (mode == 2) { + this.gearRatio4 = (Float)value; + } + break; + case 11: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "5th Gear Ratio")); + } else if (mode == 1) { + ret = new Float(this.gearRatio5); + } else if (mode == 2) { + this.gearRatio5 = (Float)value; + } + break; + case 12: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Max. Engine Torque (ft-lbs)")); + } else if (mode == 1) { + ret = new Float(this.maxEngineTorque); + } else if (mode == 2) { + this.maxEngineTorque = (Float)value; + } + break; + case 13: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Tire Adhesive Limit")); + } else if (mode == 1) { + ret = new Float(this.tireAdhesiveLimit); + } else if (mode == 2) { + this.tireAdhesiveLimit = (Float)value; + } + break; + case 14: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Shocks Damping Coefficient")); + } else if (mode == 1) { + ret = new Float(this.shockDampingCoeff); + } else if (mode == 2) { + this.shockDampingCoeff = (Float)value; + } + break; + case 15: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Shock Length (ft)")); + } else if (mode == 1) { + ret = new Float(this.shockLength); + } else if (mode == 2) { + this.shockLength = (Float)value; + } + break; + case 16: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Torque Peak (RPM)")); + } else if (mode == 1) { + ret = new Float(this.rpmTorquePeak); + } else if (mode == 2) { + this.rpmTorquePeak = (Float)value; + } + break; + case 17: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Idle RPM")); + } else if (mode == 1) { + ret = new Float(this.idleRPM); + } else if (mode == 2) { + this.idleRPM = (Float)value; + } + break; + case 18: + if (mode == 0) { + ret = BooleanPropertyEditor.make(new Property(this, index, "Transmission Type"), "Automatic", "Manual"); + } else if (mode == 1) { + ret = new Boolean(this.stickShift); + } else if (mode == 2) { + this.stickShift = (Boolean)value; + } + break; + case 19: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Gas (Gall., -1 for infinite)")); + } else if (mode == 1) { + ret = new Float(this.initialGas); + } else if (mode == 2) { + this.initialGas = (Float)value; + } + break; + case 20: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Center of gravity X adjust")); + } else if (mode == 1) { + ret = new Float(this.adjustCogX); + } else if (mode == 2) { + this.adjustCogX = (Float)value; + } + break; + case 21: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Center of gravity Y adjust")); + } else if (mode == 1) { + ret = new Float(this.adjustCogY); + } else if (mode == 2) { + this.adjustCogY = (Float)value; + } + break; + case 22: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Center of gravity Z adjust")); + } else if (mode == 1) { + ret = new Float(this.adjustCogZ); + } else if (mode == 2) { + this.adjustCogZ = (Float)value; + } + break; + case 23: + if (mode == 0) { + ret = BooleanPropertyEditor.make(new Property(this, index, "Use fixed camera"), "No", "Yes"); + } else if (mode == 1) { + ret = new Boolean(this.fixedCamera); + } else if (mode == 2) { + this.fixedCamera = (Boolean)value; + } + break; + case 24: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Camera X offset")); + } else if (mode == 1) { + ret = new Float(this.camX); + } else if (mode == 2) { + this.camX = (Float)value; + } + break; + case 25: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Camera Y offset")); + } else if (mode == 1) { + ret = new Float(this.camY); + } else if (mode == 2) { + this.camY = (Float)value; + } + break; + case 26: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Camera Z offset")); + } else if (mode == 1) { + ret = new Float(this.camZ); + } else if (mode == 2) { + this.camZ = (Float)value; + } + break; + case 27: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Camera Roll")); + } else if (mode == 1) { + ret = new Float(this.camRoll); + } else if (mode == 2) { + this.camRoll = (Float)value; + } + break; + case 28: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Camera Pitch")); + } else if (mode == 1) { + ret = new Float(this.camPitch); + } else if (mode == 2) { + this.camPitch = (Float)value; + } + break; + case 29: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Camera Yaw")); + } else if (mode == 1) { + ret = new Float(this.camYaw); + } else if (mode == 2) { + this.camYaw = (Float)value; + } + break; + case 30: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Camera Aim X")); + } else if (mode == 1) { + ret = new Float(this.camAimX); + } else if (mode == 2) { + this.camAimX = (Float)value; + } + break; + case 31: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Camera Aim Y")); + } else if (mode == 1) { + ret = new Float(this.camAimY); + } else if (mode == 2) { + this.camAimY = (Float)value; + } + break; + case 32: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Camera Aim Z")); + } else if (mode == 1) { + ret = new Float(this.camAimZ); + } else if (mode == 2) { + this.camAimZ = (Float)value; + } + break; + case 33: + if (mode == 0) { + ret = FloatPropertyEditor.make(new Property(this, index, "Camera Eye Height")); + } else if (mode == 1) { + ret = new Float(this.eyeHeight); + } else if (mode == 2) { + this.eyeHeight = (Float)value; + } + break; + default: + ret = super.properties(index, offset + 34, mode, value); + } + + return ret; + } + + @Override + public void saveState(Saver s) throws IOException { + s.saveVersion(2, classCookie); + s.saveBoolean(this.fixedCamera); + s.saveFloat(this.camX); + s.saveFloat(this.camY); + s.saveFloat(this.camZ); + s.saveFloat(this.camRoll); + s.saveFloat(this.camPitch); + s.saveFloat(this.camYaw); + s.saveFloat(this.camAimX); + s.saveFloat(this.camAimY); + s.saveFloat(this.camAimZ); + s.saveFloat(this.eyeHeight); + s.saveString(this.promptString); + s.saveFloat(this.rearEndRatio); + s.saveFloat(this.frontalArea); + s.saveFloat(this.wheelDiameter); + s.saveFloat(this.coeffKineticFriction); + s.saveFloat(this.coeffStaticFriction); + s.saveFloat(this.mass); + s.saveFloat(this.gearRatio1); + s.saveFloat(this.gearRatio2); + s.saveFloat(this.gearRatio3); + s.saveFloat(this.gearRatio4); + s.saveFloat(this.gearRatio5); + s.saveFloat(this.maxEngineTorque); + s.saveFloat(this.tireAdhesiveLimit); + s.saveFloat(this.shockDampingCoeff); + s.saveFloat(this.shockLength); + s.saveFloat(this.rpmTorquePeak); + s.saveFloat(this.idleRPM); + s.saveBoolean(this.stickShift); + s.saveFloat(this.initialGas); + s.saveFloat(this.adjustCogX); + s.saveFloat(this.adjustCogY); + s.saveFloat(this.adjustCogZ); + super.saveState(s); + } + + @Override + public void restoreState(Restorer r) throws IOException, TooNewException { + switch (r.restoreVersion(classCookie)) { + case 2: + this.fixedCamera = r.restoreBoolean(); + this.camX = r.restoreFloat(); + this.camY = r.restoreFloat(); + this.camZ = r.restoreFloat(); + this.camRoll = r.restoreFloat(); + this.camPitch = r.restoreFloat(); + this.camYaw = r.restoreFloat(); + this.camAimX = r.restoreFloat(); + this.camAimY = r.restoreFloat(); + this.camAimZ = r.restoreFloat(); + this.eyeHeight = r.restoreFloat(); + case 1: + this.promptString = r.restoreString(); + this.rearEndRatio = r.restoreFloat(); + this.frontalArea = r.restoreFloat(); + this.wheelDiameter = r.restoreFloat(); + this.coeffKineticFriction = r.restoreFloat(); + this.coeffStaticFriction = r.restoreFloat(); + this.mass = r.restoreFloat(); + this.gearRatio1 = r.restoreFloat(); + this.gearRatio2 = r.restoreFloat(); + this.gearRatio3 = r.restoreFloat(); + this.gearRatio4 = r.restoreFloat(); + this.gearRatio5 = r.restoreFloat(); + this.maxEngineTorque = r.restoreFloat(); + this.tireAdhesiveLimit = r.restoreFloat(); + this.shockDampingCoeff = r.restoreFloat(); + this.shockLength = r.restoreFloat(); + this.rpmTorquePeak = r.restoreFloat(); + this.idleRPM = r.restoreFloat(); + this.stickShift = r.restoreBoolean(); + this.initialGas = r.restoreFloat(); + this.adjustCogX = r.restoreFloat(); + this.adjustCogY = r.restoreFloat(); + this.adjustCogZ = r.restoreFloat(); + case 0: + super.restoreState(r); + return; + default: + throw new TooNewException(); + } + } +} |