Results 1 to 9 of 9

Thread: Animation Implementation

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    4,887

    Animation Implementation

    A silly question but I started thinking about it and Google didn't help much.

    First, I'm not a gamer and don't know much about it. I started playing a Match 3 game, you win money for each game completed, which you spend on things for a fish tank, fish/objects/plant/feeders.....

    After a while I had over 50 fish randomly swimming around, plant swaying, bubbles..... Then I thought if I had this many objects, even just stationary, a screen refresh would probably be slow. But this little game wasn't having any problems with the animation being slow or jerky.

    When I Googled, I read about they use animation engines. But how can it move so many objects without any speed issues.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    108,498

    Re: Animation Implementation

    They wouldn't all be separate objects on the screen. If you were using WinForms and had a PictureBox for all the fish then that would be an issue, because each control would be resource intensive. In the case proper game engines, they do all the calculations in a loop and then create the entire scene, then render that in one go.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    4,887

    Re: Animation Implementation

    Quote Originally Posted by jmcilhinney View Post
    They wouldn't all be separate objects on the screen. If you were using WinForms and had a PictureBox for all the fish then that would be an issue, because each control would be resource intensive. In the case proper game engines, they do all the calculations in a loop and then create the entire scene, then render that in one go.
    Thanks, that makes sense. It's amazing all that can be done quickly enough to make the flow look constant. Then again, I'm still baffled at how search engines like Google can search billions of records and return the results in a fraction of a second. lol

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,454

    Re: Animation Implementation

    Yeah, I have a VB6 demo where 5 "car sprites" race around and around on a square "track" turning 45 then 90 crudely in each right-angle turn. I just tried shrinking the cars and lanes to half size and doubled the number of cars and lanes to 10, a quick and dirty change.

    It still animates without flicker.

    I suspect that using slightly more advanced techniques (like Direct2D) would enable animating far more items than that over a larger area.

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,596

    Re: Animation Implementation

    Quote Originally Posted by wes4dbt View Post
    After a while I had over 50 fish randomly swimming around, plant swaying, bubbles..... Then I thought if I had this many objects, even just stationary, a screen refresh would probably be slow. But this little game wasn't having any problems with the animation being slow or jerky.
    Are the graphics in this game using any kind of specially effects like glowing effects, shadows, lighting ect? Or are they just plain sprites being moved around without any kind of effect being applied to them?

    50 sprites is nothing to animate on a modern PC without any problems as long as you're not using any blending techniques for special effects. You could use plain old GDI/GDI+ or any non-accelerated graphics library to animate hundreds on items on screen without any problems.

    Note that I am assuming this game uses sprite-based graphics. If it is using 3D graphics then what I said above doesn't apply. 3D graphics must be rendered by the GPU for good performance which means the game would be using either OpenGL, DirectX or some other 3D library for rendering. Even the most basic GPUs of today would have zero problem animating 50 texture mapped models on screen without problems.
    Last edited by Niya; May 25th, 2022 at 11:44 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    4,887

    Re: Animation Implementation

    Quote Originally Posted by Niya View Post
    Are the graphics in this game using any kind of specially effects like glowing effects, shadows, lighting ect? Or are they just plain sprites being moved around without any kind of effect being applied to them?

    50 sprites is nothing to animate on a modern PC without any problems as long as you're not using any blending techniques for special effects. You could use plain old GDI/GDI+ or any non-accelerated graphics library to animate hundreds on items on screen without any problems.

    Note that I am assuming this game uses sprite-based graphics. If it is using 3D graphics then what I said above doesn't apply. 3D graphics must be rendered by the GPU for good performance which means the game would be using either OpenGL, DirectX or some other 3D library for rendering. Even the most basic GPUs of today would have zero problem animating 50 texture mapped models on screen without problems.
    I'm not sure if they are plain sprites or not. they don't look flat and they have a lot of subtle motion with their body/fins. I don't know if they're 2D or 3D.

    What I was interested in was what type of programming technics were used, jmc's info helped. Still curious how all the various movements of the objects are generated.

  7. #7
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,596

    Re: Animation Implementation

    Quote Originally Posted by wes4dbt View Post
    they don't look flat and they have a lot of subtle motion with their body/fins.
    In this case they are almost certainly 3D.

    Quote Originally Posted by wes4dbt View Post
    What I was interested in was what type of programming technics were used, jmc's info helped. Still curious how all the various movements of the objects are generated.
    3D graphics use a wire mesh of triangles with texture mapped onto it. Movement is achieved by moving vertices of the triangles of the mesh. Certain types of movement like rotations I believe is handled entirely by the GPU. Rendering of this graphical data is also handled by the GPU. GPUs have thousands of cores and a lot of graphical operations are highly parallelizable. Your GPU is doing thousands of pixel calculations simultaneously while leaving your CPU free. This is the essence of why 3D games perform so well.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    4,887

    Re: Animation Implementation

    Quote Originally Posted by Niya View Post
    In this case they are almost certainly 3D.



    3D graphics use a wire mesh of triangles with texture mapped onto it. Movement is achieved by moving vertices of the triangles of the mesh. Certain types of movement like rotations I believe is handled entirely by the GPU. Rendering of this graphical data is also handled by the GPU. GPUs have thousands of cores and a lot of graphical operations are highly parallelizable. Your GPU is doing thousands of pixel calculations simultaneously while leaving your CPU free. This is the essence of why 3D games perform so well.
    Thanks, that's interesting. Maybe you'll know this. Does the programmer have to tell the animation engine every single movement of the object or can it be more general like, move the fish tail back and forth or move the side fins up and down?

  9. #9
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,596

    Re: Animation Implementation

    Quote Originally Posted by wes4dbt View Post
    Does the programmer have to tell the animation engine every single movement of the object or can it be more general like, move the fish tail back and forth or move the side fins up and down?
    I believe that the animations like a tail wagging would be pre-calculated in 3D modelling software like Maya or whatever is the top 3D modelling software is today or perhaps even something made inhouse. This software would essentially allow you to create all the data for the pre-defined paths of movement for vertices of the mesh. This data would imported into the game and it's 3D engine could reproduce the movement using the data. More general movement like rotations and resizes and reflections could be calculated on the fly by the game engine itself.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

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



Click Here to Expand Forum to Full Width