Friday, April 20, 2007

Objects May Appear Further Than They Are

For a while now I have been looking for a way to visualise things for gaming purposes. For example, if your character is sitting out three thousand feet from a cave and a figure comes out of the cave how "big" does that figure appear to be? Likewise, how big of a target is a robot coming in from a mile out? You can do it in the inverse too. Your character is stranded on an island. They want to make an S.O.S. on the beach out of rocks and branches. How big do you have to make the letters to be seen by a search plane?

To solve this dilemma, since I have great difficulty visualising distances and heights and such, I got together with a friend and we developed a formula to determine how "big" something is at varying distances. To make it useful we did the calculations to determine what font size would be the equivalent of the perspective height for an object. The results are available at as well as a several examples. Below the examples is a JavaScript that calculates the font for you. Also, I have added an internal frame that takes the calculation and displays an example of how tall the object will appear.

The work to make the calculator took me some time and definitely a good bit of brain wracking. First I found a place with an example script that calculated house payments based on factors the user supplied. It was important that anyone could come in and plant numbers into a form and then the calculator function would do its thing. The math is of course easy as pie. However, when you don't really know how to pass variables in and out of functions there is a bit of a learning curve to modifying an existing script. I did, as can be seen, sort it out. The form even disallows for either of the fields to be zero.

The work to make the visual example took about the same mount of time, which is not very good. It ran into two snags. First the zero checking will not work. Second, if you clicked the button to display the text at the calculated font size the web page would change. While you got your example you couldn't see what the font size was, which is useful if you want to take that number and use it in another program. Also, being a new page you had nothing to compare it to, such as the examples I have higher on the page. The answer was of course to use a frame. I don't mind the IFRAMEs so it was a good solution. There you have it.

Mood: conflicted.
Music: April Ethereal by Opeth and Always by Bon Jovi.

Opeth: My Arms Your Hearse
Buy these at
Click Images to Buy
Bon Jovi: Crossroad

Labels: , , , , ,


Post a Comment

<< Home