(define-module (assimp assimp)
#:use-module (assimp low-level)
+ #:use-module (assimp low-level color)
#:use-module (assimp low-level material)
#:use-module (assimp low-level mesh)
#:use-module (assimp low-level scene)
+ #:use-module (assimp low-level vector)
#:use-module (system foreign))
(define libassimp (dynamic-link "libassimp"))
(define-conversion-type parse-aiMesh -> mesh
(name (sized-string (field 'mName)))
(primitive-types (field 'mPrimitiveTypes))
- (vertices (array (field 'mNumVertices) (field 'mVertices) #:element-proc get-element-address))
- (faces (wrap (array (field 'mNumFaces) (field 'mFaces) #:element-size 8 #:element-proc get-element-address) wrap-face))
- (normals (array (field 'mNumVertices) (field 'mNormals) #:element-size 12 #:element-proc get-element-address))
- (tangents (array (field 'mNumVertices) (field 'mTangents) #:element-size 12 #:element-proc get-element-address))
- (bitangents (array (field 'mNumVertices) (field 'mBitangents) #:element-size 12 #:element-proc get-element-address))
- (colors (field 'mColors))
- (texture-coords (field 'mTextureCoords))
+ (vertices (wrap
+ (array (field 'mNumVertices) (field 'mVertices) #:element-proc get-element-address)
+ wrap-vector3d))
+ (faces (wrap
+ (array (field 'mNumFaces) (field 'mFaces) #:element-size 8 #:element-proc get-element-address)
+ wrap-face))
+ (normals (wrap
+ (array (field 'mNumVertices) (field 'mNormals) #:element-size 12 #:element-proc get-element-address)
+ wrap-vector3d))
+ (tangents (wrap
+ (array (field 'mNumVertices) (field 'mTangents) #:element-size 12 #:element-proc get-element-address)
+ wrap-vector3d))
+ (bitangents (wrap
+ (array (field 'mNumVertices) (field 'mBitangents) #:element-size 12 #:element-proc get-element-address)
+ wrap-vector3d))
+ (colors (map
+ (lambda (c)
+ (wrap
+ (array (field 'mNumVertices) c #:element-size 16 #:element-proc get-element-address)
+ wrap-color4d))
+ (field 'mColors)))
+ (texture-coords (map
+ (lambda (tc)
+ (wrap
+ (array (field 'mNumVertices) tc #:element-size 12 #:element-proc get-element-address)
+ wrap-vector3d))
+ (field 'mTextureCoords)))
(num-uv-components (field 'mNumUVComponents))
- (bones (array (field 'mNumBones) (field 'mBones)))
+ (bones (wrap (array (field 'mNumBones) (field 'mBones)) wrap-bone))
(material-index (field 'mMaterialIndex)))
(export mesh?
(export face?
face-contents
face-indices)
+
+
+;;; Vectors
+
+(define-conversion-type parse-aiVector2D -> vector2d
+ (x (field 'x))
+ (y (field 'y)))
+
+(export vector2d?
+ vector2d-contents
+ vector2d-x
+ vector2d-y)
+
+(define-conversion-type parse-aiVector3D -> vector3d
+ (x (field 'x))
+ (y (field 'y))
+ (z (field 'z)))
+
+(export vector3d?
+ vector3d-contents
+ vector3d-x
+ vector3d-y
+ vector3d-z)
+
+
+;;; Colors
+
+(define-conversion-type parse-aiColor4D -> color4d
+ (r (field 'r))
+ (g (field 'g))
+ (b (field 'b))
+ (a (field 'a)))
+
+(export color4d?
+ color4d-contents
+ color4d-r
+ color4d-g
+ color4d-b
+ color4d-a)
+
+
+;;; Bones
+
+(define-conversion-type parse-aiBone -> bone
+ (name (sized-string (field 'mName)))
+ (weights (wrap
+ (array (field 'mNumWeights) (field 'mWeights) #:element-size 8 #:element-proc get-element-address)
+ wrap-vertex-weight))
+ (offset-matrix (field 'mOffsetMatrix)))
+
+(export bone?
+ bone-contents
+ bone-name
+ bone-weights
+ bone-offset-matrix)
+
+
+;;; Weights
+
+(define-conversion-type parse-aiVertexWeight -> vertex-weight
+ (vertex-id (field 'mVertexId))
+ (weight (field 'mWeight)))
+
+(export vertex-weight?
+ vertex-weight-contents
+ vertex-weight-vertex-id
+ vertex-weight-weight)
--- /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 color)
+ #:use-module (assimp low-level)
+ #:use-module (system foreign))
+
+
+(define-struct-parser parse-aiColor4D
+ (r float)
+ (g float)
+ (b float)
+ (a float))
+
+(export parse-aiColor4D)
(export parse-aiFace)
+(define-struct-parser parser-aiVertexWeight
+ (mVertexId unsigned-int)
+ (mWeight float))
+
+(export parse-aiVertexWeight)
+
+
+(define-struct-parser parse-aiBone
+ (mName aiString-type)
+ (mNumWeights unsigned-int)
+ (mWeights '*)
+ (mOffsetMatrix aiMatrix4x4-type))
+
+(export parse-aiBone)
+
+
(define AI_MAX_NUMBER_OF_COLOR_SETS #x8)
(define AI_MAX_NUMBER_OF_TEXTURECOORDS #x8)
--- /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 vector)
+ #:use-module (assimp low-level)
+ #:use-module (system foreign))
+
+
+(define-struct-parser parse-aiVector2D
+ (x float)
+ (y float))
+
+(define-struct-parser parse-aiVector3D
+ (x float)
+ (y float)
+ (z float))
+
+(export parse-aiVector2D
+ parse-aiVector3D)