btTriangleIndexVertexArray to btConvexHullShape conversion

RJNelson68
Posts: 73
Joined: Tue Oct 06, 2009 3:19 pm

btTriangleIndexVertexArray to btConvexHullShape conversion

Post by RJNelson68 »

Is there some way to convert a btTriangleIndexVertexArray to a btAlignedObjectArray?
Last edited by RJNelson68 on Fri Jul 02, 2010 9:49 pm, edited 1 time in total.
RJNelson68
Posts: 73
Joined: Tue Oct 06, 2009 3:19 pm

Re: btTriangleIndexVertexArray to btConvexHullShape conversi

Post by RJNelson68 »

OK let me clarify what I am trying to do. I have a polygon list and I can easily create a btBvhTriangleMeshShape from that, but that is not practical for what I need it for, vehicles with a conforming collision. For that to react properly to the environment I need a btConvexHullShape since the btBvhTriangleMeshShape really only works well for static objects and even if I add one to a compund object it still would not collide with another vehicle set up in the same manner.

I can use addPoint but that really doesn't set up the polygons as they need to be and I only get what can be best described as a mess. I would really appreciate advice on this.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: btTriangleIndexVertexArray to btConvexHullShape conversi

Post by dphil »

I'm fairly new to bullet, but I'm thinking you'd want to take a look at btGImpactMeshShape and/or btConvexTriangleMeshShape. I think they are essentially the dynamic (concave and convex, respectively) versions of the static btBvhTriangleMeshShape shape(?). They both seem to take in predefined triangle data (StridingMeshInterface, that is) just like the btBvhTriangleMeshShape, so you should be able to plug your data in. We use btGImpactMeshShape in the project I'm working on for collisions between arbitrary tri-meshes we have predefined. I am not familiar with btConvexTriangleMeshShape, though I'm curious how it handles/enforces the convex quality of meshes it is constructed with.

And you're right about btConvexHullShape. I believe it just computes its own hull from the points you provide and doesn't necessarily organize the shape as you want/expect, hence why you'd want to perhaps look at one of the two mesh shapes I mentioned.
RJNelson68
Posts: 73
Joined: Tue Oct 06, 2009 3:19 pm

Re: btTriangleIndexVertexArray to btConvexHullShape conversi

Post by RJNelson68 »

That is EXACTLY what I needed! Thank you, I can't believe I didn't see that option. It works perfectly. Thanks again.
bulevren
Posts: 2
Joined: Sun Jan 15, 2012 11:19 pm

Re: btTriangleIndexVertexArray to btConvexHullShape conversi

Post by bulevren »

I have tried to solve the same problem for three days, thanks for your solution.

// I deleted this line
// btBvhTriangleMeshShape shapeStatic=new btBvhTriangleMeshShape(m_indexVertexArrays,true, true);

btConvexTriangleMeshShape * staticS = new btConvexTriangleMeshShape(m_indexVertexArrays);
staticS->setMargin(0.05f);
m_trimeshStatic = staticS;

btGImpactMeshShape * shapeDynamic = new btGImpactMeshShape(m_indexVertexArrays1);
shapeDynamic->setMargin(0.05f);
shapeDynamic->updateBound();

Now it is working!!!:)