summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/RoomEnvironment.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/RoomEnvironment.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/RoomEnvironment.java')
-rw-r--r--NET/worlds/scape/RoomEnvironment.java116
1 files changed, 116 insertions, 0 deletions
diff --git a/NET/worlds/scape/RoomEnvironment.java b/NET/worlds/scape/RoomEnvironment.java
new file mode 100644
index 0000000..18b1d1f
--- /dev/null
+++ b/NET/worlds/scape/RoomEnvironment.java
@@ -0,0 +1,116 @@
+package NET.worlds.scape;
+
+import java.awt.Color;
+import java.io.IOException;
+
+public class RoomEnvironment extends WObject {
+ private int lightid = 0;
+ private int lightid2 = 0;
+ int nextVertex = 1;
+ boolean wasEdited = false;
+ private static Object classCookie = new Object();
+ private int sceneID;
+
+ static {
+ nativeInit();
+ }
+
+ RoomEnvironment() {
+ }
+
+ public static native void nativeInit();
+
+ @Override
+ protected void addRwChildren(WObject parent) {
+ this.createClump();
+ Room r = (Room)this.getOwner();
+ this.createScene(r);
+ this.newRwChildHelper();
+ this.addLight(r.getLightPosition(), r.getLightColor());
+ }
+
+ @Override
+ protected void noteAddingTo(SuperRoot owner) {
+ Room r = (Room)owner;
+ }
+
+ private void addLight(Point3Temp pos, Color c) {
+ assert this.lightid == 0;
+
+ float red = c.getRed() / 256.0F;
+ float green = c.getGreen() / 256.0F;
+ float blue = c.getBlue() / 256.0F;
+ this.lightid = Room.addLight(this.sceneID, pos.x, pos.y, pos.z, red, green, blue);
+ this.lightid2 = Room.addLight(this.sceneID, -pos.x, -pos.y, -pos.z, red * 0.5F, green * 0.5F, blue * 0.5F);
+ }
+
+ void setLightPosition(float x, float y, float z) {
+ if (this.lightid != 0) {
+ Room.setLightPosition(this.lightid, x, y, z);
+ }
+
+ if (this.lightid2 != 0) {
+ Room.setLightPosition(this.lightid2, -x, -y, -z);
+ }
+ }
+
+ void setLightColor(float red, float green, float blue) {
+ if (this.lightid != 0) {
+ Room.setLightColor(this.lightid, red, green, blue);
+ }
+
+ if (this.lightid2 != 0) {
+ Room.setLightColor(this.lightid2, red * 0.5F, green * 0.5F, blue * 0.5F);
+ }
+ }
+
+ @Override
+ public BoundBoxTemp getBoundBox() {
+ return BoundBoxTemp.make(Point3Temp.make(), Point3Temp.make());
+ }
+
+ @Override
+ protected void markVoid() {
+ super.markVoid();
+ this.destroyScene();
+ this.lightid = 0;
+ this.lightid2 = 0;
+ }
+
+ public void markClumpEdited() {
+ this.wasEdited = true;
+ }
+
+ public void prerender() {
+ if (this.wasEdited) {
+ this.wasEdited = false;
+ this.doneWithEditing();
+ }
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ s.saveVersion(1, classCookie);
+ super.saveState(s);
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ switch (r.restoreVersion(classCookie)) {
+ case 0:
+ r.setOldFlag();
+ super.restoreState(r);
+ r.restore();
+ break;
+ case 1:
+ super.restoreState(r);
+ break;
+ default:
+ throw new TooNewException();
+ }
+ }
+
+ native void createScene(Room var1);
+
+ native void destroyScene();
+}