-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.java
89 lines (84 loc) · 2.26 KB
/
Entity.java
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.util.ArrayList;
import java.awt.Graphics;
import java.util.Arrays;
public class Entity implements IEntity {
private ArrayList<Tetrahedron> tetras;
private MyPolygon[] polygons;
Point3D centerOfRotation;
boolean environment;
private IEntity shadow;
private String type;
public Entity(ArrayList<Tetrahedron> tetras, Point3D center) {
environment = false;
this.centerOfRotation = center;
this.tetras = tetras;
ArrayList<MyPolygon> tempList = new ArrayList<MyPolygon>();
for (Tetrahedron t : this.tetras) {
tempList.addAll(Arrays.asList(t.getPolygons()));
}
this.polygons = new MyPolygon[tempList.size()];
tempList.toArray(this.polygons);
this.sortPolygons();
}
public void renderS(Graphics g) {
if (shadow != null) shadow.render(g);
for (Tetrahedron t : this.tetras) {
t.render(g, centerOfRotation);
}
///System.out.println("\n\n\n\n");
}
public Point3D getCenter() {
return centerOfRotation;
}
public void render(Graphics g) {
if (shadow != null) shadow.render(g);
for (Tetrahedron t : this.tetras) {
t.render(g);
}
}
public void setType(String s) {
type = s;
}
public String getType() {
return type;
}
public void makeEnvironment() {
environment = true;
}
public boolean getEnvironment() {
return environment;
}
public void setShadow(IEntity e) {
shadow = e;
}
public double getX() {
return centerOfRotation.x;
}
public MyPolygon[] getPolygons() {
return polygons;
}
public void rotate(boolean CW, double xDegrees, double yDegrees, double zDegrees) {
if (shadow != null && (! (getType().equals("ball") || getType().equals("diamond")))) shadow.rotate(CW, 0, 0, zDegrees);
for (Tetrahedron t : this.tetras) {
t.rotate(CW, centerOfRotation, xDegrees, yDegrees, zDegrees);
}
}
public void move(double x, double y, double z) {
if (shadow != null) {
shadow.move(x,y,z);
if (type!=null && type.equals("player")) {
shadow.move(0,-y*0.25,0);
}
if (type!=null && type.equals("ball")) {
shadow.move(0,-y*0.1,0);
}
}
PointConverter.move(centerOfRotation, x, y, z);
for (Tetrahedron t : tetras) {
t.move(x,y,z);
}
}
public void sortPolygons() {
MyPolygon.sortPolygons(this.polygons);
}
}