I searched a lot for that can’t find what I did wrong. It’s been like hours that I tried to make a triangle “solid”. I use the SimplexCollisionShape class to do so but it doesn’t work…I cant find where is it from. Maybe you guys can help my sorry bottom ? Here’s my code :
for(int l = 0; l < this.triangles.size(); l ++){
Mesh newMesh = new Mesh();
Geometry newGeom = new Geometry("newTriangle", newMesh);
Material mat = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
ColorRGBA color = new ColorRGBA((138.0f+(l*2))/ 255.0f, 68.0f/255.0f, 154.0f/255.0f, 1.0f);
mat.setColor("Color", color);
newGeom.setMaterial(mat);
//Important buggy part
SimplexCollisionShape triColl = new SimplexCollisionShape(this.triangles.get(l).get1(),
this.triangles.get(l).get2(),
this.triangles.get(l).get3());
RigidBodyControl triControl = new RigidBodyControl(triColl, 0.0f);
newGeom.addControl(triControl);
Eveything seems fine : I create a triangle inside the this.triangles list, I convert them to meshes and those triangles displays in a good way. But the collision debug lines dont appear on the triangles and my character passes through those triangles. They have no collision.
Any idea or suggestion guys ? Thank you in advance.
Yeah, that’s what I said : with physicsSpace.enableDebug(assetManager) on, the physic triangle doesnt appear (I guess it should translate as a blue triangle, as my boxes get two triangles with blue borders on their faces). But the visual triangle (the mesh) appears without errors.
Here’s an update. This morning, I found out that the SimplexCollisionShape is actually created but the coordinates of the points of this “collision shape” are wrong.
See the image below extracted from my tests : the light green thing is a box, representing the floor. It has a collision box which works good. I can walk on it and I can see it with the debug shapes on, so I do not have a problem with the physic space.
The dark green thing is the terrain I want to create. It is made of triangles, and it displays in a good way (though we cannot see it on this image). The yellow triangle is the result of my tests. It has been created with the test case code I posted.
You see these two blue dots ? I couldn’t figure out what it was, so I commented the yellow triangle section and figured it made one of the blue dot disappear. The remaining blue dot is in the middle of the terrain (dark green stuff), so it is in fact the SimplexCollisionShape ! Why doesnt it follow the triangles shapes ? it’s like every points of the SimplexCollisionShape is at the same coordinates.
Okay, it seems that SimplexCollisionShape is broken. I decided I’ll use a MeshCollisionShape instead. Not a great solution in optimisation, I think but that’ll do for the moment.