;; where post is any post processing required
;; if value is 0 then use default
;; of (+ aiProcess_FindDegenerates aiProcess_Triangulate)
;; if value > 0 then use post exactly as defined
;; which means the user must add AT LEAST aiProcess_Triangulate
;;
(bind-func assimp_load_model
(lambda (dir file post)
(let ((lgth (+ (strlen dir) (strlen file) 1))
(scene:aiScene* null)
(path:i8* (salloc lgth)))
(memset path 0 lgth)
(memcpy path dir (strlen dir))
(memcpy (pref-ptr path (strlen dir)) file (strlen file))
(if (> post 0)
(set! scene (aiImportFile path post))
(set! scene (aiImportFile path (+ aiProcess_FindDegenerates aiProcess_PreTransformVertices aiProcess_OptimizeMeshes aiProcess_OptimizeGraph aiProcess_Triangulate))))
;;(set! scene (aiImportFile path 498379))
(let ((root:XTMModel*
(if (null? scene)
(begin (printf "Bad Asset! %s\n" path) (cast null XTMModel*))
(ai_build_scene scene dir))))
(if (not (null? scene))
(begin ;; (printf "delete scene: %p\n" scene)
(aiReleaseImport scene)))
root))))