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
|
package common;
import com.sun.j3d.utils.geometry.Sphere;
import java.awt.*;
import javax.media.j3d.*;
import javax.vecmath.*;
@SuppressWarnings("restriction")
public class Particle extends CollidableObject {
/**
*
*/
private static final long serialVersionUID = -7803518117766472366L;
protected static final float RADIUS = 0.04f;
public Particle(Color3f color, Vector3f position, Vector3f velocity) {
this(1, color, position, velocity);
}
public Particle(float mass, Color3f color, Vector3f position, Vector3f velocity) {
super(mass);
setShape(createShape(color));
this.position.set(position);
this.velocity = new Vector3f(velocity);
updateTransformGroup();
}
private Node createShape(Color3f color) {
if (color == null)
color = new Color3f(Color.getHSBColor((float)Math.random(), 1, 1));
Appearance appearance = new Appearance();
appearance.setColoringAttributes(new ColoringAttributes(color, ColoringAttributes.FASTEST));
return new Sphere(RADIUS, 0, 8, appearance);
}
}
|