-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw.go
188 lines (149 loc) · 8.85 KB
/
draw.go
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
176
177
178
179
180
181
182
183
184
185
186
187
188
package main
import "gl"
import "game/phys"
import . "game/common"
var rtri gl.GLfloat = 0.0;
var rquad gl.GLfloat = 0.0;
func drawCube(v *Vector3) {
gl.LoadIdentity()
// gl.Translatef( -1.5, 0.0, -6.0 )
gl.Translatef( gl.GLfloat(v.X), gl.GLfloat(v.Y), gl.GLfloat(v.Z), )
/* Rotate The Triangle On The Y axis ( NEW ) */
// gl.Rotatef( rtri, 0.0, 1.0, 0.0 );
gl.Begin( gl.TRIANGLES ); /* Drawing Using Triangles */
gl.Color3f( 1.0, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, 1.0, 0.0 ); /* Top Of Triangle (Front) */
gl.Color3f( 0.0, 1.0, 0.0 ); /* Green */
gl.Vertex3f( -1.0, -1.0, 1.0 ); /* Left Of Triangle (Front) */
gl.Color3f( 0.0, 0.0, 1.0 ); /* Blue */
gl.Vertex3f( 1.0, -1.0, 1.0 ); /* Right Of Triangle (Front) */
gl.Color3f( 1.0, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, 1.0, 0.0 ); /* Top Of Triangle (Right) */
gl.Color3f( 0.0, 0.0, 1.0 ); /* Blue */
gl.Vertex3f( 1.0, -1.0, 1.0 ); /* Left Of Triangle (Right) */
gl.Color3f( 0.0, 1.0, 0.0 ); /* Green */
gl.Vertex3f( 1.0, -1.0, -1.0 ); /* Right Of Triangle (Right) */
gl.Color3f( 1.0, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, 1.0, 0.0 ); /* Top Of Triangle (Back) */
gl.Color3f( 0.0, 1.0, 0.0 ); /* Green */
gl.Vertex3f( 1.0, -1.0, -1.0 ); /* Left Of Triangle (Back) */
gl.Color3f( 0.0, 0.0, 1.0 ); /* Blue */
gl.Vertex3f( -1.0, -1.0, -1.0 ); /* Right Of Triangle (Back) */
gl.Color3f( 1.0, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, 1.0, 0.0 ); /* Top Of Triangle (Left) */
gl.Color3f( 0.0, 0.0, 1.0 ); /* Blue */
gl.Vertex3f( -1.0, -1.0, -1.0 ); /* Left Of Triangle (Left) */
gl.Color3f( 0.0, 1.0, 0.0 ); /* Green */
gl.Vertex3f( -1.0, -1.0, 1.0 ); /* Right Of Triangle (Left) */
gl.End( ); /* Finished Drawing The Triangle */
rtri = rtri + 0.2;
}
func drawMass(m *phys.Mass, dsz gl.GLfloat) {
gl.LoadIdentity()
// gl.Translatef( -1.5, 0.0, -6.0 )
v := m.Pos
gl.Translatef( gl.GLfloat(v.X), gl.GLfloat(v.Y), gl.GLfloat(v.Z), )
/* Rotate The Triangle On The Y axis ( NEW ) */
// gl.Rotatef( rtri, 0.0, 1.0, 0.0 );
gl.Begin( gl.TRIANGLES ); /* Drawing Using Triangles */
gl.Color3f( dsz, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, dsz, 0.0 ); /* Top Of Triangle (Front) */
gl.Color3f( 0.0, dsz, 0.0 ); /* Green */
gl.Vertex3f( -dsz, -dsz, dsz ); /* Left Of Triangle (Front) */
gl.Color3f( 0.0, 0.0, dsz ); /* Blue */
gl.Vertex3f( dsz, -dsz, dsz ); /* Right Of Triangle (Front) */
gl.Color3f( dsz, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, dsz, 0.0 ); /* Top Of Triangle (Right) */
gl.Color3f( 0.0, 0.0, dsz ); /* Blue */
gl.Vertex3f( dsz, -dsz, dsz ); /* Left Of Triangle (Right) */
gl.Color3f( 0.0, dsz, 0.0 ); /* Green */
gl.Vertex3f( dsz, -dsz, -dsz ); /* Right Of Triangle (Right) */
gl.Color3f( dsz, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, dsz, 0.0 ); /* Top Of Triangle (Back) */
gl.Color3f( 0.0, dsz, 0.0 ); /* Green */
gl.Vertex3f( dsz, -dsz, -dsz ); /* Left Of Triangle (Back) */
gl.Color3f( 0.0, 0.0, dsz ); /* Blue */
gl.Vertex3f( -dsz, -dsz, -dsz ); /* Right Of Triangle (Back) */
gl.Color3f( dsz, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, dsz, 0.0 ); /* Top Of Triangle (Left) */
gl.Color3f( 0.0, 0.0, dsz ); /* Blue */
gl.Vertex3f( -dsz, -dsz, -dsz ); /* Left Of Triangle (Left) */
gl.Color3f( 0.0, dsz, 0.0 ); /* Green */
gl.Vertex3f( -dsz, -dsz, dsz ); /* Right Of Triangle (Left) */
gl.End( ); /* Finished Drawing The Triangle */
}
func drawCubes(v *Vector3) {
gl.LoadIdentity()
// gl.Translatef( -1.5, 0.0, -6.0 )
gl.Translatef( gl.GLfloat(v.X), gl.GLfloat(v.Y), gl.GLfloat(v.Z), )
/* Rotate The Triangle On The Y axis ( NEW ) */
gl.Rotatef( rtri, 0.0, 1.0, 0.0 );
gl.Begin( gl.TRIANGLES ); /* Drawing Using Triangles */
gl.Color3f( 1.0, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, 1.0, 0.0 ); /* Top Of Triangle (Front) */
gl.Color3f( 0.0, 1.0, 0.0 ); /* Green */
gl.Vertex3f( -1.0, -1.0, 1.0 ); /* Left Of Triangle (Front) */
gl.Color3f( 0.0, 0.0, 1.0 ); /* Blue */
gl.Vertex3f( 1.0, -1.0, 1.0 ); /* Right Of Triangle (Front) */
gl.Color3f( 1.0, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, 1.0, 0.0 ); /* Top Of Triangle (Right) */
gl.Color3f( 0.0, 0.0, 1.0 ); /* Blue */
gl.Vertex3f( 1.0, -1.0, 1.0 ); /* Left Of Triangle (Right) */
gl.Color3f( 0.0, 1.0, 0.0 ); /* Green */
gl.Vertex3f( 1.0, -1.0, -1.0 ); /* Right Of Triangle (Right) */
gl.Color3f( 1.0, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, 1.0, 0.0 ); /* Top Of Triangle (Back) */
gl.Color3f( 0.0, 1.0, 0.0 ); /* Green */
gl.Vertex3f( 1.0, -1.0, -1.0 ); /* Left Of Triangle (Back) */
gl.Color3f( 0.0, 0.0, 1.0 ); /* Blue */
gl.Vertex3f( -1.0, -1.0, -1.0 ); /* Right Of Triangle (Back) */
gl.Color3f( 1.0, 0.0, 0.0 ); /* Red */
gl.Vertex3f( 0.0, 1.0, 0.0 ); /* Top Of Triangle (Left) */
gl.Color3f( 0.0, 0.0, 1.0 ); /* Blue */
gl.Vertex3f( -1.0, -1.0, -1.0 ); /* Left Of Triangle (Left) */
gl.Color3f( 0.0, 1.0, 0.0 ); /* Green */
gl.Vertex3f( -1.0, -1.0, 1.0 ); /* Right Of Triangle (Left) */
gl.End( ); /* Finished Drawing The Triangle */
rtri = rtri + 0.2;
return
/* Move Right 3 Units */
gl.LoadIdentity( );
gl.Translatef( 1.5, 0.0, -6.0 );
/* Rotate The Quad On The X axis ( NEW ) */
gl.Rotatef( rquad, 1.0, 0.0, 0.0 );
/* Set The Color To Blue One Time Only */
gl.Color3f( 0.5, 0.5, 1.0);
gl.Begin( gl.QUADS ); /* Draw A Quad */
gl.Color3f( 0.0, 1.0, 0.0 ); /* Set The Color To Green */
gl.Vertex3f( 1.0, 1.0, -1.0 ); /* Top Right Of The Quad (Top) */
gl.Vertex3f( -1.0, 1.0, -1.0 ); /* Top Left Of The Quad (Top) */
gl.Vertex3f( -1.0, 1.0, 1.0 ); /* Bottom Left Of The Quad (Top) */
gl.Vertex3f( 1.0, 1.0, 1.0 ); /* Bottom Right Of The Quad (Top) */
gl.Color3f( 1.0, 0.5, 0.0 ); /* Set The Color To Orange */
gl.Vertex3f( 1.0, -1.0, 1.0 ); /* Top Right Of The Quad (Botm) */
gl.Vertex3f( -1.0, -1.0, 1.0 ); /* Top Left Of The Quad (Botm) */
gl.Vertex3f( -1.0, -1.0, -1.0 ); /* Bottom Left Of The Quad (Botm) */
gl.Vertex3f( 1.0, -1.0, -1.0 ); /* Bottom Right Of The Quad (Botm) */
gl.Color3f( 1.0, 0.0, 0.0 ); /* Set The Color To Red */
gl.Vertex3f( 1.0, 1.0, 1.0 ); /* Top Right Of The Quad (Front) */
gl.Vertex3f( -1.0, 1.0, 1.0 ); /* Top Left Of The Quad (Front) */
gl.Vertex3f( -1.0, -1.0, 1.0 ); /* Bottom Left Of The Quad (Front) */
gl.Vertex3f( 1.0, -1.0, 1.0 ); /* Bottom Right Of The Quad (Front) */
gl.Color3f( 1.0, 1.0, 0.0 ); /* Set The Color To Yellow */
gl.Vertex3f( 1.0, -1.0, -1.0 ); /* Bottom Left Of The Quad (Back) */
gl.Vertex3f( -1.0, -1.0, -1.0 ); /* Bottom Right Of The Quad (Back) */
gl.Vertex3f( -1.0, 1.0, -1.0 ); /* Top Right Of The Quad (Back) */
gl.Vertex3f( 1.0, 1.0, -1.0 ); /* Top Left Of The Quad (Back) */
gl.Color3f( 0.0, 0.0, 1.0 ); /* Set The Color To Blue */
gl.Vertex3f( -1.0, 1.0, 1.0 ); /* Top Right Of The Quad (Left) */
gl.Vertex3f( -1.0, 1.0, -1.0 ); /* Top Left Of The Quad (Left) */
gl.Vertex3f( -1.0, -1.0, -1.0 ); /* Bottom Left Of The Quad (Left) */
gl.Vertex3f( -1.0, -1.0, 1.0 ); /* Bottom Right Of The Quad (Left) */
gl.Color3f( 1.0, 0.0, 1.0 ); /* Set The Color To Violet */
gl.Vertex3f( 1.0, 1.0, -1.0 ); /* Top Right Of The Quad (Right) */
gl.Vertex3f( 1.0, 1.0, 1.0 ); /* Top Left Of The Quad (Right) */
gl.Vertex3f( 1.0, -1.0, 1.0 ); /* Bottom Left Of The Quad (Right) */
gl.Vertex3f( 1.0, -1.0, -1.0 ); /* Bottom Right Of The Quad (Right) */
gl.End( ); /* Done Drawing The Quad */
rquad -= 0.15;
}