Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Animation with MFC

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2000
    Location
    Lincoln, NE, USA
    Posts
    4

    Animation with MFC

    I've got a question about how to implement animation with MFC in WinNT. Does any one has some sample code or can give me some suggestion?
    Thanks.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Bucharest, Romania
    Posts
    113

    Re: Animation with MFC

    Be more explicit. What do you mean by animatiom? You can implement animation using CDC's or DirextX or OpenGl.

    NewROmancer

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2000
    Location
    Lincoln, NE, USA
    Posts
    4

    Re: Animation with MFC

    Thanks for your reply. I am working on a robotics project with MFC and OpenGL. What I mean by animation is that I want to show the motion of the robot(3D) on the screen. I have the pose(position, joint angles) of the robot at each second. But I don't know how to make the animation to show the movement of the robot from beginning to end.
    Thanks.

  4. #4
    Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Augsburg, Germany
    Posts
    415

    Re: Animation with MFC

    Is your problem how to calculate the movement between the frames (hierarchical transformations and rotations) or is the problem how you can activate the animation in Windows to get automatically one frame rendered after another?

  5. #5
    Junior Member Newbie
    Join Date
    Aug 2000
    Location
    Lincoln, NE, USA
    Posts
    4

    Re: Animation with MFC

    My question is the later one. What kind of function should I use? OnIdle, or something else. And do I need to fork a new thread to do that?
    Thanks.

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2000
    Location
    Lancaster,Lancashire,England
    Posts
    3

    Re: Animation with MFC

    Originally posted by zhangdm:
    My question is the later one. What kind of function should I use? OnIdle, or something else. And do I need to fork a new thread to do that?

    I tend to set up a timer in MFC using SetTimer, and then use the WMTimer function to respond to it. if you set up the timer to run at x milliseconds you can then force an Invalidate(FALSE) call which in turn will call OnDraw, which in turn can have your call out to renderscene or what ever function you OGL with.

    If you only want to run for a limited amount of time the you can obviously set up a flag to stop when a timer counter expires, or you can use a modulus operator to work out if its time to render or do something else like comms etc.

    I have no idea if this is at all eleoquent but it works for me, and if it works...

  7. #7
    Junior Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Bucharest, Romania
    Posts
    113

    Re: Animation with MFC

    Use SetTimer and the function to determine if the system is idle (the function is on an example from VC++6 about a kind of notepad that has a splash screen). Look how they check if the system is idle. The function you need to make the moves are glTranslate* and glRotate*

    NewROmancer

  8. #8
    Intern Contributor
    Join Date
    Apr 2000
    Posts
    62

    Re: Animation with MFC

    I used the ol Peek-a-boo. This was my first attempt at a GL app. A few have told me this is just a bad way to animate, and they're prolly right. But it does work. It leaves the UI live enough to use sliders for speed, single block & feed hold buttons etc.Ive used gluts IdleFunc callback and it works ok. Another possibility is to put your animation routine in a seperate thread. But Ive yet to code a thread so I cant comment on it. A few people suggested this to me when I was playing with my robot app.

    //Peek-a-boo
    int CRobot::Interpolate(CString block)
    {

    //...
    //Interpolation code
    //...

    //Process window messages
    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    {
    if (msg.message == WM_QUIT)
    return 1;
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return 0;
    }

    HTH
    Sean
    Sean E. Dolan

  9. #9
    Intern Newbie
    Join Date
    Dec 2000
    Location
    Czech Republic
    Posts
    30

    Re: Animation with MFC

    Does anybody have an code example
    showing the technolgy ?
    All methos described in this threed
    are not optimal ( I was testing all of them) :

    1) The timer method does snot lead to smooth
    animation, the timer is not precise enought ... Especialy horrible is this situation
    under Win9x

    2) The infinte loop eith the Message Pump
    does not work correct in MFC ...
    It ofte leed to hanging some parts of the code in memory after exiting. It is impossible to exit the code proper in this way ...

    THe threed method will be probaby the best one. I was tring to do that, giving the new animation threed an pointer to the animation routine as an call parameter ... But it have some great time-synchronization troubles again ...
    GALI-3D Inc. CEO
    http://www.gali-3d.com

  10. #10
    Intern Contributor
    Join Date
    Jun 2000
    Posts
    68

    Re: Animation with MFC

    I'm sort of in a similar situation. What is the optimal way to get consistent screen updates in MFC?

    Agreed, WM_TIMER messages are ok if you don't need anything particularly precise. In fact, I read that TIMER messages are the lowest priority and they get processed after everything else is done. Also, I heard that the granularity is about 15 millisecs in a best case scenario, meaning that you just can't go any lower than 15...seems like last time I tried this, I couldn't go much below 40 or 50. sigh.

    So, any better suggestions would be appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •