mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
d264779173
* d/jak2: finish `glist` and `glist-h` partially done `time-of-day` * d/jak2: finish `camera` and `cam-interface` * d/jak2: partially finish `cam-master` `cam-states`, and `cam-update` finish `cam-states-dbg` `cam-combiner` `cam-debug` and `cam-start` * tests: update ref tests * scripts: add scripts to automatically update gsrc files * d/jak2: update gsrc
123 lines
3.2 KiB
Common Lisp
123 lines
3.2 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: cam-interface.gc
|
|
;; name in dgo: cam-interface
|
|
;; dgos: ENGINE, GAME
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(defun position-in-front-of-camera! ((arg0 vector) (arg1 float) (arg2 float))
|
|
(rlet ((acc :class vf)
|
|
(vf0 :class vf)
|
|
(vf1 :class vf)
|
|
(vf2 :class vf)
|
|
(vf3 :class vf)
|
|
(vf4 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(vector-float*! arg0 (-> *math-camera* inv-camera-rot vector 2) arg1)
|
|
(let ((v1-2 arg0))
|
|
(let ((a1-1 arg0)
|
|
(a3-3 (-> *math-camera* inv-camera-rot vector 1))
|
|
(f0-1 arg2)
|
|
)
|
|
(.lvf vf2 (&-> a3-3 quad))
|
|
(.lvf vf1 (&-> a1-1 quad))
|
|
(let ((a1-2 f0-1))
|
|
(.mov vf3 a1-2)
|
|
)
|
|
)
|
|
(.add.x.vf vf4 vf0 vf0 :mask #b1000)
|
|
(.mul.x.vf acc vf2 vf3)
|
|
(.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111)
|
|
(.svf (&-> v1-2 quad) vf4)
|
|
)
|
|
(vector+! arg0 arg0 (-> *math-camera* trans))
|
|
arg0
|
|
)
|
|
)
|
|
|
|
(defun position-in-front-of-screen! ((arg0 vector) (arg1 float) (arg2 vector))
|
|
(let ((a2-1 (vector-negate! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot vector 2)))
|
|
(a1-3 (vector-float*! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot vector 2) arg1))
|
|
)
|
|
(vector+! (the-as vector a1-3) (the-as vector a1-3) (-> *math-camera* trans))
|
|
(reverse-transform-point! arg0 (the-as vector a1-3) a2-1 arg2)
|
|
)
|
|
arg0
|
|
)
|
|
|
|
(defun matrix-local->world ((smooth? symbol))
|
|
"Returns [[*math-camera*]]'s `inv-camera-rot-smooth` if `smooth?` is true, else return `inv-camera-rot`"
|
|
(if smooth?
|
|
(-> *math-camera* inv-camera-rot-smooth)
|
|
(-> *math-camera* inv-camera-rot)
|
|
)
|
|
)
|
|
|
|
(defun matrix-world->local ()
|
|
"Returns [[*math-camera*]]'s `camera-rot`"
|
|
(-> *math-camera* camera-rot)
|
|
)
|
|
|
|
(define-perm *camera-dummy-vector* vector (vector-reset! (new 'global 'vector)))
|
|
|
|
(defun camera-pos ()
|
|
"Returns the `trans` vector from whatever is first determined to exist:
|
|
- [[*camera-combiner*]]
|
|
- [[*math-camera*]]
|
|
- else, [[*camera-dummy-vector*]]"
|
|
(cond
|
|
(*camera-combiner*
|
|
(-> *camera-combiner* trans)
|
|
)
|
|
(*math-camera*
|
|
(-> *math-camera* trans)
|
|
)
|
|
(else
|
|
*camera-dummy-vector*
|
|
)
|
|
)
|
|
)
|
|
|
|
(defun math-camera-pos ()
|
|
"Returns [[*math-camera*]]'s `trans`"
|
|
(-> *math-camera* trans)
|
|
)
|
|
|
|
(defun camera-matrix ()
|
|
"If [[*camera-combiner*]] exists, return it's `inv-camera-rot`. Else, return [[*math-camera*]]'s"
|
|
(if *camera-combiner*
|
|
(-> *camera-combiner* inv-camera-rot)
|
|
(-> *math-camera* inv-camera-rot)
|
|
)
|
|
)
|
|
|
|
(defun math-camera-matrix ()
|
|
"Returns [[*math-camera*]]'s `inv-camera-rot`"
|
|
(-> *math-camera* inv-camera-rot)
|
|
)
|
|
|
|
(defun camera-angle ()
|
|
(let ((f0-0 (-> *math-camera* camera-rot vector 0 x))
|
|
(f1-0 (-> *math-camera* camera-rot vector 0 z))
|
|
)
|
|
(atan f1-0 f0-0)
|
|
)
|
|
)
|
|
|
|
(defbehavior camera-teleport-to-entity process ((arg0 entity-actor))
|
|
(let ((gp-0 (new 'stack 'transformq)))
|
|
(set! (-> gp-0 trans quad) (-> arg0 extra trans quad))
|
|
(quaternion-copy! (-> gp-0 quat) (-> arg0 quat))
|
|
(vector-identity! (-> gp-0 scale))
|
|
(send-event *camera* 'teleport-to-transformq gp-0)
|
|
)
|
|
(none)
|
|
)
|
|
|
|
|
|
|
|
|