⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pointshape.java

📁 用java3d做的一个粒子系统可以控制粒子运动
💻 JAVA
字号:
import javax.media.j3d.*;import javax.vecmath.*;final class PointShape extends PointArray {    private Point3d[] coord;    private Color3f[] color;    private int numPoints;    private double invNumPoints;    public PointShape(int numPoints){        super(numPoints, COLOR_3 | COORDINATES);	setCapability(ALLOW_COLOR_WRITE);        setCapability(ALLOW_COORDINATE_WRITE);                this.numPoints = numPoints;	invNumPoints = 1.0/numPoints;        coord = new Point3d[numPoints];        color = new Color3f[numPoints];	        for(int i=0;i<numPoints;i++){            coord[i] = new Point3d();            color[i] = new Color3f();        }    }    void update(double localTime){        double localTime_2 = -0.5 * localTime;	double s = 1;	double t = localTime;	double tinc = localTime*invNumPoints;        for (int i=numPoints; --i>=0; ) {	    //double s = invNumPoints * i;	    s -= invNumPoints;	    	    //double t = localTime * s;	    t -= tinc;                        int angle_idx  = (int) (0xffff & (long) (13627.0*(t+localTime_2)));            int radius_idx = (int) (0xffff & (long) (15646.0*t));            int height_idx = (int) (0xffff & (long) (9970.0*t));                        double radius = 1.0 + 0.75 * Particles.COS[radius_idx];                        //double x = Particles.COS[angle_idx] * radius;            //double y = Particles.SIN[angle_idx] * radius;            double z = Particles.SIN[height_idx];	    //coord[i].set(x,y,z);	    Point3d point = coord[i];	    point.x=Particles.COS[angle_idx] * radius;	    point.y=Particles.SIN[angle_idx] * radius;	    point.z=Particles.SIN[height_idx];                        //color[i].set((float) s,	    //(float) (s*(z+1.0)*0.5),	    //(float) (s*(-z+1.0)*0.375+0.25));	    Color3f c = color[i];	    c.x=(float) s;	    c.y=(float) (s*(z+1.0)*0.5);	    c.z=(float) (s*(-z+1.0)*0.375+0.25);        }	        setCoordinates(0,coord);        setColors(0,color);    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -