Calling functions within a class in a dylib

I have a dylib that I want to try out ( Open Asset Import Library) and I’m wondering if there is any way to call a function within a class. Bear with me as I’m not sure if I’m asking this in the right way.

The global file-loading function returns an aiScene, which is a class. This class holds arrays for other classes, such as aiMesh, aiMaterial, etc. All of these classes have functions used (among other things) to navigate the other classes within it.

I’d like to drill down to the data contained within each class (i.e.: vertex data in aiMesh, textures in aiMaterial). There doesn’t seem to be a set of top-level functions to start off such a search. I was able to get a Ptr to the aiScene but now I’m not sure how to proceed. I’ve studied the data in a MemoryBlock but the data isn’t constant, making me wonder if I got the correct data at all (the dylib’s error function returns no error).

What I think I’d like to do is to be able to call a function within the class, such as aiScene.FindNode, so I can navigate the aiScene structure. I say “think” because I’m wondering whether or not it would be better to try and parse the data manually – something I’d rather avoid.

Any suggestions?

You have to use their C API - not the C++ one

I thought I did (I followed their plain-c function interface example), but then again this is the first time I’ve tried using dylibs. I’m slowly figuring out how to get the top-level assimp functions working, but I’m totally at a loss what to do next with the aiScene class it returns.

I feel like I’m missing something obvious here and could use a push (more likely several) in the right direction.

You might do better looking at a header file. It may look intimidating, but it looks like what should be returned is an aiScene structure…

looking at assimp/scene.h

it looks like aiScene should look something like

mFlags as uint32
mRootNode as ptr
mNumMeshes as uint32
mMeshes as ptr
mNumMaterials as uint32
mMaterials as ptr
mNumanimations as uint32
mAnimations as ptr
mNumTextures as uint32
mTextures as ptr
mNumLights as uint32
mLights as ptr
mNumCameras as uint32
mCameras as ptr

Where, for instance, mMeshes should be a ptr to the first mesh structure in an array of ptr’s to meshes (or nil if mNumMeshes=0).
You should be able to access each subsequent ptr by adding the size of a ptr to the address by casting the ptr to integer, add 4 or 8 and cast back to ptr, up to mMeshes+(mNumMeshes-1)*sizeOfPtr
Define a Mesh structure, then you can get the Mesh structure by doing thePtr.mesh(0)
From there you can access members of the mesh in the same way.

This is purely based from memory on past experience with other libraries unrelated to this… and I’ve never worked with Assimp, so I could be off-base here. But, hopefully a nudge in the right direction.

If a class structure has a function/callback (aside from those in #ifdef __cplusplus sections) that you need to call, you would create a delegate with the function ptr from that class structure.

Relying on Norman or Joe to re-nudge if I’m not correct.

Thanks all, seems like parsing the structure manually is the way to go. I can confirm that I can see my test mesh data in the aiScene memoryBlock that I have, it just a matter now of making sure I traverse the structure properly.