From 97d868192018795a86bf88d6534c132303f6cd08 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Thu, 29 May 2014 11:40:17 +0200 Subject: [PATCH] New type 'face' --- src/assimp.scm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/assimp.scm b/src/assimp.scm index b91e8ab..f3d8893 100644 --- a/src/assimp.scm +++ b/src/assimp.scm @@ -102,6 +102,18 @@ (else '()))))) +(define* (get-structs-array num-index root-index struct-size #:optional wrap-proc) + (lambda (pointer) + (let ((num (bv-uint-ref pointer num-index)) + (rootp (bv-uint-ref pointer root-index))) + (let loop ((i (- num 1))) + (cond ((< i 0) + '()) + (else + (let* ((p (make-pointer (+ rootp (* i struct-size)))) + (wp (if wrap-proc (wrap-proc p) p))) + (cons wp (loop (- i 1)))))))))) + (define* (get-pointer-of-pointers num-index root-index #:optional wrap-proc) (lambda (pointer) (let* ((num (bv-uint-ref pointer num-index)) @@ -155,7 +167,7 @@ (define-type mesh (num-primitive-types (lambda (p) (bv-uint-ref p 0))) (vertices (get-pointer-of-pointers 4 12)) - (faces (get-pointer-of-pointers 8 124)) + (faces (get-structs-array 8 124 8 wrap-face)) (normals (lambda (p) (bv-uint-ref p 16))) (tangents (lambda (p) (bv-uint-ref p 20))) (bitangents (lambda (p) (bv-uint-ref p 24))) @@ -177,3 +189,12 @@ (export material? material-contents) + + +;;; Faces + +(define-type face + (indices (get-array 0 4 'u32))) + +(export face? + face-contents) -- 2.39.5