summaryrefslogtreecommitdiff
path: root/src/tesseract/generators/BoxField.java
blob: ccb07f552e0a6dcbdeed89f236647386c32e350d (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package tesseract.generators;

import javax.vecmath.Vector3f;

import com.sun.j3d.utils.geometry.Primitive;

import tesseract.World;
import tesseract.objects.Box;
import tesseract.objects.PhysicalObject;
import tesseract.objects.Sphere;

/**
 * Generate a sphere field.
 * 
 * @author Phillip Cardon
 */
public class BoxField extends MenuItem {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static final int FIELD_SIZE = 4;
	
	private static final float BOX_SIZE = 0.025f;
	
	public BoxField(World theWorld) {
		super("Cube Field", theWorld);
	}

	/**
	 * Generate the field.
	 * 
	 * @param theWorld Where to put them
	 */
	public void generate(final World theWorld) {
		final float start = 1.01f * 0.5f * FIELD_SIZE * BOX_SIZE; 
		//int num = 0;
		//Box box = new Box(SPHERE_SIZE, SPHERE_SIZE, SPHERE_SIZE, new Vector3f(x, y, z));
		//PhysicalObject s = new Sphere(SPHERE_SIZE, new Vector3f(0f, 0f, 0f));
		
		for (float x = -start; x <= +start; x += BOX_SIZE * 1.01f) {
			for (float y = -start; y <= +start; y += BOX_SIZE * 1.01f) {
				for (float z = -start; z <= +start; z += BOX_SIZE * 1.01f) {
					//PhysicalObject s = new Sphere(SPHERE_SIZE, new Vector3f(x, y, z));
					//theWorld.addObject(s);
					//Sphere s = new Sphere(SPHERE_SIZE, new Vector3f(x, y, z));
					Box box = new Box(BOX_SIZE, BOX_SIZE, BOX_SIZE, new Vector3f(x, y, z));
					theWorld.addObject(box);
					//num++;
					//break;
				}
				//break;
			}
			//break;
		}//*/
		//System.out.println(num + " Spheres added");
	}
}