ammo.js icon indicating copy to clipboard operation
ammo.js copied to clipboard

Can't seem to make Ammo.btConvexTriangleMeshShape work properly

Open JesseKirschner opened this issue 13 years ago • 2 comments

The title says it all. Although there is some dynamics (an object falls), all the rest is simply not happening (interaction with other objects in a normal way).

this is my code:

var triTransform = new Ammo.btTransform();
triTransform.setIdentity();
triTransform.setOrigin(new Ammo.btVector3(0, 3, 0));

var verti = [];

verti[0] = new Ammo.btVector3(-1.5, -.612, -.866);
verti[1] = new Ammo.btVector3(1.5, -.612, -.866);
verti[2] = new Ammo.btVector3(0, -.612, 1.732);
verti[3] = new Ammo.btVector3(0, 1.837, 0);

verti[0] = new Ammo.btVector3(0, 0, 0);
verti[1] = new Ammo.btVector3(1, 0, 0);
verti[2] = new Ammo.btVector3(.5, 0, 1);
verti[3] = new Ammo.btVector3(.5, 4, .5);

var triMesh = new Ammo.btTriangleMesh();

triMesh.addTriangle(verti[0], verti[1], verti[2], true);
triMesh.addTriangle(verti[1], verti[0], verti[3], true);
triMesh.addTriangle(verti[2], verti[1], verti[3], true);
triMesh.addTriangle(verti[0], verti[2], verti[3], true);

var triShape = new Ammo.btConvexTriangleMeshShape(triMesh, true);

this.shape1 = this.localCreateRigidBody(1, triTransform, triShape);

I am programming this in an environment made by schteppe (big ups for that really nice environment) so the motionstate and rigidbody are created in localCreateRigidBody, where a THREE object is linked to this as well.

In the C++ bullet written examples I see them using btHullShape when using the convextrianglemeshshape, this hullshape is missing in Ammo. Maybe this is where the problem lies? Elsewise I am lost...

Greetings Jesse

JesseKirschner avatar May 05 '12 08:05 JesseKirschner

Try using btBvhTriangleMeshShape instead. I had similar issues. some shapes require to work with btBvhTriangleMeshShape and other with btConvexTriangleMeshShape. Those are my finsings in any case...

dataexcess avatar Nov 05 '22 09:11 dataexcess