diff --git a/math/matrix.lisp b/math/matrix.lisp index 5caa1b2..521c7f8 100644 --- a/math/matrix.lisp +++ b/math/matrix.lisp @@ -27,6 +27,10 @@ (make-instance 'mat4 :value (m4:rotation-from-euler (v3:make x y z)))) +(definline rotation-mat4-from-euler-axis (a vec3) + (make-instance 'mat4 :value (m4:rotation-from-axis-angle (value-of vec3) a))) + + (definline rotation-mat4 (vec) (make-instance 'mat4 :value (m4:rotation-from-euler (value-of vec)))) diff --git a/math/vector.lisp b/math/vector.lisp index 0dce2f8..ee3dc7a 100644 --- a/math/vector.lisp +++ b/math/vector.lisp @@ -28,19 +28,21 @@ (defun vref (vec idx) - (ecase idx - (0 (v:x vec)) - (1 (v:y vec)) - (2 (v:z vec)) - (3 (v:w vec)))) + (let ((vec (value-of vec))) + (ecase idx + (0 (v:x vec)) + (1 (v:y vec)) + (2 (v:z vec)) + (3 (v:w vec))))) (defun (setf vref) (value vec idx) - (ecase idx - (0 (setf (v:x vec) value)) - (1 (setf (v:y vec) value)) - (2 (setf (v:z vec) value)) - (3 (setf (v:w vec) value)))) + (let ((vec (value-of vec))) + (ecase idx + (0 (setf (v:x vec) value)) + (1 (setf (v:y vec) value)) + (2 (setf (v:z vec) value)) + (3 (setf (v:w vec) value))))) (defmethod summarize ((this vec3) (that vec3)) diff --git a/packages.lisp b/packages.lisp index 51a3f6d..6547984 100644 --- a/packages.lisp +++ b/packages.lisp @@ -133,6 +133,7 @@ identity-mat4 rotation-mat4 rotation-mat4* + rotation-mat4-from-euler-axis translation-mat4 translation-mat4* scaling-mat4* @@ -352,7 +353,12 @@ mesh-chunk-id mesh-chunk-face mesh-chunk-arrays - mesh-chunk-indexes)) + mesh-chunk-indexes + + skeleton-chunks-of + skeleton-children + skeleton-bone-children + skeleton-bone-transform)) (defpackage :cl-bodge.animation diff --git a/resources/basic-chunks.lisp b/resources/basic-chunks.lisp index 4fec582..caebb82 100644 --- a/resources/basic-chunks.lisp +++ b/resources/basic-chunks.lisp @@ -32,3 +32,22 @@ (defun text-shader-chunks-of (resource) (chunks-by-type resource :text-shader)) + + +;;; +;;; +;;; + +(define-chunk-structure (skeleton-bone t skeleton-bone) + transform) + + +(define-chunk-structure (skeleton-chunk t skeleton-bone)) + + +(defmethod parse-chunk ((this (eql :skeleton)) params data) + (make-skeleton-chunk data)) + + +(defun skeleton-chunks-of (resource) + (chunks-by-type resource :skeleton)) diff --git a/scene/transformations.lisp b/scene/transformations.lisp index 2eca561..a4e9356 100644 --- a/scene/transformations.lisp +++ b/scene/transformations.lisp @@ -79,7 +79,7 @@ ;;; ;;; -;;;c +;;; (defclass body-transform-node (node) ((position :initform (make-vec3*)) (rotation :initform (identity-mat4))