Reference frame of imported mesh

Typically: "How do I... ", "How can I... " questions
Post Reply
arennuit
Posts: 58
Joined: 03 Oct 2014, 23:04

Reference frame of imported mesh

Post by arennuit »

Hello,

I have imported an STL mesh into VRep and I was pleased to see that the mesh was aligned by VRep in such a way that the origin of the STL mesh is aligned with VRep's origin.

Now I was also surprised to see that Vrep changed the reference frame of the mesh to locate it somewhere near the center of the bounding box (or so), and orient it in something which does not fully make sense to me.

I noticed I was able to re-orient the mesh's reference frame using Edit | Reorient bounding box | With reference frame of world so as to realign it with the reference frame as encoded in the STL file. This does not modify the mesh's reference frame origin though (only the orientation is modified).

This is problematic to me as I would like to import several mesh files (composing my full robot) and translate/orient them so as to rebuild my robot up in vrep. But with vrep modifying the position of the reference frame of my mesh I cannot measure relative positions of my parts in CADs and then apply these measure in vrep.

This makes it rather complex to import geometry in vrep. Have I missed something?

Regards,

Antoine.

coppelia
Site Admin
Posts: 8516
Joined: 14 Dec 2012, 00:25

Re: Reference frame of imported mesh

Post by coppelia »

Hello Antoine,

when you import a mesh from a CAD file (e.g. obj, stl, etc.), the file does not include any reference frame. The file only contains vertices and indices to those vertices, for the triangular faces. So, when you export a mesh from one application, the reference frame for that mesh is never written in the CAD file. Each application has a different way of setting the reference frame for a mesh. But the vertices are imported in the correct position. From there, you can simply translate/rotate the new mesh, but setting its absolute position/orientation doesn't make sense. So you can translate the imported mesh with:

Code: Select all

local importedMeshHandle=...
local p=simGetObjectPosition(importedMeshHandle,-1)
p[1]=p[1]+translationX
p[2]=p[2]+translationY
p[3]=p[3]+translationZ
simSetObjectPosition(importedMeshHandle,-1,p)
above code will translate the mesh by {translationX,translationY,translationZ}.
See also this post.

Cheers

arennuit
Posts: 58
Joined: 03 Oct 2014, 23:04

Re: Reference frame of imported mesh

Post by arennuit »

Thanks

DavBuss
Posts: 11
Joined: 07 Dec 2018, 13:57

Re: Reference frame of imported mesh

Post by DavBuss »

Hi,

I am facing the same issue as arennuit. I also need to position a mesh very accurately in Coppelia and to do so, I would need to use the frame in which the vertices of the mesh are expressed.

I believe CAD files do not necessarily include a reference frame explicit definition as such. However, the vertices contained within these files are necessarily expressed in a reference frame (otherwise, how would they be placed relative to one another?). This original expression frame is the one I would need Coppelia to use as reference for the imported shape.

Other softwares (like meshlab) will position an imported mesh by aligning perfectly this reference frame with their scene origin. Coppelia seems to somehow recompute the reference frame associated to a mesh (maybe using the center of a collide box?).

Is there a way to do so?
Best regards,
David

DavBuss
Posts: 11
Joined: 07 Dec 2018, 13:57

Re: Reference frame of imported mesh

Post by DavBuss »

Oups ! I just found out that during the importation of the mesh in Coppelia :
* unticking the auto-scale checkbox,
* choosing the correct vertical axis
did the trick :) ! The correct reference frame is used as reference for the shape I import.

Post Reply