home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
model.tar
/
model-board-1
/
.#model-board-1.lisp.1.1
< prev
next >
Wrap
Lisp/Scheme
|
1995-07-24
|
6KB
|
199 lines
(in-package 'cme)
#|
(user::maybe-compile-file-load "~/cme/radius/model-board-1/model-board-1.lisp")
|#
(defparameter *model-board-1-path* "$CMEHOME/radius/model-board-1/")
(ic::ev-pathname-register *model-board-1-path*)
(defun merge-model-board-1-pathname (path)
(ic::ev-pathname-translate (format nil "~a~A" *model-board-1-path* path)))
(defparameter *model-board-1-image-path* "$CME/images/radius/model-board-1/")
(ic::ev-pathname-register "$CME/images/radius/")
(defun merge-model-board-1-image-pathname (path)
(format nil "~a~A" *model-board-1-image-path* path))
#|
(proclaim '(special *mb1-j1* *mb1-j2* *mb1-j1* *mb1-j3* *mb1-j4* *mb1-j5* *mb1-j6* *mb1-j7* *mb1-j8*))
;;; First Time Only Site Creation
;;; See the file $CMEHOME/radius/model-board-1/camera-models.lisp for control-point setup
(defparameter *mb1-3d-world*
(make-site :name "Radius Model Board 1"
:units :feet
:terrain-model (make-phoney-terrain-model -1600.0 -1000.0 40 40 -85.0 100.0)))
(setf (get-prop *mb1-3d-world* :terrain-model)
(make-phoney-terrain-model -1600.0 -1000.0 40 40 -85.0 100.0))
;;; ***************** READING GROUND CONTROL POINTS FILES *****************
;;; This is relatively generic,
;;; Other sites might define control points using the same file format.
(defvar *model-units-to-feet* (/ 500.0 12))
(defun read-control-points (path)
(with-open-file (st path)
(loop for line = (read-line st nil nil)
while line
for control-point
= (let* ((pos 0)
thing)
(flet ((read-number (&optional (scale *model-units-to-feet*))
(multiple-value-setq (thing pos) (read-from-string line nil nil :start pos))
(and (numberp thing) (* scale thing))))
(let ((control-point (list (read-number 1) (read-number) (read-number) (read-number)
(ic::substring line pos ))))
(when (cadr control-point)
control-point))))
when control-point collect control-point)))
(setf (get-prop *mb1-3d-world* :control-points) *mode
(read-control-points (merge-model-board-1-pathname "bd1gt.dat")))
(defparameter *mb1-image-symbol-path-list*
'((*mb1-j1* "j1.g" "j1" )
(*mb1-j2* "j2.g" "j2" )
(*mb1-j3* "j3.g" "j3" )
(*mb1-j4* "j4.g" "j4" )
(*mb1-j5* "j5.g" "j5" )
(*mb1-j6* "j6.g" "j6" )
(*mb1-j7* "j7.g" "j7" )
(*mb1-j8* "j8.g" "j8" )))
(defun load-mb1-images ()
(flet ((load-img (path name)
(let ((image-list
(ic::load-image-hierarchy (merge-model-board-1-image-pathname path) 0 0)))
(loop for img in image-list
do (setf (image-prop img :name) (format nil "MB1-~a" name)))
(car image-list))))
(loop for (symbol path name) in *mb1-image-symbol-path-list*
do (setf (symbol-value symbol) (load-img path name)))
))
(defun add-image-to-3d-world (image 3d-world )
(unless (image-prop image :image-to-2d-transform)
(setf (image-prop image :image-to-2d-transform) (make-coordinate-transform)))
(let ((image-name (get-prop image :name))
(2d-world (or (get-prop image :2d-world)
(make-instance '2d-world
:name (format nil "~a 2d World" image-name)
:base-image image
:3d-world 3d-world ))))
(setup-image-worlds image
:3d-to-2d-projection nil
:3d-world 3d-world
:2d-world 2d-world
)
image ))
(loop for (symbol) in *mb1-image-symbol-path-list*
do (add-image-to-3d-world (symbol-value symbol)
(get-3d-world-named "Radius Model Board 1") ))
;;; TO DEMONSTRATE CAMERA MODEL SETUP::
(add-image-to-3d-world (ic::copy-image *mb1-j8*) (get-3d-world-named "Radius Model Board 1"))
(let ((image (ic::copy-image *)))
(setf (get-prop image :name) "j8b")
(add-image-to-3d-world image (get-3d-world-named "Radius Model Board 1"))
image)
|#
#|
(defvar *mb1-3d-world* nil)
(defvar *mb1-cme-frame* nil)
(defun start-mb1-cme ()
(unless (and (boundp '*mb1-cme-frame*) *mb1-cme-frame*)
(initialize-cme)
(setq *mb1-cme-frame* (make-cme-frame "Model Board 1 2x2"))
)
(unless *mb1-3d-world*
(setq *mb1-3d-world* (load-site (merge-model-board-1-pathname "mb1.site"))))
(get-site-images *mb1-3d-world* *mb1-cme-frame*)
(unless ic::*inside-repl*
(ic::force-read-form '(in-package 'cme))
(ic::repl))
)
|#
;;(start-mb1-cme)
#|
(start-mb1-cme) ;;; ***************
(setq *mb1-3d-world* (load-site (merge-model-board-1-pathname "mb1.site")))
(get-site-images *mb1-3d-world* *mb1-cme-frame*)
(get-site-images (GET-3D-WORLD-NAMED '"Radius Model Board 1") )
(get-site-images *mb1-3d-world*)
(time (dump-site (3d-world (top-view))
(merge-model-board-1-pathname "mb1.site") :print-function 'pprint))
(load-site (merge-model-board-1-pathname "mb1.site"))
(setf (get-prop *mb1-3d-world* :control-points) *model-board-1-control-points*)
(setq *mb1-images*
(reverse
(loop for 2d-world in (2d-worlds (GET-3D-WORLD-NAMED '"Radius Model Board 1"))
for image = (base-image 2d-world)
when image collect image )))
(ic::display-image-sequence (selected-pane) *mb1-images* :pause .5 :REPEAT-COUNT 20 :delta-t 0)
(ic::display-image-sequence (selected-pane) *mb1-images* :interactive nil
:pause .5 :REPEAT-COUNT 2 :delta-t 0)
(progn *mb1-images*)
(length *mb1-images*)
|#
;;;================================================================================
;;; Set up sun vectors for Model Board imagery
;;;================================================================================
(defun tand (x)
(/ (cosd x) (sind x)))
(defun set-sun-ray-of-2d-world (2d-world sun-az sun-el)
(let ((sun-vector (list-vector
(normalize-coordinate-vector
(position-to-vector
`(,(cosd sun-az) ,(sind sun-az) ,(tand sun-el)))))))
(loop for image in (image-list 2d-world)
do
(setf (sun-vector image) sun-vector))
(setf (sun-vector (base-image 2d-world )) sun-vector)
2d-world ))
(set-sun-ray-of-2d-world (get-2d-world-named "MB1-j1 2d World") 40 27)
(set-sun-ray-of-2d-world (get-2d-world-named "MB1-j2 2d World") 320 30)
(set-sun-ray-of-2d-world (get-2d-world-named "MB1-j3 2d World") 60 48)
(set-sun-ray-of-2d-world (get-2d-world-named "MB1-j4 2d World") 140 42)
(set-sun-ray-of-2d-world (get-2d-world-named "MB1-j5 2d World") 140 42)
(set-sun-ray-of-2d-world (get-2d-world-named "MB1-j6 2d World") 140 50)
(set-sun-ray-of-2d-world (get-2d-world-named "MB1-j7 2d World") 140 50)
(set-sun-ray-of-2d-world (get-2d-world-named "MB1-j8 2d World") 240 45))