(cond (wrap-proc (wrap-proc p2))
(else p2)))))))))
-(define* (get-pointer-of-pointers-procedure num-index root-index #:optional wrap-proc)
+(define (get-array num-index root-index type)
+ (lambda (pointer)
+ (let ((num (bv-uint-ref pointer num-index))
+ (rootp (make-pointer (bv-uint-ref pointer root-index))))
+ (cond ((> num 0)
+ (array->list
+ (pointer->bytevector rootp num 0 type)))
+ (else
+ '())))))
+
+(define* (get-pointer-of-pointers num-index root-index #:optional wrap-proc)
(lambda (pointer)
(let* ((num (bv-uint-ref pointer num-index))
(rootp (make-pointer (bv-uint-ref pointer root-index))))
(define-type scene
(flags (lambda (p) (bv-uint-ref p 0)))
(root-node (lambda (p) (wrap-node (make-pointer (bv-uint-ref p 4)))))
- (meshes (get-pointer-of-pointers-procedure 8 12 wrap-mesh))
- (materials (get-pointer-of-pointers-procedure 16 20))
- (animations (get-pointer-of-pointers-procedure 24 28))
- (textures (get-pointer-of-pointers-procedure 32 36))
- (lights (get-pointer-of-pointers-procedure 40 44))
- (cameras (get-pointer-of-pointers-procedure 48 52)))
+ (meshes (get-pointer-of-pointers 8 12 wrap-mesh))
+ (materials (get-pointer-of-pointers 16 20))
+ (animations (get-pointer-of-pointers 24 28))
+ (textures (get-pointer-of-pointers 32 36))
+ (lights (get-pointer-of-pointers 40 44))
+ (cameras (get-pointer-of-pointers 48 52)))
(define (load-scene filename flags)
(wrap-scene
(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)))
+ (children (get-pointer-of-pointers 1096 1100 wrap-node))
+ (meshes (get-array 1104 1108 'u32)))
(export node?
node-contents)
(define-type mesh
(num-primitive-types (lambda (p) (bv-uint-ref p 0)))
- (vertices (get-pointer-of-pointers-procedure 4 12))
- (faces (get-pointer-of-pointers-procedure 8 124))
+ (vertices (get-pointer-of-pointers 4 12))
+ (faces (get-pointer-of-pointers 8 124))
(normals (lambda (p) (bv-uint-ref p 16)))
(tangents (lambda (p) (bv-uint-ref p 20)))
(bitangents (lambda (p) (bv-uint-ref p 24)))
(colors (lambda (p) (bv-uint-ref p 28))) ;AI_MAX_NUMBER_OF_COLOR_SETS
(texture-coords (lambda (p) (bv-uint-ref p 60))) ;AI_MAX_NUMBER_OF_TEXTURECOORDS
(num-uv-components (lambda (p) (bv-uint-ref p 92))) ;AI_MAX_NUMBER_OF_TEXTURECOORDS
- (bones (get-pointer-of-pointers-procedure 128 132))
+ (bones (get-pointer-of-pointers 128 132))
(material-index (lambda (p) (bv-uint-ref p 136))))
(export mesh?
#include <assimp/scene.h>
#include <assimp/postprocess.h>
+void print_node(const struct aiNode* node) {
+ int i;
+
+ printf("%s: %d %d [", node->mName.data, node->mNumMeshes, node->mNumChildren);
+ for (i = 0; i < node->mNumMeshes; i++) {
+ printf("%d ", node->mMeshes[i]);
+ }
+ printf("]\n");
+
+ for (i = 0; i < node->mNumChildren; i++) {
+ print_node(node->mChildren[i]);
+ }
+}
+
int main(int argc, char **argv)
{
const struct aiScene* scene = NULL;
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);
+
+ printf("\n\n");
+ print_node(node);
}