Page 1 of 1

.OBJ import

Posted: 10 Mar 2015, 22:40
by johnh
Hi

When importing some mesh from an OBJ file it seems that V-REP (current version) maps the first coordinate of a vertex in the the OBJ file to y, the second to z and the third to x. Also it rotates the resulting object by (0 0 90) in Y-up mode and by (-90 0 -90) in z-up mode. This makes life a bit complicated.

Is there a way to tell V-REP to map the first vertex coordinate to x etc and not to apply any rotations?

Thanks, John.

Re: .OBJ import

Posted: 10 Mar 2015, 23:13
by coppelia
Hello John,

as you may know, the OBJ format does not specify what axis is up, or what coordinate system is used. When V-REP reads (x;y;z), it will take it as it is. But: in V-REP, the Z axis is pointing up. In other applications, the Y axis is pointing up. So it always depends what application you have used to export the data, and what application you are using to import the data.
The same considerations go to the units: there is no unit in most mesh formats. Some applications save data as mm (i.e. "1.0" is 1mm), others as meter (i.e. "1.0" is 1meter, what V-REP does). There is no right or wrong. It is just a different convention.

Cheers

Re: .OBJ import

Posted: 10 Mar 2015, 23:41
by johnh
Hi

This is my test OBJ file - just a triangle with bounding box 2x3x0

v 1 1 0
v 1 4 0
v 3 4 0
f 1 2 3

I understand that units and direction of axes are arbitrary, but I would still have expected the bounding box to be 2x3x0 after import. However it is 0x2x3 .. that is, the x coordinate in the obj file becomes the y coordinate in v-rep etc. That doesn't seem to be taking it as it is!

Sorry if I'm misunderstanding something .. likely enough.

Re: .OBJ import

Posted: 11 Mar 2015, 22:04
by coppelia
When you import the CAD data, you have a dialog popping open that allows you to select the scaling, but also the orientation of the up-axis. Make sure to check that out, the imported data will not be same depending on the options you checked.

Cheers

Re: .OBJ import

Posted: 14 Mar 2015, 20:09
by johnh
To get the vertices ending up at the right position in world coordinates I found I had to map -y to z and z to y and then import
with y-axis up. (Probably there's a similar transformation that would work when importing z up).

For example, my original triangle

v 1 1 0
v 1 4 0
v 3 4 0
f 1 2 3

whose initial vertex is intended to be (x, y, z) = (1, 1, 0) etc

imports with vertices in the right places in the world frame if I rewrite it as

v 1 0 -1
v 1 0 -4
v 3 0 -4
f 1 2 3

I still think this is odd behaviour on V-REP's part, but giving this recipe in case it helps anyone else struggling with this.

Thanks.

Re: .OBJ import

Posted: 15 Mar 2015, 22:41
by coppelia
You also have to be aware that some applications work with right-hand coordinates (i.e. V-REP), others with left-hand coordinates. This combined with other conventions about the up-vector and the other conventions about the units can produce mix-ups.
Try one of the many obj-cad models you can find on the internet: you will see that with 99% of them, you simply need to adapt the up-vector, and/or the units.

Cheers