Shape(Mesh) Edit Mode by Code

Typically: "How do I... ", "How can I... " questions
Post Reply
vinicius
Posts: 2
Joined: 25 Jul 2023, 16:21

Shape(Mesh) Edit Mode by Code

Post by vinicius »

I want to represent soil being deformed by a wheel. I have found a page that teaches how to edit a mesh by mouse:
"https://www.coppeliarobotics.com/helpFi ... itMode.htm". The button showed in this page is called "Toggle shape edit mode" in my version of CoppeliaSim (4.3.0 rev.12). It allows me to select triangles, vertex or edges. Once I have one entity selected, I activate "Object/item shift" and them I can drag the entity with the mouse, deforming the shape.
I wanted to do this by code, an Associated child script in Lua for example, or by other means. Do you guys know if it is possible to edit vertex or triangles of a mesh by code? I want to create a thin cuboid, discretize it in hundreds of triangles, and then deform the triangles or vertex downwards when the wheel is closer than an epsilon to the entity, and with this, leave wheel marks in the soil(mesh). Thank you in advance.
fferri
Posts: 1334
Joined: 09 Sep 2013, 19:28

Re: Shape(Mesh) Edit Mode by Code

Post by fferri »

With code, you can remove the old mesh (sim.removeObjects) and create a new one (sim.createShape, or sim.createMeshShape in older versions).
vinicius
Posts: 2
Joined: 25 Jul 2023, 16:21

Re: Shape(Mesh) Edit Mode by Code

Post by vinicius »

Thank you for the functions.
There is a video from Coppelia Robotics channel in youtube called "Milling Robot in V-REP" (youtube.com/watch?v=7pKyPNpYsr8) in which material is carved out in real time. This seems similar to the terrain deformation I want to represent due to a wheel. In the case of the milling video, does anyone know if that is achieved by modifying a shape during simulation or by removing and re-inserting the shape every simulation step? If I want to follow a similar approach, it it better that I try the functions you provided or Heightfield object (edit/remove/create)? Another question: there aren't API commands to directly edit mesh vertexes, right?
coppelia
Site Admin
Posts: 10747
Joined: 14 Dec 2012, 00:25

Re: Shape(Mesh) Edit Mode by Code

Post by coppelia »

Hello,

Milling operation actually modified the mesh, but this is not supported anymore, since not scalable. Best you can do is to regenerate the shape/heightfield over any over again, drastically slowing down the simulation.

Cheers
fferri
Posts: 1334
Joined: 09 Sep 2013, 19:28

Re: Shape(Mesh) Edit Mode by Code

Post by fferri »

Or use an octree...
Post Reply