mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
b74399ed57
* move files * update game.gp
118 lines
5.4 KiB
Common Lisp
118 lines
5.4 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: math-camera-h.gc
|
|
;; name in dgo: math-camera-h
|
|
;; dgos: GAME, ENGINE
|
|
|
|
;; The "math-camera" is responsible for computing the projection matrix used in the renderer
|
|
;; from the position of the in-game camera. It also computes some other common camera info.
|
|
;; See cam-update.gc for how the game camera updates the math-camera.
|
|
|
|
;; It also contains some GIF stuff, but these seem to be wrong/unused.
|
|
;; Some of the code here may be extremely old and unused, but this does compute the camera projection
|
|
;; matrix used almost everywhere.
|
|
|
|
(deftype vis-gif-tag (structure)
|
|
((fog0 uint32 :offset-assert 0)
|
|
(strip uint32 :offset-assert 4)
|
|
(regs uint32 :offset-assert 8)
|
|
(fan uint32 :offset-assert 12)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x10
|
|
:flag-assert #x900000010
|
|
)
|
|
|
|
|
|
(deftype cull-info (structure)
|
|
((x-fact float :offset-assert 0)
|
|
(y-fact float :offset-assert 4)
|
|
(z-fact float :offset-assert 8)
|
|
(cam-radius float :offset-assert 12)
|
|
(cam-x float :offset-assert 16)
|
|
(cam-y float :offset-assert 20)
|
|
(xz-dir-ax float :offset-assert 24)
|
|
(xz-dir-az float :offset-assert 28)
|
|
(xz-dir-bx float :offset-assert 32)
|
|
(xz-dir-bz float :offset-assert 36)
|
|
(xz-cross-ab float :offset-assert 40)
|
|
(yz-dir-ay float :offset-assert 44)
|
|
(yz-dir-az float :offset-assert 48)
|
|
(yz-dir-by float :offset-assert 52)
|
|
(yz-dir-bz float :offset-assert 56)
|
|
(yz-cross-ab float :offset-assert 60)
|
|
)
|
|
:pack-me
|
|
:method-count-assert 9
|
|
:size-assert #x40
|
|
:flag-assert #x900000040
|
|
)
|
|
|
|
(deftype math-camera (basic)
|
|
((d meters :offset-assert 4) ;; camera near plane
|
|
(f meters :offset-assert 8) ;; camera far plane
|
|
(fov degrees :offset-assert 12) ;; field of view angle
|
|
|
|
;; view frustum
|
|
(x-ratio float :offset-assert 16)
|
|
(y-ratio float :offset-assert 20)
|
|
(x-pix float :offset-assert 24)
|
|
(x-clip float :offset-assert 28)
|
|
(x-clip-ratio-in float :offset-assert 32)
|
|
(x-clip-ratio-over float :offset-assert 36)
|
|
(y-pix float :offset-assert 40)
|
|
(y-clip float :offset-assert 44)
|
|
(y-clip-ratio-in float :offset-assert 48)
|
|
(y-clip-ratio-over float :offset-assert 52)
|
|
(cull-info cull-info :inline :offset-assert 56)
|
|
(fog-start meters :offset-assert 120)
|
|
(fog-end meters :offset-assert 124)
|
|
(fog-max float :offset-assert 128)
|
|
(fog-min float :offset-assert 132)
|
|
(reset int32 :offset-assert 136)
|
|
(smooth-step float :offset-assert 140)
|
|
(smooth-t float :offset-assert 144)
|
|
(perspective matrix :inline :offset-assert 160)
|
|
(isometric matrix :inline :offset-assert 224)
|
|
(sprite-2d matrix :inline :offset-assert 288)
|
|
(sprite-2d-hvdf vector :inline :offset-assert 352)
|
|
(camera-rot matrix :inline :offset-assert 368)
|
|
(inv-camera-rot matrix :inline :offset-assert 432)
|
|
(inv-camera-rot-smooth matrix :inline :offset-assert 496)
|
|
(inv-camera-rot-smooth-from quaternion :inline :offset-assert 560)
|
|
;; this camera-temp is the main matrix used for renderers.
|
|
;; the camera code will set this.
|
|
;; it's designed so the renderers can do a single matrix-vector multiply
|
|
;; and then get fog, clipping, and final vertex position from the result.
|
|
(camera-temp matrix :inline :offset-assert 576)
|
|
(prev-camera-temp matrix :inline :offset-assert 640)
|
|
(hmge-scale vector :inline :offset-assert 704)
|
|
(inv-hmge-scale vector :inline :offset-assert 720)
|
|
(hvdf-off vector :inline :offset-assert 736)
|
|
(guard vector :inline :offset-assert 752)
|
|
(vis-gifs vis-gif-tag 4 :inline :offset-assert 768)
|
|
(vis-gifs-quads uint128 4 :offset 768) ;; added
|
|
(giftex vis-gif-tag :offset 768)
|
|
(gifgr vis-gif-tag :offset 784)
|
|
(giftex-trans vis-gif-tag :offset 800)
|
|
(gifgr-trans vis-gif-tag :offset 816)
|
|
(pfog0 float :offset-assert 832)
|
|
(pfog1 float :offset-assert 836)
|
|
(trans vector :inline :offset-assert 848)
|
|
(plane plane 4 :inline :offset-assert 864)
|
|
(guard-plane plane 4 :inline :offset-assert 928)
|
|
(shrub-mat matrix :inline :offset-assert 992)
|
|
(fov-correction-factor float :offset-assert 1056)
|
|
)
|
|
(:methods
|
|
(new (symbol type) _type_ 0)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x424
|
|
:flag-assert #x900000424
|
|
)
|
|
|
|
|
|
(define-extern *math-camera* math-camera)
|