Example #1
0
void Combo::setBounceMode(bool bounce) 
{ 
   m_bounce = bounce; 
   int nCycles(-1);
   if (!m_loop) nCycles = m_bounce ? 2*m_referenceFrames-1 : m_referenceFrames-1;
   setCycles(nCycles);
}
Example #2
0
void Combo::setLoopMode(bool loop)
{
   m_loop = loop;
   int nCycles(-1);
   if (!m_loop) nCycles = m_bounce ? 2*m_referenceFrames-1 : m_referenceFrames-1;
   setCycles(nCycles);
}
Example #3
0
Combo::Combo(Layer::Molecule* molecule, DataList const& frames, int const interpolationFrames, 
   double const speed) : Base(1.0, speed, Ramp), m_molecule(molecule), m_frames(frames), 
   m_bounce(false), m_loop(false), m_interpolationFrames(interpolationFrames), 
   m_currentIndex(-1)
{ 
   m_referenceFrames = 1 + (frames.size()-1)/(m_interpolationFrames+1);
   int nCycles(m_bounce ? 2*m_referenceFrames-1 : m_referenceFrames-1);
   setCycles(nCycles);

   DataList::iterator iter;
   for (iter = m_frames.begin(); iter != m_frames.end(); ++iter) {
       (*iter)->m_surface->setCheckState(Qt::Unchecked);
   }

   setCurrentIndex(0);
}
Example #4
0
/*!\fn void Animation::start(const Time& StartTime)
 *
 * \brief Start the animation at the given start time.
 *
 * @param[in] StartTime The time (in seconds) to start the animation at.
 * This defaults to time 0.0.
 */
void Animation::start(const Time& StartTime)
{
    if(_IsPlaying)
    {
        stop(false);
    }

    _CurrentTime = _PrevTime = StartTime;
    setCycles(0);
    //commitChanges();
    _IsPlaying = true;

    update(0.0);

    produceAnimationStarted();
}
Example #5
0
    /**
     * Adds a field to the message. Unknown fields are rejected
     * @return bool if field was known to the message
     */
    bool addField(unsigned char fieldDefNum, unsigned char size, unsigned char baseType, unsigned char arch, char * data) {
        //TODO: Compare size with expected size
        //TODO: Compare baseType with expected baseType
        bool fieldWasAdded = true;
        switch (fieldDefNum) {
        case 253: setTimestamp(read0x86(data,arch));
                 break;
        case 0: setPositionLat(read0x85(data,arch));
                 break;
        case 1: setPositionLong(read0x85(data,arch));
                 break;
        case 2: setAltitude(read0x88(data,arch,5,500,0x84));
                 break;
        case 3: setHeartRate(read0x02(data,arch));
                 break;
        case 4: setCadence(read0x02(data,arch));
                 break;
        case 5: setDistance(read0x88(data,arch,100,0,0x86));
                 break;
        case 6: setSpeed(read0x88(data,arch,1000,0,0x84));
                 break;
        case 7: setPower(read0x84(data,arch));
                 break;
        case 9: setGrade(read0x88(data,arch,100,0,0x83));
                 break;
        case 10: setResistance(read0x02(data,arch));
                 break;
        case 11: setTimeFromCourse(read0x88(data,arch,1000,0,0x85));
                 break;
        case 12: setCycleLength(read0x88(data,arch,100,0,0x02));
                 break;
        case 13: setTemperature(read0x01(data,arch));
                 break;
        case 17: setNumSpeed1s(read0x02(data,arch));
                 break;
        case 18: setCycles(read0x02(data,arch));
                 break;
        case 19: setTotalCycles(read0x86(data,arch));
                 break;
        case 28: setCompressedAccumulatedPower(read0x84(data,arch));
                 break;
        case 29: setAccumulatedPower(read0x86(data,arch));
                 break;
        case 30: setLeftRightBalance(read0x02(data,arch));
                 break;
        case 31: setGpsAccuracy(read0x02(data,arch));
                 break;
        case 32: setVerticalSpeed(read0x88(data,arch,1000,0,0x83));
                 break;
        case 33: setCalories(read0x84(data,arch));
                 break;
        case 43: setLeftTorqueEffectiveness(read0x88(data,arch,2,0,0x02));
                 break;
        case 44: setRightTorqueEffectiveness(read0x88(data,arch,2,0,0x02));
                 break;
        case 45: setLeftPedalSmoothness(read0x88(data,arch,2,0,0x02));
                 break;
        case 46: setRightPedalSmoothness(read0x88(data,arch,2,0,0x02));
                 break;
        case 47: setCombinedPedalSmoothness(read0x88(data,arch,2,0,0x02));
                 break;
        case 52: setCadence256(read0x88(data,arch,256,0,0x84));
                 break;


            default:
                fieldWasAdded = false;
                break;
        }
        return fieldWasAdded;
    };
