-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneObject.java
More file actions
89 lines (74 loc) · 2.37 KB
/
SceneObject.java
File metadata and controls
89 lines (74 loc) · 2.37 KB
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
// the interface between the scene renderer and different object types
/* to be honest if you are reading this I hate this class and want to find a more clean way to do this
* that doesnt also cause the scene renderer to become less clean and since that is the current code that grows
* and changes more frequently this is where the bad code hides
*/
public class SceneObject {
// all but one object should be null
Sphere sphere = null;
Plane plane = null;
public SceneObject(Sphere object){
sphere = object;
}
public SceneObject(Plane object){
plane = object;
}
public double signedDistTo(double x_, double y_, double z_){
if (sphere != null){
return sphere.signedDistTo(x_, y_, z_);
}
else if (plane != null) {
return plane.signedDistTo(x_, y_, z_);
}
return (Double) null;
}
public double[] getNormalVector(double x_, double y_, double z_){
if (sphere != null){
return sphere.getNormalVector(x_, y_, z_);
}
else if (plane != null) {
return plane.getNormalVector();
}
return null;
}
public double getColor(){
if (sphere != null){
return sphere.c;
}
else if (plane != null) {
return plane.c;
}
return (Double) null;
}
public boolean getReflectivity(){
if (sphere != null){
return sphere.reflectivity;
}
else if (plane != null){
return plane.reflectivity;
}
return false;
}
public void changeCords(double x, double y, double z){
if (sphere != null){
sphere.x += x;
sphere.y += y;
sphere.z += z;
}
else if (plane != null){
plane.x += x;
plane.y += y;
plane.z += z;
}
}
public void changeAngle(double p, double y){
if (sphere != null){
// spheres do not have a angle so do nothing
}
else if (plane != null){
plane.angleOfNorm[0] += y;
plane.angleOfNorm[1] += p;
plane.normalVector = Scene.angleToVector(plane.angleOfNorm[0], plane.angleOfNorm[1]);
}
}
}