summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/WrStaircase.java
blob: 05612e6004efd854e12beab08fa6916bbb5d1ebe (plain) (blame)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*     */ package NET.worlds.scape;
/*     */ 
/*     */ import java.io.IOException;
/*     */ import java.io.PrintStream;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class WrStaircase
/*     */   extends Room
/*     */ {
/*     */   private static final float epsilon = 0.01F;
/*     */   public Portal portal1;
/*     */   public Portal portal2;
/*     */   private float dzByLength;
/*     */   
/*     */   public WrStaircase(World world, String name, float length, float width, float pWidth, float pHeight, float dz, float lintelZ, int numSteps, Material riser, Material tread, Material left, Material right, Material doorpost, Material lintel, Material ceiling)
/*     */   {
/*  64 */     super(world, name);
/*     */     
/*  66 */     if (pWidth > width) {
/*  67 */       System.out.println("WrStaircase: portal too wide; reducing.");
/*  68 */       pWidth = width;
/*     */     }
/*  70 */     if (length < 0.0F) {
/*  71 */       System.out.println(
/*  72 */         "WrStaircase: length must be positive; inverting.");
/*  73 */       length = -length;
/*     */     }
/*  75 */     if (width < 0.0F) {
/*  76 */       System.out.println(
/*  77 */         "WrStaircase: width must be positive; inverting.");
/*  78 */       width = -width;
/*     */     }
/*  80 */     if (pWidth < 0.0F) {
/*  81 */       System.out.println(
/*  82 */         "WrStaircase: portal width must be positive; inverting.");
/*  83 */       pWidth = -pWidth;
/*     */     }
/*  85 */     if (pHeight < 0.0F) {
/*  86 */       System.out.println(
/*  87 */         "WrStaircase: portal height must be positive; inverting.");
/*  88 */       pHeight = -pHeight;
/*     */     }
/*  90 */     if (lintelZ < 0.0F) {
/*  91 */       System.out.println(
/*  92 */         "WrStaircase: lintel height must be positive; ignoring.");
/*  93 */       lintelZ = 0.0F;
/*     */     }
/*  95 */     if (numSteps < 2) {
/*  96 */       System.out.println(
/*  97 */         "WrStaircase: must have at least 2 steps.");
/*  98 */       numSteps = 2;
/*     */     }
/*     */     
/*     */ 
/* 102 */     RoomEnvironment env = getEnvironment();
/* 103 */     float postX = (width - pWidth) / 2.0F;
/* 104 */     float bottom = Math.min(dz, 0.0F);
/* 105 */     float ceilingHeight = Math.max(dz, 0.0F) + pHeight + lintelZ;
/* 106 */     this.dzByLength = (dz / length);
/*     */     
/*     */ 
/* 109 */     this.portal1 = new Portal(width - postX, 0.0F, 0.0F, postX, 0.0F, pHeight);
/*     */     
/* 111 */     this.portal2 = new Portal(postX, length, dz, 
/* 112 */       width - postX, length, dz + pHeight);
/*     */     
/* 114 */     env.add(this.portal1);
/* 115 */     env.add(this.portal2);
/*     */     
/*     */ 
/* 118 */     float stepWidth = length / numSteps;
/* 119 */     float stepHeight = dz / numSteps;
/* 120 */     for (int i = 1; i <= numSteps; i++) {
/* 121 */       Rect w = new Rect(0.0F, i * stepWidth, (i - 1) * stepHeight, 
/* 122 */         width, i * stepWidth, i * stepHeight - 0.01F, riser);
/* 123 */       w.setTileSize(stepHeight, stepHeight);
/*     */       
/*     */ 
/* 126 */       env.add(w);
/*     */     }
/*     */     
/*     */ 
/* 130 */     for (int i = 0; i < numSteps; i++) {
/* 131 */       Rect w = Rect.floor(0.0F, i * stepWidth, i * stepHeight, 
/* 132 */         width, (i + 1) * stepWidth - 0.01F, tread);
/* 133 */       w.setTileSize(Math.abs(stepWidth), Math.abs(stepWidth));
/* 134 */       env.add(w);
/*     */     }
/*     */     
/*     */ 
/* 138 */     if (ceilingHeight > pHeight)
/* 139 */       env.add(
/* 140 */         new Rect(width, 0.0F, pHeight, 0.0F, 0.0F, ceilingHeight - 0.01F, lintel));
/* 141 */     if (ceilingHeight > dz + pHeight)
/* 142 */       env.add(
/* 143 */         new Rect(0.0F, length, dz + pHeight, 
/* 144 */         width, length, ceilingHeight - 0.01F, lintel));
/* 145 */     if (width > pWidth) {
/* 146 */       env.add(new Rect(width, 0.0F, 0.0F, width - postX, 0.0F, pHeight, doorpost));
/* 147 */       env.add(new Rect(postX, 0.0F, 0.0F, 0.0F, 0.0F, pHeight, doorpost));
/* 148 */       env.add(new Rect(0.0F, length, dz, postX, length, dz + pHeight, doorpost));
/* 149 */       env.add(new Rect(width - postX, length, dz, width, length, dz + pHeight, 
/* 150 */         doorpost));
/*     */     }
/*     */     
/*     */ 
/* 154 */     env.add(Rect.ceiling(0.0F, 0.0F, ceilingHeight, width, length, ceiling));
/* 155 */     env.add(new Rect(-0.01F, 0.0F, bottom, -0.01F, length, ceilingHeight, 
/* 156 */       left));
/* 157 */     env.add(new Rect(width + 0.01F, length, bottom, 
/* 158 */       width + 0.01F, 0.0F, ceilingHeight, right));
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public WrStaircase() {}
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public float floorHeight(float x, float y, float z)
/*     */   {
/* 175 */     return y * this.dzByLength;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public Point3 surfaceNormal(float x, float y, float z)
/*     */   {
/* 183 */     Point3 A = new Point3(1.0F, 0.0F, 0.0F);
/* 184 */     Point3Temp B = Point3Temp.make(0.0F, 1.0F, this.dzByLength);
/* 185 */     A.cross(B);
/* 186 */     A.normalize();
/* 187 */     return A;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public void saveState(Saver s)
/*     */     throws IOException
/*     */   {
/* 195 */     super.saveState(s);
/* 196 */     s.saveFloat(this.dzByLength);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r)
/*     */     throws IOException, TooNewException
/*     */   {
/* 202 */     super.restoreState(r);
/* 203 */     this.dzByLength = r.restoreFloat();
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\WrStaircase.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */