(define-module (assimp assimp)
+ #:use-module (ice-9 iconv)
#:use-module (rnrs bytevectors)
#:use-module (system foreign))
(native-endianness)
4))
+(define (get-aiString index)
+ (lambda (pointer)
+ (let* ((length (bv-uint-ref pointer index))
+ (data (pointer->bytevector pointer length (+ index 4))))
+ (bytevector->string data (fluid-ref %default-port-encoding)))))
+
+(define* (get-pointer index #:optional wrap-proc)
+ (lambda (pointer)
+ (let ((p (bv-uint-ref pointer index)))
+ (cond ((= p 0) '())
+ (else
+ (let ((p2 (make-pointer p)))
+ (list
+ (cond (wrap-proc (wrap-proc p2))
+ (else p2)))))))))
+
(define* (get-pointer-of-pointers-procedure num-index root-index #:optional wrap-proc)
(lambda (pointer)
(let* ((num (bv-uint-ref pointer num-index))
;;; Nodes
(define-type node
- (name (lambda (p) (bv-uint-ref p 0))) ;check, it's a struct
- (transformation (lambda (p) (bv-uint-ref p 1028))) ;check, it's a struct
- (parent (lambda (p) (bv-uint-ref p 1092)))
- (children (get-pointer-of-pointers-procedure 1096 1100))
- (meshes (get-pointer-of-pointers-procedure 1104 1108)))
+ (name (get-aiString 0))
+ (transformation (lambda (p) (array->list (pointer->bytevector p 16 1028 'f32))))
+ (parent (get-pointer 1092 wrap-node))
+ (children (get-pointer-of-pointers-procedure 1096 1100 wrap-node))
+ (meshes (get-pointer-of-pointers-procedure 1104 1108 wrap-mesh)))
(export node?
node-contents)
scene = aiImportFile("/home/jsancho/Imágenes/fleurOptonl.blend", aiProcessPreset_TargetRealtime_MaxQuality);
node = scene->mRootNode;
printf("Node:\n parent: %d\n children: %d\n meshes: %d\n", node->mParent, node->mNumChildren, node->mNumMeshes);
+ printf(" transformation: %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n", node->mTransformation.a1, node->mTransformation.a2, node->mTransformation.a3, node->mTransformation.a4, node->mTransformation.b1, node->mTransformation.b2, node->mTransformation.b3, node->mTransformation.b4, node->mTransformation.c1, node->mTransformation.c2, node->mTransformation.c3, node->mTransformation.c4, node->mTransformation.d1, node->mTransformation.d2, node->mTransformation.d3, node->mTransformation.d4);
}