Custom mesh loaders

qwertyuiop23
Posts: 2
Joined: Sat Apr 24, 2010 4:54 am

Custom mesh loaders

Post by qwertyuiop23 »

Are there any custom model premade model loaders out there?

For example functions that will load .x, .obj, .3ds etc into bullet arrays or will I have to do this myself? I am using Irrlicht to draw the models so this already can load all these things so I only need functions to be able to load in the collision data. So before I try to start making my own I was wondering if there were any already out there?

Cheers
Qwertyuiop23
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Custom mesh loaders

Post by Dirk Gregorius »

John Rattcliff released a simple mesh loader which can deal with a bunch of file formats. I don't think you can load it directly into Bullet, but it should be quite easy to do this. You can download it here:

http://code.google.com/p/meshimport/

Cheers,
-Dirk
qwertyuiop23
Posts: 2
Joined: Sat Apr 24, 2010 4:54 am

Re: Custom mesh loaders

Post by qwertyuiop23 »

That mesh loader is quite confusing and it is not designed for bullet. Are there any others out there that are easy to implement and are designed for Bullet?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Custom mesh loaders

Post by Erwin Coumans »

There are several examples:

1) example to create a mesh from an .obj file in Bullet/Demos/ConvexDecompositionDemo
2) example to load a Quake .bsp into Bullet in Bullet/Demos/BspDemo
3) example to initialize Bullet objects from a Blender .blend file into Irrlicht, see http://gamekit.googlecode.com (download section IrrKit, or svn branches/IrrKit)
4) example to load a COLLADA .dae file into Bullet in http://dynamica.googlecode.com, Bullet/Demos/ColladaDemo

The easiest way is just to use this:

Code: Select all

		btTriangleMesh* trimesh = new btTriangleMesh();
		for ( i=0;i<numTriangles;i++)
		{
			trimesh->addTriangle(triangles[i].vertex0,triangles[i].vertex1,triangles[i].vertex2);
		}
		btCollisionShape* shape = 0;
		if (movingDynamic)
		{
				shape = new btConvexTriangleMeshShape(trimesh);
		}
		else
		{
				//static, non-moving world environment geometry
				bool useQuantization = true;
				shape  = new btBvhTriangleMeshShape(trimesh,useQuantization);
		}
Thanks,
Erwin
molma100
Posts: 11
Joined: Sat Apr 09, 2011 8:12 pm

Re: Custom mesh loaders

Post by molma100 »

hey, im wondering if this works with GLM, a model loading library originally created by Nate Robins?

I have tried something like this before and it caused my game to crash..

Im going to try this again.