Re: Drawing and Animation (using Timers?)

From: Justin Rogers (Justin_at_games4dotnet.com)
Date: 08/21/04

  • Next message: Justin Rogers: "Re: Regions & DrawPath"
    Date: Fri, 20 Aug 2004 23:38:21 -0700
    
    

    You need some sort of timer to activate the animation logic. The recommended
    approach is to use a single high frequency timer that checks each animation
    sequence
    for a frame advance. A simple example might be:

    50 ms resolution timer
    Animation Sequence 1: 10 fps (100ms) with some variant frames of +/- a few ms
    Animation Sequence 2: 0.5 fps (2000 ms) with some portions of the sequence at
    10fps

    The general logic here is as follows:
    1. Upon each timer elapse check the sequences for a frame advance.
        a) Simple: Current Time > Next Frame Time
        b) Complex: Current Time > Next Frame Time or Next Frame Time within X ms of
    Current Time
    2. If a frame advance is encountered then call the rendering logic. Rendering
    logic should consist of:
        a) Compute clearing regions
        b) Invalidate or Direct Copy of new assets
    3. Compute next Frame Advance

    The logic here uses a single timer to manage multiple sequences. The ability to
    dynamically change the
    timing between portions of an animation sequence is key. For instance, you might
    have a sequence that
    displays a characters face for 2 seconds, then updates the mouth for half a
    second at 10fps, and then
    shows the face again for another second. Each step in the animation sequence
    requires timeslices of
    varying lengths. Setting up multiple timers for this is a pain and error prone.
    Having a single logical timer
    simplifies the situation.

    If you are interested in something more complete I might write a small article
    on this. Contact me through
    my blog if you are interested and then I can drop you a response once the
    article is posted.

    -- 
    Justin Rogers
    DigiTec Web Consultants, LLC.
    Blog: http://weblogs.asp.net/justin_rogers
    "Phil Jones" <phil_newsgroup@hotmail.com> wrote in message
    news:O6HjcexhEHA.396@TK2MSFTNGP12.phx.gbl...
    > I'm just wondering, in regards to animating a sequence (for instance I'm
    > looking at creating some sort of visual transformation between states wtihin
    > the control - like sliding things around) what's the general approach to
    > take?
    >
    > I'm thinking of using Timers to force redraws of the control - and then
    > successively paint the thing.  But is there a more efficient or correct way
    > to use the Drawing framework to achieve this type of thing?
    >
    > Thanks everyone.
    > ===
    > Phil - NZ
    >
    >
    >
    

  • Next message: Justin Rogers: "Re: Regions & DrawPath"

    Relevant Pages

    • Re: Animationset
      ... An animation is a set of keyframes for a given frame in the hierarchy. ... You can set key events so that when the first sequence ends you rest the ...
      (microsoft.public.win32.programmer.directx.graphics)
    • Re: Illusion of moving LEDs
      ... > make them flash on and off in sequence by changing the fillcolor from ... > green to red,to give the illusion of movement. ... you'll need to stick with the individual controls and have the Timer do ...
      (microsoft.public.vb.general.discussion)
    • Re: ActiveX Control Doesnt Appear When Form Launches
      ... I also had a similar issue with another activex control where I couldn't ... the interval to that timer for 5 ms in the init of the form. ... object) in the INIT of the form is that doing so alters the firing sequence ... I have removed the controls from the container and placed them on the ...
      (microsoft.public.fox.programmer.exchange)
    • Re: Design of process control timer
      ... atleast 3 relays in a particular sequence using timer ic.Thank You! ... Far less components to do this with a small microcontroller and capture ...
      (sci.electronics.design)
    • Re: PATCH: Race in 2.6.0-test2 timer code
      ... > sequence could crash on current 2.6: ... > checks whether the timer has this base or not and repeats the sequence if ... list_del and list_add_tail running at the same time will crash. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)