Beispiel #1
0
size_t PlayListStep::GetLengthMS() const
{
    int msPerFrame = 1000;
    PlayListItem* timesource = GetTimeSource(msPerFrame);
    if (timesource != nullptr)
    {
        return timesource->GetDurationMS();
    }
    else
    {
        size_t len = 0;
        for (auto it = _items.begin(); it != _items.end(); ++it)
        {
            len = std::max(len, (*it)->GetDurationMS());
        }

        if (len == 0)
        {
            for (auto it = _items.begin(); it != _items.end(); ++it)
            {
                len = std::max(len, (*it)->GetDurationMS(msPerFrame));
            }

            if (len == 0) len = msPerFrame;
        }

        return len;
    }
}
Beispiel #2
0
size_t PlayListStep::GetPosition() const
{
    int msPerFrame = 1000;
    PlayListItem* timesource = GetTimeSource(msPerFrame);

    size_t frameMS;
    if (timesource != nullptr)
    {
        frameMS = timesource->GetPositionMS();
    }
    else
    {
        auto now = wxGetUTCTimeMillis();
        if (_pause == 0)
        {
            frameMS = (now - _startTime).ToLong();
        }
        else
        {
            frameMS = (now - _startTime - (now - _pause)).ToLong();
        }
    }

    return frameMS;
}
Beispiel #3
0
size_t PlayListStep::GetFrameMS() const
{
    int ms = 0;
    PlayListItem* timesource = GetTimeSource(ms);

    return ms;
}
Beispiel #4
0
bool PlayListStep::Frame(wxByte* buffer, size_t size)
{
    int msPerFrame = 1000;
    PlayListItem* timesource = GetTimeSource(msPerFrame);

    if (msPerFrame == 0)
    {
        msPerFrame = 50;
    }

    size_t frameMS;
    if (timesource != nullptr)
    {
        frameMS = timesource->GetPositionMS();
    }
    else
    {
        frameMS = (wxGetUTCTimeMillis() - _startTime).ToLong();
    }

    for (auto it = _items.begin(); it != _items.end(); ++it)
    {
        (*it)->Frame(buffer, size, frameMS, msPerFrame);
    }

    if (timesource != nullptr)
    {
        return timesource->Done();
    }
    else
    {
        return frameMS >= GetLengthMS();
    }
}
int TColladaAnimation::GetFrameCount() const
{
    TColladaSource* timeSource = GetTimeSource();
    if( timeSource )
    {
        return (int)timeSource->values.size();
    }
    
    assert(!"");
    return 0;
}
float TColladaAnimation::GetFPS() const
{
    if( ! IsEqualTimeInterval() )
        return -1.0f;
    TColladaSource* timeSource = GetTimeSource();
    
    assert( timeSource );
    assert( timeSource->values.size()>=2 );
    
    return 60.0f*(timeSource->values[1] - timeSource->values[0]);
}
bool TColladaAnimation::IsEqualTimeInterval() const
{
    TColladaSource* timeSource = GetTimeSource();
    if( !timeSource )
        return true; //HACK t
    
    assert( timeSource );
    if( timeSource->values.size()<2 )
        return true;
    for(int t=2;t<(int)timeSource->values.size();++t)
    {
        float dt0 = timeSource->values[t] - timeSource->values[t-1];
        float dt1 = timeSource->values[t-1] - timeSource->values[t-2];
        float diff = fabs(dt1 - dt0);
        if( diff > 0.01f )
            return false;
    }
    return true;
}