Example #6
0
/*!
 * \fn bool OSG::Animation::update(const Time& ElapsedTime)
 *
 * \brief Update the animation with the time since the last update
 *
 * The result of the animation will also be applied to the
 * object it is connected to.
 *
 * \param[in] ElapsedTime The time, in seconds, since the previous call to
 * update.
 */
bool Animation::update(const Time& ElapsedTime)
{
    if(!_IsPlaying || _IsPaused)
    {
        return false;
    }

    //Increment the updated animations statistic
    StatIntElem *NAnimationsStatElem = StatCollector::getGlobalElem(statNAnimations);
    if(NAnimationsStatElem) { NAnimationsStatElem->inc(); }

    //Start the  animation update time statistic
    StatTimeElem *AnimUpdateTimeStatElem = StatCollector::getGlobalElem(statAnimUpdateTime);
    if(AnimUpdateTimeStatElem) { AnimUpdateTimeStatElem->start(); }

    _CurrentTime += getScale()*ElapsedTime;
    UInt32 PreUpdateCycleCount(getCycles());
    if(getCycling() < 0 || PreUpdateCycleCount < getCycling())
    {
        Real32 CycleLength(getCycleLength() * getScale());

        //Check if the Animation Time is past the end
        if(_CurrentTime >= CycleLength)
        {
            //Update the number of cycles completed
            setCycles( (CycleLength <= 0.0f) ? (0): (static_cast<UInt32>( osgFloor( _CurrentTime / CycleLength ) )) );
            //commitChanges();
        }
        Real32 t(_CurrentTime);

        if(getCycling() > 0 && getCycles() >= getCycling())
        {
            if(getSpan() > 0.0f)
            {
                t = getSpan();
            }
            t -= 0.0001f;
        }
        else
        {
            if(getSpan() > 0.0f)
            {
                t -= osgFloor(_CurrentTime/getSpan())*getSpan();
            }
        }
        t += getOffset();

        //Internal Update
        internalUpdate(t, _PrevTime);


        //If the number of cycles has changed
        if(getCycles() != PreUpdateCycleCount)
        {
            if(getCycling() > 0 && getCycles() >= getCycling())
            {
                //Animation has reached the end
                //Remove the Animation from it's update producer
                _UpdateEventConnection.disconnect();
                _IsPlaying = false;

                //Produce the Ended event
                produceAnimationEnded();
            }
            else
            {
                //Animation hasn't finished yet
                //Produce the Cycled event
                produceAnimationCycled();
            }
        }
    }

    _PrevTime = _CurrentTime;

    //Stp[ the  animation update time statistic
    if(AnimUpdateTimeStatElem) { AnimUpdateTimeStatElem->stop(); }

    //Return true if the animation has completed its number of cycles, false otherwise
    return (getCycling() > 0 && getCycles() >= getCycling());
}
bool AnimationGroup::update(const Time& ElapsedTime)
{
    if(!_IsPlaying || _IsPaused)
    {
        return false;
    }
    _CurrentTime += getScale()*ElapsedTime;

    UInt32 PreUpdateCycleCount(getCycles());
    if(getCycling() < 0 || PreUpdateCycleCount < getCycling())
    {
        Real32 CycleLength(getCycleLength() * getScale());
        
        //Check if the Animation Time is past the end
        if(_CurrentTime >= CycleLength)
        {
            //Update the number of cycles completed
            setCycles( (CycleLength <= 0.0f) ? (0): (static_cast<UInt32>( osgFloor( _CurrentTime / CycleLength ) )) );
            //commitChanges();
        }
        Real32 t(_CurrentTime);

        if(getCycling() > 0 && getCycles() >= getCycling())
        {
            if(getSpan() > 0.0f)
            {
                t = getSpan();
            }
            else
            {
                t = CycleLength;
            }
            t -= 0.0001f;
        }
        else
        {
            if(getSpan() > 0.0f)
            {
                t -= osgFloor(_CurrentTime/getSpan())*getSpan();
            }
        }
        t += getOffset();

        //Internal Update
        for(UInt32 i = 0; i < getMFAnimations()->size(); ++i)
        {
            getAnimations(i)->internalUpdate(t, _PrevTime);
        }

        //If the number of cycles has changed
        if(getCycles() != PreUpdateCycleCount)
        {
            if(getCycling() > 0 && getCycles() >= getCycling())
            {
                //Animation has reached the end
                //Remove the Animation from it's update producer
                _UpdateEventConnection.disconnect();
                _IsPlaying = false;

                //Produce the Ended event
                produceAnimationEnded();
            }
            else
            {
                //Animation hasn't finished yet
                //Produce the Cycled event
                produceAnimationCycled();
            }
        }
    }

    _PrevTime = _CurrentTime;

    //Return true if the animation has completed its number of cycles, false otherwise
    return (getCycling() > 0 && getCycles() >= getCycling());
}