Created
November 8, 2009 18:43
-
-
Save making/229420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmethod diagonal ((box <body>)) | |
(let ((vertices (vertices-of box)) | |
(max-point (make-float-vector 3)) | |
(min-point (make-float-vector 3)) | |
) | |
(copy-vector (car vertices) max-point) | |
(copy-vector (car vertices) min-point) | |
(dolist (v (cdr vertices)) | |
(dotimes (i 3) | |
(when (> (aref v i) (aref max-point i)) | |
(setf (aref max-point i) (aref v i)) | |
) | |
(when (< (aref v i) (aref min-point i)) | |
(setf (aref min-point i) (aref v i)) | |
) | |
) | |
) | |
(v- max-point min-point) | |
) | |
) | |
(defmethod look-all ((win <komainu-viewer>) | |
&optional (bounding-box | |
(make-bounding-box | |
(flatten (mapcar #'(lambda (o) | |
(if (typep o '<body>) (world-vertices-of o)) | |
) | |
(objects-of win)) | |
) | |
))) | |
(when bounding-box | |
(let* ((vt (pos-of (coords-of bounding-box))) | |
(vp (scale (/ (apply #'max (coerce (diagonal bounding-box) 'cons)) | |
;; (* 0.5 (tan (deg2rad (up-down-angle-of win))))) ;; view-angle的なものはどうとる? | |
(* 0.5 (tan (deg2rad 30.0)))) | |
(normalize-vector (v- (viewpoint-of win) vt)))) | |
) | |
(setf (viewtarget-of win) vt) | |
(setf (viewpoint-of win) vp) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment