Importing shapes into Bullet

Post Reply
Ehsanizadi
Posts: 72
Joined: Mon Dec 02, 2013 4:13 pm

Importing shapes into Bullet

Post by Ehsanizadi »

Hi,

I have a meshed geometry file (in stl, obj, etc format) composed of thousands of separated rigid bodies. But all in one file.
How can I import it into bullet with less effort in a way that I tell bullet to recognize every separate object as an unique rigid body?

If it is not possible, what do you suggest for doing that?

Thank you
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Importing shapes into Bullet

Post by drleviathan »

As far as I know Bullet has no utilities for reading non-Bullet file formats. If you have an OBJ file then you'd have to find (or write) an OBJ parser and then write custom code to turn each mesh object into a btShape. Ideally you'd want to optimize the shapes: you wouldn't want to use a btBvhTriangleMeshShape when you could get away with a btConvexHullShape. So depending on what the objects look like (are they all boxes? or are they arbitrary concave meshes?) it might actually pay off to perform convex decomposition of your meshes using the V-HACD utilities (see the ConvexDecompositionDemo).

Unfortunately, I would expect doing convex decomposition on a large scene will take time (several seconds to a few minutes) so maybe it should be done as a pre-processing step before you try to load your scene.
Ehsanizadi
Posts: 72
Joined: Mon Dec 02, 2013 4:13 pm

Re: Importing shapes into Bullet

Post by Ehsanizadi »

It is composed of irregular polyhedrons. So, there is no regular shapes like boxes or so.
The time for such conversion does not matter to me that much (as far as it is less than a few hours)

Is there any tutorial for convex decomposition? What file format is accepted for convex decomposition?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Importing shapes into Bullet

Post by drleviathan »

The V-HACD library is just a lib that computes a list of convex hulls if you give it at mesh (points and triangle indices). From its output you'd have to generate your own btConvexHull shapes and put them into a btCompoundShape, or just load each convex hull as one object if they are all static (note that this may have poor loading performance if there are a LOT of objects). There is a ConvexDecomposition demo in the Bullet codebase.

Alternatively the highfidelity project has implemented a command line utility that takes an FBX file, feeds the mesh parts to V-HACD, and outputs the convex hull points (in JSON I think). It's a work in progress (and further development on that particular utility is on hold) but if you built that codebase and found the utility you might be able to make it do the hard work for you. Might be a quick way to go if you only ever plan to process just one content file.
Ehsanizadi
Posts: 72
Joined: Mon Dec 02, 2013 4:13 pm

Re: Importing shapes into Bullet

Post by Ehsanizadi »

Thanks,

I will try convex decomposition.

The time takes for that does not matter that much. so, I think it is ok for me
Post Reply