Animations: Who do I talk to

Discussion area for user-created Allegiance models, textures, voicechats, music, and other ingame content.
DonKarnage
Posts: 545
Joined: Mon Nov 01, 2010 7:18 pm

Post by DonKarnage »

GetTime(), to my knowledge, will return system time in milliseconds.

Code: Select all

void AnimatedImage::Evaluate()
{
    float time = GetTime()->GetValue();

    int count = m_psurfaces.GetCount();
    m_index = (int)(time * count) % count;

    Image::Evaluate();
}
From the looks of it, m_index is used with m_psurfaces to choose the right image.
Time multiplied by number of images, then with the % (Modulo) the remainder of (time*count)/count

I never was good at math, maybe you can make sense of what that actually does... I'm gonna sleep on it, it's late :wacko:
Last edited by DonKarnage on Sun Dec 05, 2010 11:39 am, edited 1 time in total.
It is Karnage! Don Karnage! Roll the r!
madpeople
Posts: 4787
Joined: Tue Dec 16, 2003 8:00 am
Location: England

Post by madpeople »

Well, m_index always needs to be a value from 0 to count. modulo is an easy way to make the value wrap around.

if I had
m_index = i % count

and count = 4, then
i,m_index
0,0
1,1
2,2
3,3
4,0
5,1
6,2
7,3
8,0
...
See, m_index is always from 0 to count.

I'm not sure GetTime()->GetValue() does return millisecond time - they feel the need to multiply by count, and it is a float, where as a millisecond time is usually a long int. Perhaps it's seconds with a number of decimal places? You probably want to look up what it actually does if you want to understand this piece of code.
Post Reply