-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTest.java
More file actions
89 lines (45 loc) · 1.81 KB
/
Copy pathTest.java
File metadata and controls
89 lines (45 loc) · 1.81 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
import java.awt.Frame;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
public class Test extends Applet {
SimpleUniverse simpleU;
public BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
Appearance polygon1Appearance = new Appearance();
Color3f color1 = new Color3f (1.0f, 1.0f, 0.0f);
ColoringAttributes color1ca = new ColoringAttributes (color1, 1);
polygon1Appearance.setColoringAttributes(color1ca);
QuadArray polygon1 = new QuadArray (4, QuadArray.COORDINATES);
polygon1.setCoordinate (0, new Point3f (0f, 0f, 0f));
polygon1.setCoordinate (1, new Point3f (2f, 0f, 0f));
polygon1.setCoordinate (2, new Point3f (2f, 3f, 0f));
polygon1.setCoordinate (3, new Point3f (0f, 3f, 0f));
objRoot.addChild(new Shape3D(polygon1,polygon1Appearance));
return objRoot;
}
public void init() {
setLayout(new BorderLayout());
Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
add("Center", c);
BranchGroup scene = createSceneGraph();
simpleU = new SimpleUniverse(c);
TransformGroup tg = simpleU.getViewingPlatform().getViewPlatformTransform();
Transform3D t3d = new Transform3D();
t3d.setTranslation(new Vector3f(0f,0f,10f));
tg.setTransform(t3d);
scene.compile();
simpleU.addBranchGraph(scene);
}
public void destroy(){
simpleU.removeAllLocales();
}
public static void main(String[] args) {
Frame frame = new MainFrame(new Test(), 500, 500);
}
}