Import 3D model shapes with the original orientation via script

Typically: "How do I... ", "How can I... " questions
Post Reply
Uio96
Posts: 6
Joined: 09 May 2019, 20:08

Import 3D model shapes with the original orientation via script

Post by Uio96 » 14 Jul 2019, 19:37

Hi there,

I have difficulty in importing 3D model shapes with the original orientation via script. It has no problem to import the shape by clicking on file->import->mesh with the default settings(the up vector is set to auto mode). The imported shape would be in the exact same direction which I designed in SketchupPro and exported to .obj file.

However, when I tried to use lua script, things turned to be different. I used the simImportShape function like sim.importShape(0,pathAndFilename, 32, 0, 1). By setting the option code to 32, I wanted to realign the shape's bounding box with the world. But the imported shape would be rotated like 90 degree compared with the previous one by manual action.

I once tried to set the option code to 128 to ignore up-vector coded in fileformat. But it didn't help. I also found that not every shape will face this kind of problem. Do you have any good ideas? If necessary, I can provide you with my .skp and .obj files.

BTW, I am using the latest vrep of v3.6.1.

Thank you so much.

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

Re: Import 3D model shapes with the original orientation via script

Post by coppelia » 15 Jul 2019, 06:52

Hello,

you can't really control the position or orientation of a shape reference frame: the reference frame of a shape is automatically selected to be at the geometric center of the shape. Orientation is also selected to form the smallest bounding box around your shape.

But the shape itself (the vertices and triangles making up the shape) should remain the same.
Have you tried using simAssimp.importShapes function?

Cheers

Uio96
Posts: 6
Joined: 09 May 2019, 20:08

Re: Import 3D model shapes with the original orientation via script

Post by Uio96 » 16 Jul 2019, 22:39

Thank you so much.

Several days ago, I figured out the problem by myself. I found that if I chose y-direction as the up-vector, the shape will remain the same direction as I designed in SketchPro. So I first aligned the bounding box with the vrep environment, then rotated it to make y-direction as the up-vector.

I have not tried the function you mentioned yet. Maybe it is a good idea.

Post Reply