Skip to content

Instantly share code, notes, and snippets.

@making
Created November 8, 2009 18:43
Show Gist options
  • Save making/229420 to your computer and use it in GitHub Desktop.
Save making/229420 to your computer and use it in GitHub Desktop.
(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