Thursday, December 13, 2007

Evolution of Visibility Determination - II

I have a a fortunate side (can also be unfortunate at times) with me. Whenever I start working with a 100% focus on a project, I never tend to loosen that focus outside the work area. For instance way back in the day, when I started playing around with one of the greatest 3D modelling-rendering tools, 3D Studio Max there were times where I visualized pretty much everything in wireframe. Those who had a touch on 3D graphics probably know what I'm talking about. Well a similar case happened today. Here is the story:

I'm walking to one of my classes, trying 'not' to think about the current 2D Polygon Engine I'm working on, 20% because my brain needs to relax but 80% because I am actually walking to the class to take a Discrete Mathematics final. So I hear a sound far away, calling my name, and I look up to see some green shape, coming towards me.

- Hey Dogan, what's up?

Oh, nothin' much, only if I knew who you are not that I have a short term memory but mainly because I can't pick your figure from the distance. Here is what went through my brain from that moment through I actually found out what that green thing was:

~0-3 seconds: I saw: 'A SHAPE coming towards me, yelling my name'
~3-5 seconds: I saw: 'SOME GUY, walking towards me, calling my name, asking me what's up'
~5-5.5 seconds: I think: 'That it is THE GUY that sits by me in my class, could be, I'm not sure, better wait...'
~5.5-6 seconds: I'm sure that: 'It is HIM. I better call his name if I want to avoid this weird situation. Standing in the middle of the street trying to think about what's going on in the brain might not be what a person should be doing when someone asks what's up.'

And I said nothin' much. Ready for the final?
So from the moment I saw him, it took me about 8 seconds to actually realize what the shape was, who it was and so on...So kept that thought process aside, took my final and now I am here, with the same thoughts again, this time sitting beside my 'thought transformation tool', or some say 'the computer'. I am actually writing this right now, instead of studying for my Film Musics elective final tomorrow partially because I think I can wing some essay on 'The development of Electronic Music in Film' and partially because I can't keep these thoughts on my brain too much.
Going back to the problem... Currently the visibility determination tool I am programming is on a state where if you attach it to an object, that object can see another figure that is inside the object's triangle of visibility. With my experience today, I right now want to improve this and add an illusion of the process I went through today.
Opening up the development tool...
So, right now, since I want to create the illusion of the gradual improvement of vision with distance, I know that I need to call the eye let's say 100% vision and the furthest point I can see 0% vision. This means that the vision quality will increase with an inverse proportion to the distance.

Adding the vision variable...

Onto the function. So what I'm thinking is that, If I start the vision from zero always, I can create a function that gradually increases the vision percentage up to one hundred percent. But, imagine the real life situation as I gave in seconds above, our vision gradually increases but as it gets closer, the speed that it increases gets faster which not very surprisingly looks like a quadratic function.

So I want to implement that probably on my 'update-the-whole-thing' function.

And voila!

Unfortunately, the current status of the engine does not allow minimizes and resizes so I can't really use text-wise debugging tools to see if the function outcome is right. So what I did was, I wrote a getter function that gave me the vision_percentage. In the client, I used it to change the color of the polygon from 0% green to 100% green and used it for debugging. If the color changed too slow, I increased the 'fairly large constant' and added a couple more housekeeping tools.
Remember, visualization is the most important debugging tool.

1 comment:

Gazillion said...


How will you handle an object that is in the field of view but hidden by another object?