// Fw3D.java // Flower Works Fire Ball Class // Copyright (C) 1997,1998 Yukinori NAGATANI // nagatani@eken.phys.nagoya-u.ac.jp import java.awt.Color; public class Fw3D { public Fw3D next; public double x, y, z; // position public double xV, yV, zV; // velocity public double rFriction; public int nLifeTime, nTime; public int nGeneration; public Color colorFirst, colorMid, colorFinal; public void reset () { next = null; x = y = z = 0.0; xV = yV = zV = 0.0; rFriction = 0.0; nLifeTime = nTime = 0; nGeneration = 0; colorFirst = colorMid = colorFinal = Color.white; } Fw3D () { // default constructor reset (); } // constructor Fw3D (double x, double y, double z, double xV, double yV, double zV, double rFriction, int nLifeTime, int nGeneration) { reset (); this.x = x; this.y = y; this.z = z; this.xV = xV; this.yV = yV; this.zV = zV; this.rFriction = rFriction; this.nLifeTime = this.nTime = nLifeTime; this.nGeneration = nGeneration; } Fw3D (Fw3D fw) // copy constructor { reset (); this.x = fw.x; this.y = fw.y; this.z = fw.z; this.xV = fw.xV; this.yV = fw.yV; this.zV = fw.zV; this.rFriction = fw.rFriction; this.nLifeTime = fw.nLifeTime; this.nTime = fw.nTime; this.nGeneration = fw.nGeneration; this.colorFirst = fw.colorFirst; this.colorMid = fw.colorMid; this.colorFinal = fw.colorFinal; } public void evolute () { x += xV; y += yV; z += zV; xV += +0.00 - rFriction*xV; yV += +0.00 - rFriction*yV; zV += -0.15 - rFriction*zV; nTime--; } public Color getColor () { if (nTime < 5) return colorFinal; if (nLifeTime - nTime < 4 + (int)(4.0*Math.random())) return colorFirst; return colorMid; } };