Assimp wrapper update

BlitzMax Forums/MiniB3D Module/Assimp wrapper update

markcw(Posted 2014) [#1]
I have updated Peter Scheutz's Assimp wrapper to use version 3.1.1 and changed it from a source to a dynamic library wrapper because the source was broken and I haven't been able to fix it yet.

Apart from that it is basically the same code reorganized a bit. Now you can import Scheutz.aiMinib3d instead of needing to include the aiLoadMesh function in your projects. It also includes some docs and a module for Openb3d.

You can get the wrapper and examples here and the library binaries here. Courtesy of GitHub. You will also need the Assimp source to run the examples.

The original Assimp wrapper thread is here.

Animations are not supported and meshes have no children.


markcw(Posted 2014) [#2]
Okay, so I'm trying to get the assimp source wrapper working but I can't understand these errors as I have included all the header directories and cc files so it really should be happy.

The module builds but when I run an example I get just these poly2tri errors:
/home/mark/BlitzMax/mod/scheutz.mod/assimp.mod/assimp.debug.linux.x86.a(IFCOpenings.cpp.debug.linux.x86.o): In function 
`Assimp::IFC::TryAddOpenings_Poly2Tri(std::vector<Assimp::IFC::TempOpening, std::allocator<Assimp::IFC::TempOpening> > const&, 
std::vector<aiVector3t<double>, std::allocator<aiVector3t<double> > > const&, Assimp::IFC::TempMesh&)':
IFCOpenings.cpp:(.text+0xb912): undefined reference to `p2t::CDT::CDT(std::vector<p2t::Point*, std::allocator<p2t::Point*> >)'
IFCOpenings.cpp:(.text+0xbe14): undefined reference to `p2t::CDT::AddHole(std::vector<p2t::Point*, std::allocator<p2t::Point*> >)'
IFCOpenings.cpp:(.text+0xbeb0): undefined reference to `p2t::CDT::Triangulate()'
IFCOpenings.cpp:(.text+0xbec8): undefined reference to `p2t::CDT::GetTriangles()'
/home/mark/BlitzMax/mod/scheutz.mod/assimp.mod/assimp.debug.linux.x86.a(BlenderTessellator.cpp.debug.linux.x86.o): In function 
`Assimp::BlenderTessellatorP2T::Tessellate(Assimp::Blender::MLoop const*, int, 
std::vector<Assimp::Blender::MVert, std::allocator<Assimp::Blender::MVert> > const&)':
BlenderTessellator.cpp:(.text+0x120): undefined reference to `p2t::CDT::CDT(std::vector<p2t::Point*, std::allocator<p2t::Point*> >)'
BlenderTessellator.cpp:(.text+0x139): undefined reference to `p2t::CDT::Triangulate()'
BlenderTessellator.cpp:(.text+0x14e): undefined reference to `p2t::CDT::GetTriangles()'
BlenderTessellator.cpp:(.text+0x17c): undefined reference to `p2t::CDT::~CDT()'
BlenderTessellator.cpp:(.text+0x1b9): undefined reference to `p2t::CDT::~CDT()'
BlenderTessellator.cpp:(.text+0x1da): undefined reference to `p2t::CDT::~CDT()'

I resolved all the other errors by importing the c/cpp files but this one won't go away. They are the only .cc files in the library, could this be the problem?

Edit: looking around in maxmods it seems I may need a glue.cpp for cc files because it's 'c with classes'.


Hezkore(Posted 2015) [#3]
I don't know the limitations to Assimp, but no animations or bones are loaded.
And it seems like the shading on Assimp loaded models is much harder than on models loaded normally.
Other than that, it seems to work great and loads my DAE files perfectly! (Tested with both Openb3d and Minib3d)


markcw(Posted 2015) [#4]
The wrapper is incomplete, Peter Scheutz never got round to it, so no animations. I just took his code and made it compile.
I hadn't noticed that about the shading, it maybe something that can be changed.


Brucey(Posted 2015) [#5]
I've had a play, and have a built-as-module version of assimp on OS X 32-bit.
Unfortunately, I think the types.bmx stuff will need a rewrite as it doesn't look like it will be x64 compatible.
I'm coming at this from my "usual" direction, which tends to involve glue code rather than trying to do everything in .bmx (this tends to make things much cleaner on the bmx side, with less caveats and possible issues).

Anyway, just playing at the moment..


markcw(Posted 2015) [#6]
@Brucey: Even just to get this built as a module is awesome! I've really stalled on this as I have no idea how to write glue code and that seemed to be what this needed. So feel free to take over this project as there's not much I can do with it.


Brucey(Posted 2015) [#7]
Is it just me or is z "inverted" on loading .b3d with assimp? i.e. the back is at the front, and the front is at the back.

I see in the examples, that the entity gets a 180 degree rotation. Which is fine, but if you look at the zombie, his stubby arm is on a different side than when you use the standard LoadMesh.

I see where the anim issues have come from, since the bone stuff isn't exposed anywhere. It will all need to be applied at a low level...


markcw(Posted 2015) [#8]
Yes, it does invert at least one of the model axis.

I wasn't aware that there was any animation code in the wrapper.


markcw(Posted 2015) [#9]
The ImportFile function has flags for different options, docs here.

The aiProcess_ConvertToLeftHanded flag assigns the DX coordinate space (solving the z inverting issue), aiProcess_GenSmoothNormals generate smooth normals (solving the hard shading issue), aiProcess_GenNormals generates the flat normals, aiProcess_FlipWindingOrder flips all the mesh triangles.

I changed the flags found in the LoadMesh functions in aiminib3d.mod/types.bmx and aiopenb3d/types.bmx. Those files are identical btw.


Brucey(Posted 2015) [#10]
Yep, I just discovered those too :-)

So, after the rewrapping I have models loading but without textures for whatever reason - all the code looks correct as far as I can tell, but no textures.
Not to worry... I'm trying to find a way to crowbar in the animation/bone data at the moment...


markcw(Posted 2015) [#11]
Sounds like you know what you're doing there! Is it x64 compatible now too?


Brucey(Posted 2015) [#12]
Is it x64 compatible now too?

I expect so, but I haven't tried it yet.

[edit] Yes.


markcw(Posted 2015) [#13]
Great!

A little update: I removed aiminib3d.mod and aiopenb3d.mod in favour of using Include "TaiModel.bmx" as I thought it was a little confusing. The drawback is needing to copy the file to the app folder but I now think this is the better option. I added to dynamic.bmx Import "-ldl" needed on Linux. I also put a license.txt in there.


Brucey(Posted 2015) [#14]
I removed aiminib3d.mod and aiopenb3d.mod...

That's interesting.
I've modified everything to use a factory-style mesh loader (much in the same way as pixmap loading works). Each "loader" knows what file format it can load, so the factory just looks up the extension and gets the correct loader. That way you just call LoadMesh(), and depending on what modules you have imported, it will load using an appropriate loader (or not, if the extension isn't supported by any of the current loaders).


markcw(Posted 2015) [#15]
That sounds like a clever solution to the problem (using abstract methods/types), but I don't see how it solves use of the minib3d functions in TaiModel.bmx (i.e. CreateBrush, BrushShininess, LoadTexture, BrushTexture, CreateMesh, CreateSurface, AddVertex, VertexX, VertexNormal, VertexNX, VertexTexCoords, VertexU, TriangleVertex, AddTriangle, etc). Surely you're forced to import sidesign.minib3d for this?


RustyKristi(Posted 2016) [#16]
Hi, I'm interested to know where I can find the updated repo for blitz-assimp. I can only see the google code page.


markcw(Posted 2016) [#17]
I closed my repo for this as it didn't do animations and it was just a bit too bloated, the library file was pretty big 50 MB or something.


RustyKristi(Posted 2016) [#18]
Ok understood and I kinda figured when I saw that dreaded boost libs again. I was trying to stay away from that monster hehehe. XD

thanks munch.


LT(Posted 2016) [#19]
Brucey, did you ever post your version of the AssImp module? I can't see it anywhere...