LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

translating object in 3D picture control distorts perspective

Hi, I'm using LabVIEW 8.6. I've created a simple 3D vehicle (couple boxes and 4 cylinders) that I'm trying to translate along the x-vector in the 3D Picture control. When the object is at x=0, it looks fine. But, when I translate the object along the x vector, its perspective radically distorts. Do I need to do something with the camera setting or the object scale or other settings to get this perspective view to be a little more realistic?

I've attached an image that shows the object in the center and at one extreme position.

 

Thanks,

 

Tobin

0 Kudos
Message 1 of 10
(3,785 Views)

Greetings Tobin,

 

Personally I've found the 3D picture control to be tricky to use so I understand any confusion on this.  If you could post a screenshot of your code (at least the translation / manipulation / and if possible, object creation sections) so that I can get a better idea of the methods, VIs, order, etc. 

 

Quite frankly, I'm not sure that it is a problem with the perspective so to speak; it may be a odd issue with the object transformation. 

 

Michael G

Michael G.
Applications Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Self-realization: I was thinking of the immortal words of Socrates, who said, "... I drank what?"
0 Kudos
Message 2 of 10
(3,766 Views)

I experienced a similar bug long ago and found a workaround. Can you post some simplified code?

In the meantime I'll try to dig up my old program....

0 Kudos
Message 3 of 10
(3,763 Views)

I created the 3d model using the "Robot Simulator.vi" that I downloaded from NI.

http://decibel.ni.com/content/docs/DOC-2430

I then created a simple vi that was to be used in a larger app that would display the articulation and translation of the 3d object.

I took code portions from the Robot Simulator referenced above and then started playing with ways to get the translation to work.

I've attached the code and a model. Code is for LabVIEW 8.6

This is my first attempt at using the 3D picture control.

 

Note: the file SSL translate.txt should be renamed with .dat extension. I had to change it in order to attach it.

Download All
0 Kudos
Message 4 of 10
(3,760 Views)

Hi Tobin!

 

I've worked with your project some to see if I could notice anything that might be the cause of the distortion.  While I never came to a perfect solution, I did notice some slight improvement by adding an invoke node for "Projection" and experimenting with the various options and values there.  You might want to take a look and see if adding some settings for that will remedy the distortion enough for your application. 

 

SceneGraphDisplay Methods

http://zone.ni.com/reference/en-XX/help/371361G-01/lvprop/scenegraphdisplay_m/

 

Hope this helps a little.

 

Regards,

 

Michael G

Michael G.
Applications Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Self-realization: I was thinking of the immortal words of Socrates, who said, "... I drank what?"
Message 5 of 10
(3,736 Views)

Michael,

 

Thank you for your efforts (3:00 AM?!). I've tried each of the three Projection invoke nodes. The Projection.Orthographic removes all perspective shaping, which for my purposes, will work fine.

 

I can't tell the difference between Projection.Perspective and Projection.Frustum. To me, it appears that the object shaping (for perspective effect) is linked to the scene's point of origin and not just to the object position relative to the camera.

 

Thanks again for your help.

0 Kudos
Message 6 of 10
(3,732 Views)

Hi Tobin,

 

Projection.Perspective sets coordinates to render the scene in a frustum-shaped view, where you specify an angle for the horizontal and vertical viewing fields. This projection causes objects closer to the camera to appear larger in size.

 

Projection.Frustum also sets coordinates to render the scene in a frustum-shaped view. This projection causes objects farther from the camera to appear smaller.

 

The difference bewteen the two are the parameters that can be altered. With Projection.Perspective, the field of view and the aspect ratio can be set. With Projection.Frustrum, the top, bottom, left, and right boundaries of the frustrum can be customized. I'm glad Projection.Orthographic will work for you. It actually sets coordinates to render the scene in a box-shaped view. The distance of the camera from the objects does not affect the size of the objects in this view.

 

Jordan G

0 Kudos
Message 7 of 10
(3,702 Views)

Jordan,

 

That explains why I can't tell the difference. They both result in a frustum-shaped view. However, I truely believe that the math for this projection calculation is flawed. To me, it appears that the perspective calculation makes the assumption that the camera is along a vector that begins at scene coordinate 0, 0, 0, passes through the primary object and then reaches the camera. In this case, the camera would only be in line with the observer when the object is centered in the scene. When the object is placed at an extreme edge of the 3D picture control scene, the stretched portion of the object is away from the observer. This is incorrect.

 

Tobin

0 Kudos
Message 8 of 10
(3,689 Views)

Tobin,

I'm going to see if I can get some more specific information regarding the scene coordinates and the relationship between the object and the observer. In the meantime, I was searching our Community site for examples using the 3D Picture Control. This is one example I came across:

http://decibel.ni.com/content/docs/DOC-2109

 

It makes use of many of the Transformation VIs located under the 3D Picture Control panel in the block diagram of LabVIEW and is set up in such a way that we are able to rotate with no distortion in the 3D Picture. I'm unsure of your end goal with the VI you've created, but thought this code might be something you would be interested in.

 

Jordan G

0 Kudos
Message 9 of 10
(3,668 Views)

Jordan,

 

I looked at the SolarSytem.vi a couple years ago. That is what gave me the desire to add a 3d picture control to my recent project.

However, now that I view it with a more critical eye, I can see that it suffers from the same perspective problem that I have encountered. since each object in solarsystem.vi is a sphere, the object geometry should appear as a true circle regardless of the camera position, only the circle size should change. The texture mapping should show enlarged details for the region nearest the camera and compressed details near the edge of the circle (farther away from the camera than the center of the circle).

 

If I run solarsystem.vi with the Scene Window as the Render Destination and set the Camera Controller to Flying, then it is clear to see the planets do not remain circular when they are placed near the edge of the Scene Window. This gets really exaggerated when the Scene Window is sized to be short and wide. The objects are more circular when near the center of the Scene Window and more distorted at the edges of the window.

 

For my purposes, using the orthographic projection is my best option.

 

Tobin

0 Kudos
Message 10 of 10
(3,650 Views)