-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathObject3D.java
51 lines (45 loc) · 1.08 KB
/
Object3D.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
package com.miniproject;
import java.awt.Color;
import java.awt.Graphics;
public class Object3D
{
private Polygon3D[] polygons;
private Color color;
public Object3D(Color color, Polygon3D... polygons)
{
this.color = color;
this.polygons = polygons;
this.setPolygonColor();
}
public Object3D(Polygon3D... polygons)
{
//this.color = Color.WHITE;
this.polygons = polygons;
}
public void render(Graphics g)
{
for(Polygon3D poly: this.polygons)
{
poly.render(g);
}
}
public void rotate(double xDegrees, double yDegrees, double zDegrees)
{
for(Polygon3D p: this.polygons)
{
p.rotate(xDegrees,yDegrees,zDegrees);
}
this.sortPolygons();
}
public void sortPolygons()
{
Polygon3D.sortPolygons(this.polygons);
}
public void setPolygonColor()
{
for(Polygon3D poly: this.polygons)
{
poly.setColor(this.color);
}
}
}