Files
jak-project/goal_src/jak3/engine/math/transform.gc
T
Hat Kid 9a4929ac0c decomp3: some engine files (#3319)
- `vector-h`
- `gravity-h`
- `bounding-box-h`
- `matrix-h`
- `quaternion-h`
- `euler-h`
- `transform-h`
- `geometry-h`
- `trigonometry-h`
- `transformq-h`
- `bounding-box`
- `matrix`
- `matrix-compose`
- `transform`
- `quaternion`
- `euler`
- `trigonometry`

Not a whole lot of changes, just a couple of new functions and one new
file (`matrix-compose`).
2024-01-20 10:42:51 -05:00

69 lines
2.2 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: transform.gc
;; name in dgo: transform
;; dgos: GAME
;; DECOMP BEGINS
(defmethod print ((this transform))
(format #t "#<transform @ #x~X~%" this)
(format #t "~T~Ttrans:~F ~F ~F ~F ~%" (-> this trans x) (-> this trans y) (-> this trans z) (-> this trans w))
(format #t "~T~Trot: ~F ~F ~F ~F ~%" (-> this rot x) (-> this rot y) (-> this rot z) (-> this rot w))
(format #t "~T~Tscale:~F ~F ~F ~F>" (-> this scale x) (-> this scale y) (-> this scale z) (-> this scale w))
this
)
(defmethod new trs ((allocation symbol) (type-to-make type))
(let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
(set! (-> gp-0 trans w) 1.0)
(set! (-> gp-0 rot w) 1.0)
(vector-identity! (-> gp-0 scale))
gp-0
)
)
(defun transform-matrix-calc! ((arg0 transform) (arg1 matrix))
"Convert a transform to matrix. Not efficient, and the output is the second arg."
(let ((s4-0 (new-stack-matrix0))
(s3-0 (new-stack-matrix0))
)
(matrix-identity! arg1)
(matrix-translate! arg1 (-> arg0 trans))
(matrix-rotate-y! s4-0 (-> arg0 rot y))
(matrix*! s3-0 s4-0 arg1)
(matrix-rotate-x! s4-0 (-> arg0 rot x))
(matrix*! arg1 s4-0 s3-0)
(matrix-rotate-z! s4-0 (-> arg0 rot z))
(matrix*! s3-0 s4-0 arg1)
(matrix-scale! s4-0 (-> arg0 scale))
(matrix*! arg1 s4-0 s3-0)
)
)
(defun transform-matrix-parent-calc! ((arg0 transform) (arg1 matrix) (arg2 vector))
"Convert a transform to a matrix, applying an inverse scaling."
(let ((s4-0 (new-stack-matrix0))
(s3-0 (new-stack-matrix0))
)
(matrix-identity! s3-0)
(matrix-translate! s3-0 (-> arg0 trans))
(matrix-inv-scale! s4-0 arg2)
(matrix*! arg1 s4-0 s3-0)
(matrix-rotate-y! s4-0 (-> arg0 rot y))
(matrix*! s3-0 s4-0 arg1)
(matrix-rotate-x! s4-0 (-> arg0 rot x))
(matrix*! arg1 s4-0 s3-0)
(matrix-rotate-z! s4-0 (-> arg0 rot z))
(matrix*! s3-0 s4-0 arg1)
(matrix-scale! s4-0 (-> arg0 scale))
(matrix*! arg1 s4-0 s3-0)
)
)
(defun trs-matrix-calc! ((arg0 trs) (arg1 matrix))
"Convert a trs to a matrix."
(transform-matrix-calc! (the-as transform (-> arg0 trans)) arg1)
)