The collision is strange after using AddTriangleMesh

121 views
Skip to first unread message

Page

unread,
Nov 29, 2023, 4:03:11 AM11/29/23
to ProjectChrono

Hi,all

I write a simple demo, I built a ChBody, use AddTriangleMesh, add a cube mesh, so that two cubes do collision, but the collision effect is obviously wrong, I hope someone can help me, the following is the code and demonstration video

code.docx
collision.mp4

Radu Serban

unread,
Nov 30, 2023, 3:02:20 AM11/30/23
to ProjectChrono

Page,

 

First of all, please attach code as a text file, not a Word document!

 

There are many issues with the code you provided and it’s not clear to me why you are trying such a low-level approach when other solutions are available. If you are convinced you need to create a ChTriangleMeshConnected programmatically (hopefully for something other than a box), please first make sure you understand well how those work and how they should be created.

 

Having said that, one problem with your code is that you define the mesh with normal pointing inwards. The order of the vertices in each triangle follows the right-hand rule.

 

--Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/e35df334-7e57-4030-9a14-38c6a60e37a7n%40googlegroups.com.

Page

unread,
Dec 2, 2023, 2:19:47 AM12/2/23
to ProjectChrono

Hi,Radu

Thank you very much for your prompt reply. The issue you pointed out is correct: I made a mistake in the direction of the normal. When I corrected this issue, it seems to work properly. In this demo, I just tested using a triangular mesh for collisions, and in the future, I will use complex models for precise collisions

 

You mentioned that there are many issues with my code, can you help me point them out? Thank you very much. I am very interested in this physics engine

 

--Page

Radu Serban

unread,
Dec 3, 2023, 8:23:35 AM12/3/23
to ProjectChrono

Hi Page,

 

The issues I was referring to are related to misuse of a connected triangular mesh. What you created is a “triangle soup” with no connectivity information.  That is not the best way of specifying a collision mesh. You should read more carefully the description of a ChTriangleMeshConnected and generate all its information. But even better is to use a mesh specified in a Wavefront OBJ file and let Chrono read it and create the corresponding collision object.  There are only very few situations where one would need to create a trimesh programmatically. Not knowing what exactly your end goal is, other issues with the code you provided could be: using a trimesh when a convex hull would do (more efficient collision shape) and not sharing the geometry (assuming you have multiple objects/bodies with the same collision shapes.

Page

unread,
Dec 6, 2023, 8:41:46 PM12/6/23
to ProjectChrono

Hi,Radu,

Thanks for your advice, my project is working normally, I will use chrono engine in my project, I can't read the data of obj directly, I have to read the data from a more complex model format, such as a cube in my project, the cube has 12 triangular facets and 36 vertices. Each of the three vertices forms a triangular face, and I put these three vertices in turn into trimesh. 

Thanks again for your help,

-Page

Reply all
Reply to author
Forward
Message has been deleted
0 new messages