blob: edabc75419688a68451871a11a1a9509b880ac44 (
plain)
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
|
package common;
import javax.media.j3d.*;
import javax.vecmath.*;
@SuppressWarnings("restriction")
public class Sphere extends CollidableObject {
/**
*
*/
private static final long serialVersionUID = -7821415888599737442L;
protected float radius;
public Sphere(float radius, Vector3f position) {
this(1, radius, position);
}
public Sphere(float mass, float radius, Vector3f position) {
super(mass);
setShape(createShape(radius, 22));
this.radius = radius;
this.position.set(position);
if (inverseMass != 0) {
inverseInertiaTensor.m00 = 2f / 5 / inverseMass * radius * radius;
inverseInertiaTensor.m11 = inverseInertiaTensor.m00;
inverseInertiaTensor.m22 = inverseInertiaTensor.m00;
inverseInertiaTensor.invert();
}
updateTransformGroup();
}
protected Node createShape(float radius, int divisions) {
Appearance appearance = new Appearance();
Material material = new Material();
material.setDiffuseColor(0.7f, 0.7f, 1);
appearance.setMaterial(material);
return new com.sun.j3d.utils.geometry.Sphere(radius, com.sun.j3d.utils.geometry.Sphere.GENERATE_NORMALS, divisions, appearance);
}
}
|