Is it possible to make a btTriangleShape out of a btTriangleMeshShape?
I have a btBvhTriangleMeshShape that is recognised as a TRIANGLE_MESH_SHAPE_PROXYTYPE.
However for the InternalEdgeUtility I require a btTriangleShape (TRIANGLE_SHAPE_PROXYTYPE).
The model is a 3d non-convex object loaded from .osg and created as a btBvhTriangleMesh using osgBullet.
The btTriMeshCollisionShapeFromOSG returns a btTriangleMeshShape (while using btBvhTriangleMeshShape inside the function).
It gathers all the vertices and then adds these as triangles to a btTriangleMesh (which is added to the btBvhTriangleMeshShape.
Now I asume I could use a similar visitor to get all the vertices, but how do I construct a valid 3D TriangleShape from these vertices?
Cheers
edit:
the OSG model is generated from parametric surfaces (with a thickness added) which represent the world, these models have also been given a thickness (so it becomes a triangle mesh from that surface+thickness).
This means that there are a good number of internal edges, which mess up my cylinder-wheeled vehicles.
And the internal edge util only accepts TRIANGLE_SHAPE_PROXYTYPE, not meshes.
btTriangleMeshShape to btTriangleShape (InternalEdges prob)
-
- Posts: 65
- Joined: Fri May 13, 2011 1:11 pm
-
- Posts: 65
- Joined: Fri May 13, 2011 1:11 pm
Re: btTriangleMeshShape to btTriangleShape (InternalEdges pr
Or in other words:
How do I fix the internal edge problem if I only have a btBvhTriangleMeshShape (which is concave).
How do I fix the internal edge problem if I only have a btBvhTriangleMeshShape (which is concave).
-
- Posts: 31
- Joined: Tue Apr 26, 2011 5:52 pm
Re: btTriangleMeshShape to btTriangleShape (InternalEdges pr
Well, as a matter of fact, btBvhTriangleMeshShape is the shape that you need to pass to the internal edge utility function. So i do not understand why you think you can't. Look at this post:Karrok wrote:Or in other words:
How do I fix the internal edge problem if I only have a btBvhTriangleMeshShape (which is concave).
http://bulletphysics.org/Bullet/phpBB3/ ... 566#p24566
-
- Posts: 65
- Joined: Fri May 13, 2011 1:11 pm
Re: btTriangleMeshShape to btTriangleShape (InternalEdges pr
I realise that, but the shape returned from getShapeType() is not TRIANGLE_SHAPE_PROXYTYPE as it was generated from osgBullet, which turns an osg file into a TriangleMesh.
And I am not sure how I should alter the shape creation to make a proper btBvhTriangleMeshShape that would return a TRIANGLE_SHAPE_PROXYTYPE. I can use osgBullets visitor to gather all vertices from the osg node. But I don't know how to construct a compatible btBvhTriangleMeshShape.
And I am not sure how I should alter the shape creation to make a proper btBvhTriangleMeshShape that would return a TRIANGLE_SHAPE_PROXYTYPE. I can use osgBullets visitor to gather all vertices from the osg node. But I don't know how to construct a compatible btBvhTriangleMeshShape.
-
- Posts: 31
- Joined: Tue Apr 26, 2011 5:52 pm
Re: btTriangleMeshShape to btTriangleShape (InternalEdges pr
Sorry i misunderstood the question. I'm affraid i do not know much on that side either
-
- Posts: 144
- Joined: Fri Aug 01, 2008 6:36 am
- Location: Bonn, Germany
Re: btTriangleMeshShape to btTriangleShape (InternalEdges pr
the function is not from Bullet... try write own, but returning btBvhTriangleMeshShape *,
the original is -
the original is -
Code: Select all
btTriangleMeshShape* btTriMeshCollisionShapeFromOSG( osg::Node* node )
{
ComputeTriMeshVisitor visitor;
node->accept( visitor );
osg::Vec3Array* vertices = visitor.getTriMesh();
if( vertices->size() < 3 )
{
osg::notify( osg::WARN ) << "osgbCollision::btTriMeshCollisionShapeFromOSG, no triangles found" << std::endl;
return( NULL );
}
btTriangleMesh* mesh = new btTriangleMesh;
for( size_t i = 0; i + 2 < vertices->size(); i += 3 )
{
osg::Vec3& p1 = ( *vertices )[ i ];
osg::Vec3& p2 = ( *vertices )[ i + 1 ];
osg::Vec3& p3 = ( *vertices )[ i + 2 ];
mesh->addTriangle( osgbCollision::asBtVector3( p1 ),
osgbCollision::asBtVector3( p2 ), osgbCollision::asBtVector3( p3 ) );
}
btBvhTriangleMeshShape* meshShape = new btBvhTriangleMeshShape( mesh, true );
return( meshShape );
}
-
- Posts: 65
- Joined: Fri May 13, 2011 1:11 pm
Re: btTriangleMeshShape to btTriangleShape (InternalEdges pr
where the
causes the btBvhTriangleMesh to identify as a Triangle mesh shape instead of a triangle shape as is expected by the internal edge utility.
So the question remains, how can I create a valid triangle shape?
And I have tried with just changing the return types, which does not work with the TriangleMesh created internally.
Code: Select all
btTriangleMesh* mesh = new btTriangleMesh;
So the question remains, how can I create a valid triangle shape?
And I have tried with just changing the return types, which does not work with the TriangleMesh created internally.
-
- Posts: 144
- Joined: Fri Aug 01, 2008 6:36 am
- Location: Bonn, Germany
Re: btTriangleMeshShape to btTriangleShape (InternalEdges pr
AFAIK, Bvh shape is always TRIANGLE_MESH_SHAPE_PROXYTYPE ... but may be i don't understand the questions... anyway, you can also set up mesh interface like that
Code: Select all
btTriangleIndexVertexArray * mesh_interface = new btTriangleIndexVertexArray(
faces_size/12,
index_array,
3*sizeof(int),
j+1,
(btScalar *) &vertex_array[0][0],
sizeof(btVector3));
btBvhTriangleMeshShape * shape = new btBvhTriangleMeshShape(mesh_interface,true,true);
-
- Posts: 65
- Joined: Fri May 13, 2011 1:11 pm
Re: btTriangleMeshShape to btTriangleShape (InternalEdges pr
So how do I go from having a bunch of vertices to actually getting all parameters?
There seems to be another problem with using btBvHTriangleMeshShapes though:
in the bvhTriangleMeshShape header we see:
btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};
and in the internal edge util in btAdjustInternalEdgeContacts:
if (colObj0->getCollisionShape()->getShapeType() != TRIANGLE_SHAPE_PROXYTYPE)
return;
So logically no btbvhtriangle mesh can get it's edges fixed right ?
however in the demo (I checked) even though the shapes are created as TRIANGLE_MESH_SHAPE_PROXYTYPE, once they reach the callback, they magically appear as being TRIANGLE_SHAPE_PROXYTYPE, and nowhere in the code can I find what makes this happen.
There seems to be another problem with using btBvHTriangleMeshShapes though:
in the bvhTriangleMeshShape header we see:
btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};
and in the internal edge util in btAdjustInternalEdgeContacts:
if (colObj0->getCollisionShape()->getShapeType() != TRIANGLE_SHAPE_PROXYTYPE)
return;
So logically no btbvhtriangle mesh can get it's edges fixed right ?
however in the demo (I checked) even though the shapes are created as TRIANGLE_MESH_SHAPE_PROXYTYPE, once they reach the callback, they magically appear as being TRIANGLE_SHAPE_PROXYTYPE, and nowhere in the code can I find what makes this happen.
-
- Posts: 144
- Joined: Fri Aug 01, 2008 6:36 am
- Location: Bonn, Germany
Re: btTriangleMeshShape to btTriangleShape (InternalEdges pr
afaik, at the end the callback gets individual triangles, so probably it is not a mistake... not 100% sure, didn't use this code.... anyway may be the idea to use "btTriangleIndexVertexArray * mesh_interface" was not wrong because i have seenhowever in the demo (I checked) even though the shapes are created as TRIANGLE_MESH_SHAPE_PROXYTYPE, once they reach the callback, they magically appear as being TRIANGLE_SHAPE_PROXYTYPE, and nowhere in the code can I find what makes this happen.
"meshInterface->getLockedReadOnlyVertexIndexBase(...)" somewhere in void btGenerateInternalEdgeInfo (btBvhTriangleMeshShape*trimeshShape, btTriangleInfoMap* triangleInfoMap)....
-
- Posts: 65
- Joined: Fri May 13, 2011 1:11 pm
Re: btTriangleMeshShape to btTriangleShape (InternalEdges pr
Seemed to have fixed it and it's now getting through the callback.
Problem was a wrongly placed callback.
thanks for the help!
Problem was a wrongly placed callback.
thanks for the help!