jPCT - a 3d engine for Java => Support => Topic started by: paulscode on April 11, 2013, 04:53:59 pm

Title: Countering visual y-offset from depth
Post by: paulscode on April 11, 2013, 04:53:59 pm
I recall seeing a thread about this, but wasn't able to find it (and I apologize for using the wrong terminology).  I am looking for a way to counter the effect of the 2D y-position of an object changing the further away it is from the camera.  I drew up a simple diagram of where I'll be using this (this is an overhead view):


Note that this represents just one screen -- the full world will be longer, and the camera will move horizontally to follow the character.  The idea is to have a simulated 2D world with 3D characters and 2D billboarded objects in the background.  The visual y-offset with this setup causes the trees to float up off the ground the further away they are (which would be the desired behavior in a fully 3D world but not in a 2D world).  A couple of ways I could counter this:

- Apply a formula to modify an object's y position based on it's distance (I'm not sure what formula to use)

- Use reproject2D3DWS to calculate the furthest two corners of a "ground polygon", and snap the background objects to it

Any thoughts on the best route to go?
Title: Re: Countering visual y-offset from depth
Post by: EgonOlsen on April 11, 2013, 10:16:23 pm
I think i remember the thread you are thinking of, but i can't find it either. I've no idea what it actually was about and what i should search for... ??? Anyway, i think that solving it with some formula should be the easiest way. I've no out-of-the-box solution for it, but given that double the depth means half the scale, it should be possible to derive something from the perspective projection formula. If that doesn't work out, the pragmatic solution would be an option too.