Hello,
I have always wondered how any kind of asynchronous animation would work. I can do animations but all of them are always timed (as an example, a sphere loop-orbiting around something since and for ever) made with something like “angle=(angle+x)%360” inside a never ending timer function. I apologize if this is not a speciffically OpenGL related one but I guess this is the best place to post here.
By asynchronous I would mean any rendering action that would happen at an unknown or random moment, and with limited duration. As examples, a character that would stop and walk after random timeslices or something that moves only when a button is pressed and eventually stops.
I have thought on some ‘status’ scheme (haven’t tried implementing it so far). Using the character example and being every character an object: if status Walk then walk or if status Stop then stop. Status changes by chances over time. However this would require a check in every clock. Something like:
for every clock do
generate random number 0-99
if number < 5 then //for a 5% chance of changing status
swap status
endif
if status=walk then
increments position
endif
endfor
Also, I wonder if I would have to keep two timers for this. Like one for frame rendering and other one for this kind of event handling?
The same clock for frame rendering would be just weird for me. I also wonder if there’s no problem to run more than one timer at once, and what would be their frequency (probably the event timer faster than the rendering timer…).
That is, i can only think on a solution where there would be a timer and chances for things to start happening and finish happening. Is it an okay thought?
Sorry if this was a somewhat noob example and/or question, it’s just that I cant really think on how to Google for that, and would like some guidance.
Thanks in advance, any input will be appreciated! (and sorry for any bad english, Brazil here.)