fix perspective matrix computation

This commit is contained in:
Renaud Casenave-Péré 2014-10-30 21:42:28 +09:00
parent 3de90e7618
commit a8d4f11193

View file

@ -54,14 +54,18 @@
mat)))))
(defun calc-frustum-scale (fovy)
(/ 1.0 (tan (/ (maths:deg-to-rad fovy) 2.0))))
(tan (/ (maths:deg-to-rad fovy) 2.0)))
(defun make-persp-matrix (fovy aspect near far)
(let ((frustum-scale (calc-frustum-scale fovy)))
(f44:mat frustum-scale 0.0 0.0 0.0
0.0 (/ frustum-scale aspect) 0.0 0.0
(let ((range (calc-frustum-scale fovy)))
(let ((left (* (- range) aspect))
(right (* range aspect))
(bottom (- range))
(top range))
(f44:mat (/ (* near 2) (- right left)) 0.0 0.0 0.0
0.0 (/ (* near 2) (- top bottom)) 0.0 0.0
0.0 0.0 (/ (+ far near) (- near far)) -1.0
0.0 0.0 (/ (* 2.0 far near) (- near far)) 0.0)))
0.0 0.0 (/ (* 2.0 far near) (- near far)) 0.0))))
(defun make-ortho-matrix (width height)
(f44:mat (/ 2.0 width) 0.0 0.0 -1.0