summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/WrRamp.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/WrRamp.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/WrRamp.java')
-rw-r--r--NET/worlds/scape/WrRamp.java207
1 files changed, 207 insertions, 0 deletions
diff --git a/NET/worlds/scape/WrRamp.java b/NET/worlds/scape/WrRamp.java
new file mode 100644
index 0000000..6e72628
--- /dev/null
+++ b/NET/worlds/scape/WrRamp.java
@@ -0,0 +1,207 @@
+package NET.worlds.scape;
+
+import java.io.IOException;
+
+public class WrRamp extends Room {
+ private static final float epsilon = 0.01F;
+ public Portal portal1;
+ public Portal portal2;
+ private float dzByLength;
+
+ public WrRamp(
+ World world,
+ String name,
+ float length,
+ float width,
+ float pWidth,
+ float pHeight,
+ float dz,
+ float lintelZ,
+ float floorTileX,
+ float floorTileY,
+ float ceilTileX,
+ float ceilTileY,
+ float leftTileX,
+ float leftTileY,
+ float rightTileX,
+ float rightTileY,
+ Material floor,
+ Material left,
+ Material right,
+ Material doorpost,
+ Material lintel,
+ Material ceiling
+ ) {
+ super(world, name);
+ if (pWidth > width) {
+ System.out.println("WrRamp: portal too wide; reducing.");
+ pWidth = width;
+ }
+
+ if (length < 0.0F) {
+ System.out.println("WrRamp: length must be positive; inverting.");
+ length = -length;
+ }
+
+ if (width < 0.0F) {
+ System.out.println("WrRamp: width must be positive; inverting.");
+ width = -width;
+ }
+
+ if (pWidth < 0.0F) {
+ System.out.println("WrRamp: portal width must be positive; inverting.");
+ pWidth = -pWidth;
+ }
+
+ if (pHeight < 0.0F) {
+ System.out.println("WrRamp: portal height must be positive; inverting.");
+ pHeight = -pHeight;
+ }
+
+ if (lintelZ < 0.0F) {
+ System.out.println("WrRamp: lintel height must be positive; ignoring.");
+ lintelZ = 0.0F;
+ }
+
+ if (floorTileX < 10.0F) {
+ System.out.println("WrRamp: floor tile width must be at least 10; fixing.");
+ floorTileX = 10.0F;
+ }
+
+ if (floorTileY < 10.0F) {
+ System.out.println("WrRamp: floor tile length must be at least 10; fixing.");
+ floorTileY = 10.0F;
+ }
+
+ if (ceilTileX < 10.0F) {
+ System.out.println("WrRamp: ceiling tile width must be at least 10; fixing.");
+ ceilTileX = 10.0F;
+ }
+
+ if (ceilTileY < 10.0F) {
+ System.out.println("WrRamp: ceiling tile length must be at least 10; fixing.");
+ ceilTileY = 10.0F;
+ }
+
+ if (leftTileX < 10.0F) {
+ System.out.println("WrRamp: lWall tile width must be at least 10; fixing.");
+ leftTileX = 10.0F;
+ }
+
+ if (leftTileY < 10.0F) {
+ System.out.println("WrRamp: lWall tile length must be at least 10; fixing.");
+ leftTileY = 10.0F;
+ }
+
+ if (rightTileX < 10.0F) {
+ System.out.println("WrRamp: rWall tile width must be at least 10; fixing.");
+ rightTileX = 10.0F;
+ }
+
+ if (rightTileY < 10.0F) {
+ System.out.println("WrRamp: rWall tile length must be at least 10; fixing.");
+ rightTileY = 10.0F;
+ }
+
+ RoomEnvironment env = this.getEnvironment();
+ float postX = (width - pWidth) / 2.0F;
+ this.dzByLength = dz / length;
+ float nearTop = pHeight + lintelZ;
+ float farTop = dz + nearTop;
+ this.portal1 = new Portal(width - postX, 0.0F, 0.0F, postX, 0.0F, pHeight);
+ this.portal2 = new Portal(postX, length, dz, width - postX, length, dz + pHeight);
+ env.add(this.portal1);
+ env.add(this.portal2);
+ float[] floorVerts = new float[]{
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ width,
+ 0.0F,
+ 0.0F,
+ width / floorTileX,
+ 0.0F,
+ width,
+ length,
+ dz,
+ width / floorTileX,
+ length / floorTileY,
+ 0.0F,
+ length,
+ dz,
+ 0.0F,
+ length / floorTileY
+ };
+ env.add(new Polygon(floorVerts, floor));
+ if (lintelZ > 0.0F) {
+ env.add(new Rect(width, 0.0F, pHeight, 0.0F, 0.0F, nearTop, lintel));
+ env.add(new Rect(0.0F, length, dz + pHeight, width, length, farTop, lintel));
+ }
+
+ if (width > pWidth) {
+ env.add(new Rect(width, 0.0F, 0.0F, width - postX, 0.0F, pHeight, doorpost));
+ env.add(new Rect(postX, 0.0F, 0.0F, 0.0F, 0.0F, pHeight, doorpost));
+ env.add(new Rect(0.0F, length, dz, postX, length, dz + pHeight, doorpost));
+ env.add(new Rect(width - postX, length, dz, width, length, dz + pHeight, doorpost));
+ }
+
+ float[] ceilVerts = new float[]{
+ 0.0F,
+ 0.0F,
+ nearTop,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ length,
+ farTop,
+ 0.0F,
+ length / ceilTileY,
+ width,
+ length,
+ farTop,
+ width / ceilTileX,
+ length / ceilTileY,
+ width,
+ 0.0F,
+ nearTop,
+ width / ceilTileX,
+ 0.0F
+ };
+ env.add(new Polygon(ceilVerts, ceiling));
+ float bottom = Math.min(dz, 0.0F);
+ float top = Math.max(nearTop, farTop);
+ env.add(new Rect(-0.01F, 0.0F, bottom, -0.01F, length, top, left));
+ env.add(new Rect(width + 0.01F, length, bottom, width + 0.01F, 0.0F, top, right));
+ }
+
+ public WrRamp() {
+ }
+
+ @Override
+ public float floorHeight(float x, float y, float z) {
+ return y * this.dzByLength;
+ }
+
+ @Override
+ public Point3 surfaceNormal(float x, float y, float z) {
+ Point3 A = new Point3(1.0F, 0.0F, 0.0F);
+ Point3Temp B = Point3Temp.make(0.0F, 1.0F, this.dzByLength);
+ A.cross(B);
+ A.normalize();
+ return A;
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ super.saveState(s);
+ s.saveFloat(this.dzByLength);
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ super.restoreState(r);
+ this.dzByLength = r.restoreFloat();
+ }
+}