(define-module (assimp assimp)
+ #:use-module (assimp low-level scene)
#:use-module (ice-9 iconv)
#:use-module (rnrs bytevectors)
#:use-module (system foreign))
(aiImportFile (string->pointer filename)
flags)))
+(define (load-scene filename flags)
+ (parse-aiNode
+ (assoc-ref
+ (parse-aiScene
+ (aiImportFile (string->pointer filename)
+ flags))
+ 'mRootNode)))
+
(export load-scene
unwrap-scene
scene?
;;; Meshes
+(define AI_MAX_NUMBER_OF_COLOR_SETS 8)
+
(define-type mesh
(num-primitive-types (lambda (p) (bv-uint-ref p 0)))
(vertices (get-pointer-of-pointers 4 12))
--- /dev/null
+;;; guile-assimp, foreign interface to libassimp
+;;; Copyright (C) 2014 by Javier Sancho Fernandez <jsf at jsancho dot org>
+;;;
+;;; This program is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (assimp low-level)
+ #:use-module (system foreign))
+
+
+(define-syntax define-struct-parser
+ (lambda (x)
+ (syntax-case x ()
+ ((_ name (field type) ...)
+ (with-syntax (((field-name ...) (map car #'((field type) ...)))
+ ((field-type ...) (map cadr #'((field type) ...))))
+ #'(define (name pointer)
+ (map cons
+ '(field-name ...)
+ (parse-c-struct pointer (list field-type ...)))))))))
+
+(export define-struct-parser)
--- /dev/null
+;;; guile-assimp, foreign interface to libassimp
+;;; Copyright (C) 2014 by Javier Sancho Fernandez <jsf at jsancho dot org>
+;;;
+;;; This program is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (assimp low-level scene)
+ #:use-module (assimp low-level)
+ #:use-module (assimp low-level types)
+ #:use-module (system foreign))
+
+
+(define-struct-parser parse-aiNode
+ (aiString aiString-type)
+ (aiMatrix4x4 aiMatrix4x4-type)
+ (mParent '*)
+ (mNumChildren unsigned-int)
+ (mChildren '*)
+ (mNumMeshes unsigned-int)
+ (mMeshes '*))
+
+(export parse-aiNode)
+
+
+(define-struct-parser parse-aiScene
+ (mFlags unsigned-int)
+ (mRootNode '*)
+ (mNumMeshes unsigned-int)
+ (mMeshes '*)
+ (mNumMaterials unsigned-int)
+ (mMaterials '*)
+ (mNumAnimations unsigned-int)
+ (mAnimations '*)
+ (mNumTextures unsigned-int)
+ (mTextures '*)
+ (mNumLights unsigned-int)
+ (mLights '*)
+ (mNumCameras unsigned-int)
+ (mCameras '*)
+ (mPrivate '*))
+
+(export parse-aiScene)
--- /dev/null
+;;; guile-assimp, foreign interface to libassimp
+;;; Copyright (C) 2014 by Javier Sancho Fernandez <jsf at jsancho dot org>
+;;;
+;;; This program is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (assimp low-level types)
+ #:use-module (system foreign))
+
+
+(define-public aiString-type
+ (list size_t (make-list 1024 int8)))
+
+(define-public aiMatrix4x4-type
+ (make-list 16 float))