www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Irony on July 14, 2014, 01:58:30 pm

Title: Keeping an object the same apparent size regardless of distance
Post by: Irony on July 14, 2014, 01:58:30 pm
When I call
setScale (distanceToCamera)
on an object, shouldn't it always appear at the same size regardless of distance?  It seems to not work that way, so maybe my thought is wrong?
Title: Re: Keeping an object the same apparent size regardless of distance
Post by: lawless_c on July 14, 2014, 06:26:08 pm
What is it doing?
Title: Re: Keeping an object the same apparent size regardless of distance
Post by: Irony on July 14, 2014, 06:57:54 pm
It is getting bigger when you are close. It's better than when there is no scaling done at all, but it's still very visible that the size changes.
I was thinking
twice the distance + twice the size => same apparent size,
but maybe I am thinking too simple?
Title: Re: Keeping an object the same apparent size regardless of distance
Post by: EgonOlsen on July 15, 2014, 08:46:24 am
How much does it change? Just subtle or quite visible? Your thinking seems reasonable to me, but maybe you are running into some accuracy issues with that approach.
Title: Re: Keeping an object the same apparent size regardless of distance
Post by: Irony on July 15, 2014, 09:40:58 am
It's subtle when the distance is > ~500 units
When you are very close it's very visible (multiple times the size)

As the use case is a particle effect, I guess I'll just use blitting instead of geometry.
Title: Re: Keeping an object the same apparent size regardless of distance
Post by: EgonOlsen on July 15, 2014, 03:39:53 pm
It's most likely an accuracy issue then. Due to the limitations of the floating point format, neither the distance nor the scaling will be 100% correct and depending on the distance, this inaccuracies might become noticable. I don't see how to fix this...
Title: Re: Keeping an object the same apparent size regardless of distance
Post by: Irony on August 15, 2014, 01:48:33 pm
Final update on this issue: it actually works exactly as it should the way I described. I was just stupid enough to not update the variable holding the distance.