Author Topic: Method to make objects stay the same size with distance?  (Read 3622 times)

Offline Darkflame

  • int
  • **
  • Posts: 55
    • View Profile
Method to make objects stay the same size with distance?
« on: February 02, 2011, 02:10:50 pm »
I'm working on a little AR app, and it would be helpfull if there was a way to make billboard sprites not scale with distance.
That is, if they are far away they are the same size as near.

I figured theres two ways of doing this, and I wondered if anyone could give feedback on what seems the best and what sort of maths would be required;

1. Each time the camera moves scale all the billboard sprites to compansate.  This would mean mesuring their distance to then camera [insert formular] and scaleing based on that.

2. Drawing the sprites directly to the screen not using the 3D scene at all - obviously this takes care of the scaleing easily, but raise's issues such as drawing order and positioning.

I'm guessing number 1 will be more flexible, and 2 would be more efficiant in terms of cpu.
Number 1 would also let me scale by other methods too if I wished - like getting slightly smaller with distance rather then realisticly exponetialy smaller.
The camera in my app shouldn't be moving too much - walking pace in a city with gps updates probably means only once every few seconds at most.

So..and ideas on the direction I should take?



Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Method to make objects stay the same size with distance?
« Reply #1 on: February 03, 2011, 08:41:31 pm »
I would go with 1. Rescaling is pretty simply as scale is linear with distance. Another option might be to use an Overlay for this. It's like a scaled blit but can have a depth. You need the latest beta release to use it properly though.

Offline Darkflame

  • int
  • **
  • Posts: 55
    • View Profile
Re: Method to make objects stay the same size with distance?
« Reply #2 on: February 03, 2011, 09:33:14 pm »
Thanks, I'll go with that one.
Is it really just linear? Wouldn't it depend on lens/fov?

I'm basicly going to measure the distance between the objects and the camera and set their scale equal to there existing scale times that value.  That seems...wrong..though. Too easy :p

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Method to make objects stay the same size with distance?
« Reply #3 on: February 03, 2011, 10:11:52 pm »
Of course it depends on the fov and such but its still linear within the same fov. That's because the perspective projection basically is a divide by z.