1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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();
}
|