]> git.jsancho.org Git - guile-assimp.git/blobdiff - src/assimp.scm
New struct types ai-matrix3x3 and ai-matrix4x4
[guile-assimp.git] / src / assimp.scm
index 5c8ccd2b99df311616aa3d2eb292d1be4e818ad2..9954e8212bcb47cab6f070bc22e4f80654e091bb 100644 (file)
@@ -20,6 +20,7 @@
   #:use-module (assimp low-level cimport)
   #:use-module (assimp low-level color)
   #:use-module (assimp low-level material)
+  #:use-module (assimp low-level matrix)
   #:use-module (assimp low-level mesh)
   #:use-module (assimp low-level scene)
   #:use-module (assimp low-level types)
@@ -55,7 +56,7 @@
 
 (define-conversion-type parse-aiNode -> ai-node
   (name (sized-string (field 'mName)))
-  (transformation (field 'mTransformation))
+  (transformation (wrap (parse-aiMatrix4x4 (field 'mTransformation) #:reverse #t) wrap-ai-matrix4x4))
   (parent (wrap (field 'mParent) wrap-ai-node))
   (children (wrap (array (field 'mNumChildren) (field 'mChildren)) wrap-ai-node))
   (meshes (array (field 'mNumMeshes) (field 'mMeshes))))
        ai-vector3d-z)
 
 
+;;; Matrixes
+
+(define-conversion-type parse-aiMatrix3x3 -> ai-matrix3x3
+  (a1 (field 'a1))
+  (a2 (field 'a2))
+  (a3 (field 'a3))
+  (b1 (field 'b1))
+  (b2 (field 'b2))
+  (b3 (field 'b3))
+  (c1 (field 'c1))
+  (c2 (field 'c2))
+  (c3 (field 'c3)))
+
+(export ai-matrix3x3?
+       ai-matrix3x3-contents
+       ai-matrix3x3-a1
+       ai-matrix3x3-a2
+       ai-matrix3x3-a3
+       ai-matrix3x3-b1
+       ai-matrix3x3-b2
+       ai-matrix3x3-b3
+       ai-matrix3x3-c1
+       ai-matrix3x3-c2
+       ai-matrix3x3-c3)
+
+(define-conversion-type parse-aiMatrix4x4 -> ai-matrix4x4
+  (a1 (field 'a1))
+  (a2 (field 'a2))
+  (a3 (field 'a3))
+  (a4 (field 'a4))
+  (b1 (field 'b1))
+  (b2 (field 'b2))
+  (b3 (field 'b3))
+  (b4 (field 'b4))
+  (c1 (field 'c1))
+  (c2 (field 'c2))
+  (c3 (field 'c3))
+  (c4 (field 'c4))
+  (d1 (field 'd1))
+  (d2 (field 'd2))
+  (d3 (field 'd3))
+  (d4 (field 'd4)))
+
+(export ai-matrix4x4?
+       ai-matrix4x4-contents
+       ai-matrix4x4-a1
+       ai-matrix4x4-a2
+       ai-matrix4x4-a3
+       ai-matrix4x4-a4
+       ai-matrix4x4-b1
+       ai-matrix4x4-b2
+       ai-matrix4x4-b3
+       ai-matrix4x4-b4
+       ai-matrix4x4-c1
+       ai-matrix4x4-c2
+       ai-matrix4x4-c3
+       ai-matrix4x4-c4
+       ai-matrix4x4-d1
+       ai-matrix4x4-d2
+       ai-matrix4x4-d3
+       ai-matrix4x4-d4)
+
+
 ;;; Colors
 
 (define-conversion-type parse-aiColor4D -> ai-color4d
   (weights (wrap
            (array (field 'mNumWeights) (field 'mWeights) #:element-size 8 #:element-proc get-element-address)
            wrap-ai-vertex-weight))
-  (offset-matrix (field 'mOffsetMatrix)))
+  (offset-matrix (wrap (parse-aiMatrix4x4 (field 'mOffsetMatrix) #:reverse #t) wrap-ai-matrix4x4)))
 
 (export ai-bone?
        ai-bone-contents
                 flags)))
 
 (define-public (ai-multiply-matrix4 m1 m2)
-  (let ((cm1 (make-c-struct aiMatrix4x4-type m1))
-       (cm2 (make-c-struct aiMatrix4x4-type m2)))
+  (let ((cm1 (parse-aiMatrix4x4 (map cdr (ai-matrix4x4-contents m1)) #:reverse #t))
+       (cm2 (parse-aiMatrix4x4 (map cdr (ai-matrix4x4-contents m2)) #:reverse #t)))
     (aiMultiplyMatrix4 cm1 cm2)
-    (parse-c-struct cm1 aiMatrix4x4-type)))
+    (wrap-ai-matrix4x4 cm1)))