-
Notifications
You must be signed in to change notification settings - Fork 1
/
earth_anti_alias.awk
79 lines (69 loc) · 1.46 KB
/
earth_anti_alias.awk
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
BEGIN {
extension("./awkgl.so", "dlload")
# X Y Wid Height
SetWindowPosSize(250, 50, 600, 450)
# Window Title
CreateWindow("AwkGL Demo Earth")
#(0-255) R G B
ClearColor(0, 0, 0)
ReshapeFunc("reshape")
DisplayFunc("display")
TimerFunc(30, "timer", 0)
KeyboardFunc("keyboard")
wire=0
Enable("POINT_SMOOTH")
Enable("LINE_SMOOTH")
MainLoop()
}
function keyboard(key, x, y)
{
switch (key) {
case " ":
wire = !wire
break
case "q":
case "Q":
case "\033":
print "exiting..."
exit
break
}
}
function reshape(width, height)
{
Viewport(0, 0, width, height)
MatrixMode("PROJECTION")
LoadIdentity()
Perspective(45, width/ height , 1, 2000)
LookAt(-70.0, 280.0, 70.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0)
MatrixMode("MODELVIEW")
LoadIdentity()
}
function timer(val)
{
moon_ang = moon_ang >= 357 ? 0 : moon_ang + 3
#PostRedisplay()
TimerFunc(30, "timer", 0)
}
function display()
{
ClearColor(0, 0, 0)
LoadIdentity()
DrawAxes(500)
Color(32, 32, 255)
if (wire) {
WireSphere(35.0, 24, 18) # Earth
} else {
SolidSphere(35.0, 24, 18) # Earth
}
PushMatrix()
Rotate(moon_ang, 0.0, 0.0, 1.0) # z軸周りにmoon_ang度回転
Translate(100.0, 0.0, 0.0) # x軸に60平行移動
Color(255, 255, 64)
if (wire) {
WireSphere(5.0, 18, 12) # Moon
} else {
SolidSphere(5.0, 18, 12) # Moon
}
PopMatrix()
}