Since `aiImportFile` can return NULL to indicate failure, you should use
`_ai-scene-pointer/null`:

 (define-assimp ai-import-file (_fun _string _int -> _ai-scene-pointer/null)
   #:c-id aiImportFile)


Probably you don't want `_array`. In a structure, that inlines an array
instead of representing a pointer to an array of pointers. For example,
`mMeshes` in `aiScene` is a pointer at an array of pointers,

 aiMesh** mMeshes

not an array of pointers,

 aiMesh* mMeshes[50000]

For this case at the Racket level, it's easiest to just use `_pointer`
instead of `(_array _ai-mesh-pointer 50000)` as the field type, and use
`ptr-ref` with `_ai-mesh-pointer` to get one pointer from the
referenced array.

At Tue, 21 May 2019 12:03:47 -0700 (PDT), Akash Shakdwipeea wrote:
> Hi guys,
> 
>  I am trying to use assimp <https://github.com/assimp/assimp> to load some 
> 3d objects. I have run into a problem with the ffi.
> 
> So I have written bindings 
> <https://github.com/bdfp/kaladin/blob/master/assimp.rkt#L113> to a function 
> which helps me load the model into a scene object 
> <https://github.com/assimp/assimp/blob/master/include/assimp/scene.h#L241>. 
> I am able to load the scene object but when I am trying to go in the meshes 
> in the object and try to print the vertices I am running into this error
> 
> "assimp.rkt"> (enter! "assimp.rkt")
>   [re-loading /assimp.rkt]
> "assimp.rkt"> (ai-mesh-vertices a)
> ; ai-vector-3D->C: argument is not non-null `ai-vector-3D' pointer
> ;   argument: #f
> ; [,bt for context]
> 
> In the mesh struct 
> <https://github.com/assimp/assimp/blob/master/include/assimp/mesh.h#L595>, 
> they have defined it to be a pointer to vector3D, so I am not sure why this 
> is failing.
> 
> Also in the a variable 
> <https://github.com/bdfp/kaladin/blob/master/assimp.rkt#L116> I am able to 
> view the integer types properly
> (ai-mesh-num-vertices a)
> 
> but the other pointers and the string are not working. This could be 
> because of the way I am representing the mesh structure 
> <https://github.com/assimp/assimp/blob/master/include/assimp/scene.h#L269> 
> , using an  _array type . 
> <https://github.com/bdfp/kaladin/blob/master/assimp.rkt#L94> 
> I am not sure if this is the right way to do this. 
> 
>  Any pointers will be very helpful.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/cf7df646-24ee-4a6b-9674-22766698
> c3f2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20190521191449.8ECE06500E0%40mail-svr1.cs.utah.edu.
For more options, visit https://groups.google.com/d/optout.

Reply via email to