|
-
Jul 28th, 2011, 12:41 AM
#1
Thread Starter
Lively Member
Slow animation of a lot of data
Comrades,
I have an issue here which I am looking for ideas on. I am creating a program that models the movement of some atoms and then animates them using the basic Paint method in visual basic. The animation is to have basic remote control functions, such as play, pause, fast forward, rewind and skip to any particular frame.
The program is in two parts. The program models the movements of atoms in a background thread. This program was 90% written by other people and is very long and complicated, so in your answers please do not suggest I change the modelling aspect because it's just not possible. It is my job to do the animation.
The modelling program outputs the positions of each atom (just an x,y coordinate) at each time step. We could easily be looking at 200,000 time steps and 50/100 atoms. That means there are 200,000 * 100 * 2 = 40,000,000 numbers that need to be stored. The locations are all single precision numbers.
At the moment the modelling code stores these positions in arrays. When you hit the start button both the modelling and animation start. The modelling of course zooms ahead of the animation as it is running in a background thread as fast as it can, whilst the animation paints the atoms onto the form at intervals specified by a timer.
What happens though is, as the model rolls on and the number of time steps increases, the animation becomes God slow. I have run a couple of tests:
With the timer set at 1 ms (although it doesn't run this fast) it takes ~25 seconds per 1,000 steps of animation initially. It takes ~8 seconds to model each 1,000 steps.
After leaving the program to run for a bit, by the time 268,000 steps have been modelled it is taking ~15 seconds to model each 1,000 steps. That's not really a concern for me, given that I won't need to run the program for much longer than that and the speed is acceptable, even if it has roughly halved.
The program is that by this time 44,000 steps have been animated and it now takes ~90 seconds to animate each 1,000 steps! That's really slow and it shows. The thing is really laggy.
So, what I need is some way of having consistently smooth animation. Here are a few extra points.
1) The atoms are moving every time step so every bit of data is important
2) The program was initially created with the animation and modelling occuring concurrently. A time step was modelled, and then it was animated. This wasn't good though because there was a lag between animation steps, and this got signifcantly worse with poorer computers which struggled to do the modelling.
3) I have attempted having all of the data from the modelling code not put into an array but instead put into a text file. I then call in the data line by line from the text file at each time step for animation. This is laggy, I suppose due to the time taken to load the data from the text file. It's normally quicker if the data is already there in memory.
So yeah, sorry comrades for the long post, but any suggestions would be most appreciated. Unfortunately I cannot change the data output from the modelling program, and I'm not even sure it'd be possible given that the position of each atom at each timestep is important. It doesn't seem like there is a large size of data, just lots and lots of tiny bits of data. My knowledge of computer science isn't good enough to know how hard that makes it for a computer.
Thanks in advance,
Dave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|