summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/DiskShadow.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/DiskShadow.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/DiskShadow.java')
-rw-r--r--NET/worlds/scape/DiskShadow.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/NET/worlds/scape/DiskShadow.java b/NET/worlds/scape/DiskShadow.java
new file mode 100644
index 0000000..603ad75
--- /dev/null
+++ b/NET/worlds/scape/DiskShadow.java
@@ -0,0 +1,61 @@
+package NET.worlds.scape;
+
+import java.awt.Color;
+
+public class DiskShadow extends Polygon implements NonPersister, Shadow {
+ private static int numSides = 8;
+ private static float[] diskVertices = new float[5 * numSides];
+
+ static {
+ float radius = 0.5F;
+ int end = 5 * numSides;
+ double angle = 0.0;
+ double angleInc = (float)((Math.PI * 2) / numSides);
+
+ for (int i = 0; i < end; angle += angleInc) {
+ float x = (float)Math.cos(angle);
+ float y = (float)Math.sin(angle);
+ diskVertices[i + 0] = radius * x;
+ diskVertices[i + 1] = radius * y;
+ diskVertices[i + 2] = 0.0F;
+ diskVertices[i + 3] = 0.5F + 0.5F * x;
+ diskVertices[i + 4] = 0.5F + 0.5F * y;
+ i += 5;
+ }
+ }
+
+ public DiskShadow(WObject caster) {
+ super(diskVertices, new Material(0.0F, 0.0F, 0.0F, Color.black, null, 0.5F, false, false));
+ this.setBumpable(false);
+ this.adjustShadow(caster);
+ }
+
+ @Override
+ public void adjustShadow(WObject caster) {
+ Room r = caster.getRoom();
+ if (caster.getVisible() && r != null) {
+ float defSize = 0.0F;
+ float size = caster.getMinXYExtent();
+ BoundBoxTemp box = caster.getBoundBox();
+ if (!(size <= 0.0F) && !(size > 10000.0F) && !(box.hi.z < 0.0F) && !(box.lo.z >= 250.0F)) {
+ float shadowFrac = 1.0F;
+ if (box.lo.z > 0.0F) {
+ shadowFrac = 1.0F - box.lo.z / 250.0F;
+ }
+
+ if (this.getOwner() == null && r != null) {
+ r.getEnvironment().add(this);
+ }
+
+ Point3Temp xyz = caster.getWorldPosition();
+ this.moveTo(xyz.x, xyz.y, r.floorHeight(xyz.x, xyz.y, xyz.z) + 0.5F);
+ this.yaw(this.getYaw() - caster.getYaw());
+ this.scale(size * shadowFrac / this.getScaleX());
+ } else {
+ this.detach();
+ }
+ } else {
+ this.detach();
+ }
+ }
+}