-
Notifications
You must be signed in to change notification settings - Fork 0
/
scene3.test
177 lines (148 loc) · 2.63 KB
/
scene3.test
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# Test Scene 3
# Intended to show transforms
# I know it's not the most exciting of scenes...
size 640 480
camera 0 -4 4 0 -1 0 0 1 1 45
maxverts 8
vertex -1 -1 -1
vertex +1 -1 -1
vertex +1 +1 -1
vertex -1 +1 -1
vertex -1 -1 +1
vertex +1 -1 +1
vertex +1 +1 +1
vertex -1 +1 +1
pushTransform
# The basic camera transform to return to for new parts
# The actual cube definition. Since no instancing is supported, I will just
# repeat this to create many cubes. For extra credit, you can implement
# instancing to make this simpler. Alternatively, define a ray-cube
# intersection test.
ambient .7 .7 1
scale 2 1 .25
tri 0 1 5
tri 0 5 4
tri 3 7 6
tri 3 6 2
tri 1 2 6
tri 1 6 5
tri 0 7 3
tri 0 4 7
tri 0 3 2
tri 0 2 1
tri 4 5 6
tri 4 6 7
popTransform
pushTransform
# This idiom restores the camera transform and pushes it back on the stack
# Now, I draw the 4 legs of the table.
# Note that like OpenGL, commands right-multiply
ambient .7 .7 .4
translate -1.75 -.8 -.25
translate 0 0 -2.0
scale 0.15 0.15 2.0
tri 0 1 5
tri 0 5 4
tri 3 7 6
tri 3 6 2
tri 1 2 6
tri 1 6 5
tri 0 7 3
tri 0 4 7
tri 0 3 2
tri 0 2 1
tri 4 5 6
tri 4 6 7
# leg 2: Note that I'm only changing a single translation command.
popTransform
pushTransform
translate +1.75 -.8 -.25
translate 0 0 -2.0
scale 0.15 0.15 2.0
tri 0 1 5
tri 0 5 4
tri 3 7 6
tri 3 6 2
tri 1 2 6
tri 1 6 5
tri 0 7 3
tri 0 4 7
tri 0 3 2
tri 0 2 1
tri 4 5 6
tri 4 6 7
# leg 3: Note that I'm only changing a single translation command.
popTransform
pushTransform
translate +1.75 +.8 -.25
translate 0 0 -2.0
scale 0.15 0.15 2.0
tri 0 1 5
tri 0 5 4
tri 3 7 6
tri 3 6 2
tri 1 2 6
tri 1 6 5
tri 0 7 3
tri 0 4 7
tri 0 3 2
tri 0 2 1
tri 4 5 6
tri 4 6 7
# leg 4: Note that I'm only changing a single translation command.
popTransform
pushTransform
translate -1.75 +.8 -.25
translate 0 0 -2.0
scale 0.15 0.15 2.0
tri 0 1 5
tri 0 5 4
tri 3 7 6
tri 3 6 2
tri 1 2 6
tri 1 6 5
tri 0 7 3
tri 0 4 7
tri 0 3 2
tri 0 2 1
tri 4 5 6
tri 4 6 7
# Now draw the spheres
ambient 0 1 0
popTransform
pushTransform
translate 0 0 0.5
rotate 0 0 1 45
scale 1.0 0.25 0.25
sphere 0 0 0 1
ambient 1 0 0
popTransform
pushTransform
translate 0 0 0.5
rotate 0 0 1 -45
scale 1.0 0.25 0.25
sphere 0 0 0 1
ambient 0 1 1
popTransform
pushTransform
translate -1.5 -.8 0.65
scale 0.4 0.4 0.4
sphere 0 0 0 1
ambient 0 1 1
popTransform
pushTransform
translate 1.5 -.8 0.65
scale 0.4 0.4 0.4
sphere 0 0 0 1
ambient 0 1 1
popTransform
pushTransform
translate 1.5 .8 0.65
scale 0.4 0.4 0.4
sphere 0 0 0 1
ambient 0 1 1
popTransform
pushTransform
translate -1.5 .8 0.65
scale 0.4 0.4 0.4
sphere 0 0 0 1