Skew near edges of SceneGraph

Have jReality programming problems or questions? Post them here.
Post Reply
goose12
Posts: 11
Joined: Sun 24. Jul 2011, 03:08

Skew near edges of SceneGraph

Post by goose12 » Sat 17. Mar 2012, 05:51

I have encountered a problem that exists both in the tutorials, as well as in my own application. The problem is that when objects are drug near the edge of the SceneGraph, they are skewed (see images below).
centered_square.png
centered_square.png (12.26 KiB) Viewed 1522 times
skewed_square.png
skewed_square.png (34.91 KiB) Viewed 1522 times


The screenshot above comes from the CubeUnwrapped.java demo. The skewing is more exaggerated if I am zoomed out. To experience what I am talking about, open one of the tutorials, zoom out, then drag the object near the edge of the scene.

How can I prevent skewing from occurring, even if I am zoomed out?
Last edited by goose12 on Mon 19. Mar 2012, 01:21, edited 1 time in total.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Skew near edges of SceneGraph

Post by gunn » Sun 18. Mar 2012, 21:49

Are you sure that the effect you are observing is a mistake?

Consider the case of a sphere. When it's in the middle of the scene, the projection onto the viewing plane is a circle. What is its projection onto the viewing plane when it moves to the far left of the viewing window? Consider the line from the eye to the center of the sphere. This line does not meet the viewing plane at right angles (as it did the sphere was in the middle) but crosses this plane at a "skew" angle. The projection of the sphere onto this "skew" plane will no longer be a circle, but an ellipse elongated in the horizontal (x-axis) direction. If you zoom the camera out and move to the left of the expanded viewing window, the effect will become more extreme. This same effect applies naturally to any object, not just a sphere, and explains (in my opinion) why you are seeing this "stretching". Such effects are not part of normal vision since it only occurs due to the presence of a "viewing plane" which is not part of human vision; they occur only in cameras and in perspective rendering which do make essential use of such planes.
jReality core developer

goose12
Posts: 11
Joined: Sun 24. Jul 2011, 03:08

Re: Skew near edges of SceneGraph

Post by goose12 » Sun 18. Mar 2012, 23:50

gunn wrote:Are you sure that the effect you are observing is a mistake?
Your comments about the sphere helped me understand why this is happening. Apparently it is not a mistake, just a result of perspective rendering. What I should have asked was "Is there a way to eliminate the skew that occurs?" or something like that. Perhaps the skew effect is why Ronin asked "Is there any easy way to make the camera rotate around the content vs rotating the contents in front of the camera?"

I will look more into Ronin and Arve's posts on rotating the camera around the object.

If there is a way to eliminate the skewing effect with out rotating the camera about the object, please let me know.

P.s. Thanks for the quick reply. The support on this forum is great.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Skew near edges of SceneGraph

Post by gunn » Mon 19. Mar 2012, 09:45

(Am I losing my mind, or did the images in the original post change over-night? I remember a blue icosahedron, for example.)

Anyway, the pictures that are there now helped me to see that there is something else going on here. The drag tool that is built in to jReality is not a translate tool, but rather a "rotate around the camera" tool. When the object is far away and the field of view is small, this rotation is close to a translation and one doesn't notice. But when you increase the field of view, then things start looking funny if you are expecting the object to be translated. I ran the same tutorial with a real translation tool and created the image below. As you can see, the front face of the cube appears still square, as it should under a translation, and one sees the other sides of the cube in perspective (which were not visible in the posted images). The overall shape of the cube is stretched out as predicted in my previous post, but the effect seems realistic and not "skewed" at least to me.
forumPost-02.png
image using real translation tool
forumPost-02.png (9.04 KiB) Viewed 1519 times
The natural next question is, which translation tool did I use? Well, it's one that is not in the standard jReality distribution, but rather part of my own jReality-related development. The reason the standard JRViewer does not include a translation tool is due to the fact that some environments, such as virtual reality, do not use a mouse as an input device, hence there is no standard notion of "translate parallel to the viewing screen", whereas "rotate around the camera" is well-defined. But I think there are, nevertheless, translate tools in the standard jReality distribution. Perhaps there are others reading this thread who know more than I do and can provide pointers to the appropriate tools. You would then need to remove the DraggingTool currently included in the content node, and replace it with the translate tool
jReality core developer

goose12
Posts: 11
Joined: Sun 24. Jul 2011, 03:08

Re: Skew near edges of SceneGraph

Post by goose12 » Sat 24. Mar 2012, 23:34

Thanks, can anyone point me towards the tool that I should be using for translation??

goose12
Posts: 11
Joined: Sun 24. Jul 2011, 03:08

Re: Skew near edges of SceneGraph

Post by goose12 » Tue 27. Mar 2012, 09:07

Code: Select all

camera.setPerspective(false); 
that fixed it.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Skew near edges of SceneGraph

Post by gunn » Tue 27. Mar 2012, 20:40

Cool! 8) I didn't think about that :o: A non-perspective camera is essentially "infinitely far away", and a rotation around an infinitely distant point can't be anything else but a translation! That fixes the problem without having to write a new tool at all. :D
jReality core developer

Post Reply