Add tags

Add tags to the following comment

普通ピラミッドって言ったら4角錐でしょう。

実行例:

% gosh pyramid.scm 5

※ a, sで回転、z, xでズームイン・ズームアウトします。ESC で終了です

 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
(use gl)
(use gl.glut)

(define *height* #f)
(define *size* #f)
(define *theta* 0)

(define (init h)
  (gl-clear-color 0.0 0.0 0.0 0.0)
  (gl-shade-model GL_FLAT)
  (set! *height* h)
  (set! *size* (* h 6.0)))

(define (draw-asterisk x y z)
  (gl-push-matrix)
  (gl-translate x y z)
  (gl-begin* GL_LINES
    (for-each gl-vertex (list '#f32( 0.0  0.45) '#f32( 0.0  -0.45)
                              '#f32( 0.45 0.0 ) '#f32(-0.45  0.0)
                              '#f32( 0.3  0.3 ) '#f32(-0.3  -0.3)
                              '#f32(-0.3  0.3 ) '#f32( 0.3  -0.3))))
  (gl-pop-matrix))

(define (disp)
  (gl-clear GL_COLOR_BUFFER_BIT)
  (gl-matrix-mode GL_PROJECTION)
  (gl-load-identity)
  (gl-frustum -0.5 0.5 -0.5 0.5 1 (* 2 *size*))
  (let ((rad (* *theta* 0.0175))
        (l (/ *size* 2)))
    (glu-look-at (* l (sin rad)) 0.0 (* l (cos rad)) 0.0 0.0 0.0 0.0 1.0 0.0))
  (gl-matrix-mode GL_MODELVIEW)
  (gl-load-identity)
  (gl-color #f32(1.0 1.0 1.0))
  (do ((x (/ (- *height* 1) 2.0) (- x 1.0))
       (n 0 (+ n 1)))
      ((<= *height* n))
    (do ((y (- n) (+ y 1.0)))
        ((< n y))
      (do ((z (- n) (+ z 1.0)))
          ((< n z))
        (draw-asterisk (* x 2) y z))))
  (gl-flush))

(define (reshape w h)
  (gl-viewport 0 0 w h))

(define (keyboard key x y)
  (case key
    ((27) (exit 0))
    ((97) (dec! *theta* 10))
    ((115) (inc! *theta* 10))
    ((122) (when (< 0 *size*)
             (dec! *size* 1)))
    ((120) (inc! *size* 1)))
  (glut-post-redisplay))

(define (main args)
  (glut-init args)
  (glut-init-display-mode (logior GLUT_SINGLE GLUT_RGB))
  (glut-init-window-size 400 400)
  (glut-create-window "Pyramid")
  (init (x->integer (ref args 1)))
  (glut-display-func disp)
  (glut-reshape-func reshape)
  (glut-keyboard-func keyboard)
  (glut-main-loop)
  0)

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...