From 21dab003aaf4e3d42bf5a7c2fe8a64e1fcec6192 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 30 Jul 2014 13:06:25 +0200 Subject: [PATCH] More functions from original library * src/assimp.scm: New functions: ai-release-import ai-attach-predefined-log-stream ai-detach-all-log-streams Bug resolved with size of vertices structs when wrapping meshes. * src/low-level/cimport.scm: New foreign function supported: aiReleaseImport aiGetPredefinedLogStream aiAttachLogStream aiDetachAllLogStreams * src/low-level/types.scm: New enumeration ai-default-log-stream --- src/assimp.scm | 43 ++++++++++++++++++++++++++++++--------- src/low-level/cimport.scm | 9 ++++++++ src/low-level/types.scm | 18 +++++++++++++--- 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/src/assimp.scm b/src/assimp.scm index dad5634..fcb9492 100644 --- a/src/assimp.scm +++ b/src/assimp.scm @@ -27,12 +27,24 @@ #:use-module (assimp low-level types) #:use-module (assimp low-level vector) #:use-module (system foreign) + #:export (ai-import-file + ai-release-import + ai-attach-predefined-log-stream + ai-transform-vec-by-matrix4 + ai-multiply-matrix3 + ai-multiply-matrix4 + ai-identity-matrix3 + ai-identity-matrix4 + ai-transpose-matrix3 + ai-transpose-matrix4) #:re-export (ai-material-key ai-process-steps ai-process-convert-to-left-handed ai-process-preset-target-realtime-fast ai-process-preset-target-realtime-quality - ai-process-preset-target-realtime-max-quality)) + ai-process-preset-target-realtime-max-quality + ai-default-log-stream + (aiDetachAllLogStreams . ai-detach-all-log-streams))) ;;; Scenes @@ -83,7 +95,7 @@ (name (sized-string (field 'mName))) (primitive-types (field 'mPrimitiveTypes)) (vertices (wrap - (array (field 'mNumVertices) (field 'mVertices) #:element-proc get-element-address) + (array (field 'mNumVertices) (field 'mVertices) #:element-size 12 #:element-proc get-element-address) wrap-ai-vector3d)) (faces (wrap (array (field 'mNumFaces) (field 'mFaces) #:element-size 8 #:element-proc get-element-address) @@ -319,45 +331,56 @@ ;;; Functions -(define-public (ai-import-file filename flags) +(define (ai-import-file filename flags) (wrap-ai-scene (aiImportFile (string->pointer filename) flags))) -(define-public (ai-transform-vec-by-matrix4 vec mat) +(define (ai-release-import scene) + (aiReleaseImport (unwrap-ai-scene scene))) + +(define* (ai-attach-predefined-log-stream type #:optional file) + (aiAttachLogStream + (aiGetPredefinedLogStream + type + (if file + (string->pointer file) + %null-pointer)))) + +(define (ai-transform-vec-by-matrix4 vec mat) (let ((cvec (parse-aiVector3D (map cdr (ai-vector3d-contents vec)) #:reverse #t)) (cmat (parse-aiMatrix4x4 (map cdr (ai-matrix4x4-contents mat)) #:reverse #t))) (aiTransformVecByMatrix4 cvec cmat) (wrap-ai-vector3d cvec))) -(define-public (ai-multiply-matrix3 m1 m2) +(define (ai-multiply-matrix3 m1 m2) (let ((cm1 (parse-aiMatrix3x3 (map cdr (ai-matrix3x3-contents m1)) #:reverse #t)) (cm2 (parse-aiMatrix3x3 (map cdr (ai-matrix3x3-contents m2)) #:reverse #t))) (aiMultiplyMatrix3 cm1 cm2) (wrap-ai-matrix3x3 cm1))) -(define-public (ai-multiply-matrix4 m1 m2) +(define (ai-multiply-matrix4 m1 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) (wrap-ai-matrix4x4 cm1))) -(define-public (ai-identity-matrix3) +(define (ai-identity-matrix3) (let ((cmat (parse-aiMatrix3x3 (make-list 9 0) #:reverse #t))) (aiIdentityMatrix3 cmat) (wrap-ai-matrix3x3 cmat))) -(define-public (ai-identity-matrix4) +(define (ai-identity-matrix4) (let ((cmat (parse-aiMatrix4x4 (make-list 16 0) #:reverse #t))) (aiIdentityMatrix4 cmat) (wrap-ai-matrix4x4 cmat))) -(define-public (ai-transpose-matrix3 mat) +(define (ai-transpose-matrix3 mat) (let ((cmat (parse-aiMatrix3x3 (map cdr (ai-matrix3x3-contents mat)) #:reverse #t))) (aiTransposeMatrix3 cmat) (wrap-ai-matrix3x3 cmat))) -(define-public (ai-transpose-matrix4 mat) +(define (ai-transpose-matrix4 mat) (let ((cmat (parse-aiMatrix4x4 (map cdr (ai-matrix4x4-contents mat)) #:reverse #t))) (aiTransposeMatrix4 cmat) (wrap-ai-matrix4x4 cmat))) diff --git a/src/low-level/cimport.scm b/src/low-level/cimport.scm index 023dc7a..7f0f259 100644 --- a/src/low-level/cimport.scm +++ b/src/low-level/cimport.scm @@ -19,6 +19,10 @@ #:use-module (assimp low-level) #:use-module (system foreign) #:export (aiImportFile + aiReleaseImport + aiGetPredefinedLogStream + aiAttachLogStream + aiDetachAllLogStreams aiTransformVecByMatrix4 aiMultiplyMatrix3 aiMultiplyMatrix4 @@ -28,6 +32,11 @@ aiTransposeMatrix4)) (define-assimp-function (aiImportFile '* unsigned-int) -> '*) +(define-assimp-function (aiReleaseImport '*) -> void) +(define-assimp-function (aiGetPredefinedLogStream unsigned-int '*) -> (list '* '* '*)) +(define-assimp-function (aiAttachLogStream '*) -> void) +(define-assimp-function (aiDetachAllLogStreams) -> void) + (define-assimp-function (aiTransformVecByMatrix4 '* '*) -> void) (define-assimp-function (aiMultiplyMatrix3 '* '*) -> void) (define-assimp-function (aiMultiplyMatrix4 '* '*) -> void) diff --git a/src/low-level/types.scm b/src/low-level/types.scm index 18a11d2..20e2281 100644 --- a/src/low-level/types.scm +++ b/src/low-level/types.scm @@ -16,11 +16,23 @@ (define-module (assimp low-level types) - #:use-module (system foreign)) + #:use-module (assimp low-level) + #:use-module (system foreign) + #:export (aiString-type + aiMatrix4x4-type + ai-default-log-stream)) -(define-public aiString-type +(define aiString-type (list size_t (make-list 1024 int8))) -(define-public aiMatrix4x4-type +(define aiMatrix4x4-type (make-list 16 float)) + +(define-enumeration + ai-default-log-stream + (file #x1) + (stdout #x2) + (stderr #x4) + (debugger #x8) + (ai-dls-enforce-enum-size #x7fffffff)) -- 2.39.5