Usage of ConvexMeshShape with collider #264
-
I am getting difficulties with creating a convex mesh and adding a collider to it. I have taken the example straight from the manual (https://www.reactphysics3d.com/usermanual.html#x1-5100011.1.4), but I am not getting the expected result. The segment of code where I try to add the convexMeshShape of a cube is the following:
The expected outcome should be a cube with dimensions 6x6x6. The result I am getting is that the cube is not interacting appropriately with other objects in the scene, such as spheres and boxes created with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello, I am not sure this is the issue but do not forget to compute or set a correct inertia tensor for your body as described in the documentation here. For instance, you can call the If it is not better, you can try to take a look at this code in the testbed application. That's the code that create a ConvexMeshShape. Maybe it will help to figure out what is wrong. Also note that you can use the DebugRenderer of the library to display the faces of your ConvexMeshShape in order to see if everything is correct. |
Beta Was this translation helpful? Give feedback.
-
I took the time to try again with the code from the documentation. I replaced the code that creates a ConvexMeshShape in the testbed application here by the code from the documentation that creates a simple cube and it's working fine. If I display the collision shapes in the tesbed application, I can see that the collision shape is now a cube. Can you check in your code that your your array of vertices, indices, PolygonFace, your PolygonVertexArray and PolyhedronMesh are persisted in memory and not destroyed right after the ConvexMeshShape creation. As written in the documentation (see quote below), those objects needs to persist in memory during the whole simulation not just during collision shape creation.
|
Beta Was this translation helpful? Give feedback.
I took the time to try again with the code from the documentation. I replaced the code that creates a ConvexMeshShape in the testbed application here by the code from the documentation that creates a simple cube and it's working fine. If I display the collision shapes in the tesbed application, I can see that the collision shape is now a cube.
Can you check in your code that your your array of vertices, indices, PolygonFace, your PolygonVertexArray and PolyhedronMesh are persisted in memory and not destroyed right after the ConvexMeshShape creation. As written in the documentation (see quote below), those objects needs to persist in memory during the whole simulation not just during colli…