From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3D Scene get coordinates of object relative to "world origin"

Hi,

I added an object (.stl format) to a 3D Scene and everything works fine. The Problem is, that the stl-Object is originally created in FreeCAD with an own coordinate system with its origin at [1000,100,50]. If I add this object to the 3D Scene, it is located at [1000,100,50].

Now I want to set it to the world coordinates origin (the point, that is used, when I set [0,0,0] as target for "Setup Camera", in this case the "world origin") that i can rotate the object around this point. I want to use the VI for other objects too, so a hardcoded translation of [-1000,-100,-50] is not possible.

Is there a way to get these coordinates relative to the "world origin"? I tried to use "get translation" but it doesn't work, because there is no translation of the object in the picture. I also tried to open the .stl-file with a Texteditor to get this Information, but there is just illegible "nonsense" 

I added a picture of my code so far.

Hope, anyone can help me with this problem 🙂

0 Kudos
Message 1 of 6
(2,382 Views)

In addition to providing us data (thank you!) to examine, how about providing us the code you are using, which saves us a lot of time and lets us (if we can figure it out) show you how to handle such translations?  You need to attach actual code (meaning VIs, TypeDefs, etc. that you are using).  If it is 1-3 VIs, just attach them.  Otherwise, if they are in a LabVIEW Project contained within a single Folder, compress the Folder and attach the resulting .ZIP file.

 

Bob Schor

0 Kudos
Message 2 of 6
(2,343 Views)

As I see it, the origin of the file is 0,0,0.

 

It's just that all coordinates in the model are far from the origin.

 

From a stl SceneMesh, you can get the VertexArray from a property node. You can go over all coordinates, get the min and max x, y and z. Probably values around 1000, 100 and 50. Take the average of the x min\max, y min\max and z min\max and use that to translate the model.

 

Of course you can make variations on the avg of min and max. Perhaps the average of all points? Or a median or something? Your mileage may vary.

0 Kudos
Message 3 of 6
(2,336 Views)

Hi, thank you for your answer. I will attach the VI and an example of a stl file. 

0 Kudos
Message 4 of 6
(2,304 Views)

Acutally, the stl is not exactly like the ones I'm working with. In this file, the sphere is just moved to the coordinates but still in relation to the original coordinate System. I can't attach an original file, as it is work-related. 

The attempt of finding the average of all points works with the sphere, but in my file(s), it doesn't.

 

0 Kudos
Message 5 of 6
(2,284 Views)

Ok, late reply, but I had 3 weeks off.

 

Do you know why it doesn't work for your file?

 

Does it work at all or not at all? I'm sure you won't find the exact middle (center of weight) of a model by averaging the coordinates.

 

If I had to guess, that file has one (or a few?) coordinates around 0,0,0 added, screwing up the average.

0 Kudos
Message 6 of 6
(2,236 Views)