summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/DiskShadow.java
blob: b24ab89845b238c5bdbb8d833949f45c8bfd1d94 (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
/*     */ package NET.worlds.scape;
/*     */ 
/*     */ import java.awt.Color;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DiskShadow
/*     */   extends Polygon
/*     */   implements NonPersister, Shadow
/*     */ {
/*  20 */   private static int numSides = 8;
/*  21 */   private static float[] diskVertices = new float[5 * numSides];
/*     */   
/*     */ 
/*     */ 
/*     */   static
/*     */   {
/*  27 */     float radius = 0.5F;
/*  28 */     int end = 5 * numSides;
/*  29 */     double angle = 0.0D;
/*  30 */     double angleInc = (float)(6.283185307179586D / numSides);
/*  31 */     for (int i = 0; i < end; angle += angleInc)
/*     */     {
/*  33 */       float x = (float)Math.cos(angle);
/*  34 */       float y = (float)Math.sin(angle);
/*  35 */       diskVertices[(i + 0)] = (radius * x);
/*  36 */       diskVertices[(i + 1)] = (radius * y);
/*  37 */       diskVertices[(i + 2)] = 0.0F;
/*  38 */       diskVertices[(i + 3)] = (0.5F + 0.5F * x);
/*  39 */       diskVertices[(i + 4)] = (0.5F + 0.5F * y);i += 5;
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public DiskShadow(WObject caster)
/*     */   {
/*  49 */     super(diskVertices, new Material(0.0F, 0.0F, 0.0F, Color.black, null, 0.5F, false, false));
/*  50 */     setBumpable(false);
/*  51 */     adjustShadow(caster);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public void adjustShadow(WObject caster)
/*     */   {
/*  61 */     Room r = caster.getRoom();
/*  62 */     if ((!caster.getVisible()) || (r == null))
/*     */     {
/*  64 */       detach();
/*  65 */       return;
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  75 */     float size = caster.getMinXYExtent();
/*     */     
/*  77 */     BoundBoxTemp box = caster.getBoundBox();
/*     */     
/*     */ 
/*     */ 
/*  81 */     if ((size <= 0.0F) || (size > 10000.0F) || (box.hi.z < 0.0F) || (box.lo.z >= 250.0F))
/*     */     {
/*  83 */       detach();
/*  84 */       return;
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*  89 */     float shadowFrac = 1.0F;
/*  90 */     if (box.lo.z > 0.0F) {
/*  91 */       shadowFrac = 1.0F - box.lo.z / 250.0F;
/*     */     }
/*  93 */     if ((getOwner() == null) && (r != null)) {
/*  94 */       r.getEnvironment().add(this);
/*     */     }
/*  96 */     Point3Temp xyz = caster.getWorldPosition();
/*     */     
/*  98 */     moveTo(xyz.x, xyz.y, r.floorHeight(xyz.x, xyz.y, xyz.z) + 0.5F);
/*  99 */     yaw(getYaw() - caster.getYaw());
/*     */     
/* 101 */     scale(size * shadowFrac / getScaleX());
/*     */   }
/*     */ }


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