jak-project/goal_src/jak3/engine/camera/cam-interface.gc
Hat Kid 5a8b4e81f9
decomp3: more engine stuff, support boxed stack arrays in compiler (#3424)
- `sync-info`
- `trajectory`
- `camera`
- `cam-update`
- `cam-states`
- `cam-states-dbg`
- `cam-master`
- `cam-layout`
- `cam-interface`
- `cam-combiner`

Closes #2016
2024-03-15 20:28:26 -04:00

111 lines
2.8 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: cam-interface.gc
;; name in dgo: cam-interface
;; dgos: GAME
;; DECOMP BEGINS
(defun position-in-front-of-camera! ((arg0 vector) (arg1 float) (arg2 float))
(vector-float*! arg0 (-> *math-camera* inv-camera-rot fvec) arg1)
(vector+float*! arg0 arg0 (-> *math-camera* inv-camera-rot uvec) arg2)
(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 fvec)))
(a1-3 (vector-float*! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot fvec) arg1))
)
(vector+! a1-3 a1-3 (-> *math-camera* trans))
(reverse-transform-point! arg0 a1-3 a2-1 arg2)
)
arg0
)
(defun matrix-local->world ((arg0 symbol) (arg1 symbol))
(if arg0
(-> *math-camera* inv-camera-rot-smooth)
(-> *math-camera* inv-camera-rot)
)
)
(defun matrix-world->local ((arg0 symbol) (arg1 object))
(-> *math-camera* camera-rot)
)
(define-perm *camera-dummy-vector* vector (vector-reset! (new 'global 'vector)))
(defun camera-pos ()
(cond
(*camera-combiner*
(-> *camera-combiner* trans)
)
(*math-camera*
(-> *math-camera* trans)
)
(else
*camera-dummy-vector*
)
)
)
(defun math-camera-pos ()
(-> *math-camera* trans)
)
(defun camera-matrix ()
(if *camera-combiner*
(-> *camera-combiner* inv-camera-rot)
(-> *math-camera* inv-camera-rot)
)
)
(defun math-camera-matrix ()
(-> *math-camera* inv-camera-rot)
)
(defun camera-angle ()
(let ((f0-0 (-> *math-camera* camera-rot rvec x))
(f1-0 (-> *math-camera* camera-rot rvec z))
)
(atan f1-0 f0-0)
)
)
;; WARN: Return type mismatch object vs symbol.
(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))
(the-as symbol (send-event *camera* 'teleport-to-transformq gp-0))
)
)
(defun camera-teleport-to-entity-named ((arg0 string))
(let* ((gp-0 (entity-by-name arg0))
(a0-3 (if (type? gp-0 entity-actor)
gp-0
)
)
)
(if a0-3
(camera-teleport-to-entity (the-as entity-actor a0-3))
(format #t "sorry, couldn't find an actor named '~S'~%" arg0)
)
)
0
(none)
)
(defun camera-teleport-to-location ((arg0 float) (arg1 float) (arg2 float))
(let ((v1-1 (new 'stack 'transformq)))
(set-vector! (-> v1-1 trans) (* 4096.0 arg0) (* 4096.0 arg1) (* 4096.0 arg2) 1.0)
(send-event *camera* 'teleport-to-transformq v1-1)
)
0
(none)
)