next up previous
Next: 4.3 ハノイの塔の操作 sample/hanoimanipulation.l Up: 4 物体操作の記述 Previous: 4.1 eus/lib/llib/animation.l

4.2 アニメーションの例 demo7.l


(defun harm nil
  (send sarm :worldcoords)
  (send-all (sarm . components) :worldcoords)
  (hid sarmbodies))
(defun darm nil 
  (send sarm :worldcoords)
  (send-all (sarm . components) :worldcoords)
  (draw sarmbodies))

(setq disk-a (make-cylinder 12 20))
(setq disk-b (make-cylinder 21 20))
(setq disk-c (make-cylinder 30 20))
(send disk-a :locate #f(0 0 40.1))
(send disk-b :locate #f(0 0 20.05))
(setq disks (list disk-a disk-b disk-c))
(send-all disks :worldcoords)
(send disk-b :assoc disk-a)
(send disk-c :assoc disk-b)
(send disk-c :locate #f(300 200 210))

(defun hanoi-table (&optional (pos (float-vector 0 0 0)))
  (let ((b (make-cylinder 30 200))
        (c (make-cube 80 80 4)))
    (send c :locate #f(0 0 200))
    (setq c (body+ c b))
    (send c :locate pos)
    c
    ))

(setq table1 (hanoi-table #f(300 200 0)))
(setq table2 (hanoi-table #f(400 0 0)))
(setq table3 (hanoi-table #f(300 -200 0)))

(setq tables (list table1 table2 table3))
(setq worlds (append sarmbodies disks tables))

(defun dworld nil
  (send sarm :worldcoords)
  (send-all (sarm . components) :worldcoords)
  (draw worlds))
(defun hworld nil
  (send sarm :worldcoords)
  (send-all (sarm . components) :worldcoords)
  (hid worlds))

(eval-when (eval load)
  (hworld)
  )
(require :animation "llib/animation")

(defun move-sarm (h)
  (send sarm
        :translate
        (float-vector h (- h) (/ (- h) 2.0)))
  ;;  (send sarm :rotate -0.1 :y)
  (cls)
  (hid sarm))

(defun sanim nil
  (setq sarmanim 
        (hid-lines-animation
         20 (move-sarm 15))))

(setq sarmanim (sanim))

#|
(loop 
   (if (y-or-n-p "playback ")
       (playback-hid-lines sarmanim)
     (return nil)))
|#


generated through LaTeX2HTML. M.Inaba 平成18年5月7日