示例#1
0
/*-----------------------------------------------------------------------------
    Name        : madAnimationUpdate
    Description : Update the mesh animation for an object
    Inputs      : ship - ship to update the animation for
                  timeElapsed - time elapsed since last updated
    Outputs     :
    Return      : TRUE if the animation ends
----------------------------------------------------------------------------*/
bool madAnimationUpdate(Ship *ship, real32 timeElapsed)
{
    madanim *anim = ship->madBindings;
    madheader *header = anim->header;
    madanimation *animation = &header->anim[anim->nCurrentAnim];

    dbgAssertOrIgnore(anim != NULL);
    dbgAssertOrIgnore(anim->nCurrentAnim != MAD_NoAnimation);

    if (anim->bPaused)
    {                                                       //if paused
        return(FALSE);                                      //just chillin'
    }

    if (anim->time + timeElapsed > animation->endTime)
    {                                                       //if we'll go past the end
        if (bitTest(animation->flags, MAF_Loop))
        {                                                   //if this is a looping animation
            do
            {
                anim->time = anim->time + timeElapsed - animation->endTime + animation->startTime;
            }
            while (anim->time + timeElapsed > animation->endTime);
            dbgAssertOrIgnore(anim->time + timeElapsed <= animation->endTime);   //wrap around to start
        }
        else
        {                                                   //else it's a non-looping animation; clamp at the end
            madAnimationStop(ship);
            return(TRUE);
        }
    }
    else
    {
        anim->time += timeElapsed;
    }
    anim->timeElapsed += timeElapsed;
    return(FALSE);
}
示例#2
0
/*-----------------------------------------------------------------------------
    Name        : madLinkInUpdateMeshAnimations
    Description : starts,stops and does whatever needs to be done
                  for mesh animations based on code given cues.
    Inputs      : Ship to have animation updated
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void madLinkInUpdateMeshAnimations(Ship *ship)
{
    if(bitTest(ship->madAnimationFlags,MAD_NEED_TO_START_NEW_ANIMATION))
    {
        //we need to switch to a new animation for some odd reason
        if(ship->madBindings->nCurrentAnim != MAD_NoAnimation)
        {
            if(ship->madBindings->bPaused)
            {
                //animation is paused...well,unpause it
                //so as to fix a bug in lukes code!
                madAnimationPause(ship,!ship->madBindings->bPaused);
            }
            madAnimationStop(ship);
        }
        madAnimationStart(ship, ship->cuedAnimationIndex);  //start 0th cued animation
		/* play special animation sound here */
		soundEvent(ship, ship->soundEventAnimationTypeFlag);
        bitClear(ship->madAnimationFlags,MAD_NEED_TO_START_NEW_ANIMATION);
        if(ship->shiptype == Mothership)
        {
            MothershipDoorUpKeep(ship);
        }
        return;
    }



    //time to start animation

    if(madAnimationUpdate(ship, universe.phystimeelapsed))
    {
#if DEBUG_MESH_ANIMATIONS
        dbgMessagef("Animation Finished.");
#endif
        //start and pause poo here for pooeyness...(wings just closed, gotta stay closed...etc..

        //cleanup ended animation
        switch(ship->cuedAnimationType)
        {
        case MAD_ANIMATION_GUN_OPENING:
            ship->cuedAnimationType = MAD_ANIMATION_NOTHING;
            ship->madGunStatus = MAD_STATUS_GUNS_OPEN;
            break;
        case MAD_ANIMATION_GUN_CLOSING:
            ship->cuedAnimationType = MAD_ANIMATION_NOTHING;
            ship->madGunStatus = MAD_STATUS_GUNS_CLOSED;
            //setup closed gun hack...
            madAnimationStart(ship, ship->staticinfo->madStatic->gunOpenIndexes[0]);    //start 0th animation
            madAnimationPause(ship,!ship->madBindings->bPaused);
            break;
        case MAD_ANIMATION_WINGS_OPENING:
            ship->cuedAnimationType = MAD_ANIMATION_NOTHING;
            ship->madWingStatus = MAD_STATUS_WINGS_OPEN;
            break;
        case MAD_ANIMATION_WINGS_CLOSING:
            ship->cuedAnimationType = MAD_ANIMATION_NOTHING;
            ship->madWingStatus = MAD_STATUS_WINGS_CLOSED;
            //setup closed gun hack...
            madAnimationStart(ship, ship->staticinfo->madStatic->PostDockIndexes[0]);   //start 0th animation
            madAnimationPause(ship,!ship->madBindings->bPaused);
            break;
        case MAD_ANIMATION_DOOR_OPENING:
            ship->cuedAnimationType = MAD_ANIMATION_NOTHING;
            ship->madDoorStatus = MAD_STATUS_DOOR_OPEN;
            madAnimationStart(ship, ship->staticinfo->madStatic->DoorCloseIndexes[0]);  //start 0th animaiton
            madAnimationPause(ship,!ship->madBindings->bPaused);
            break;
        case MAD_ANIMATION_DOOR_CLOSING:
            ship->cuedAnimationType = MAD_ANIMATION_NOTHING;
            ship->madDoorStatus = MAD_STATUS_DOOR_CLOSED;
			// play the mothership door closed sound (big Ka-chunk)
			// this is in addition to the closing sound which is triggered at the start of closing
			soundEvent(ship, Ship_MoshipDoorClosed);
            break;
        case MAD_ANIMATION_SPECIAL_OPENING:
            ship->cuedAnimationType = MAD_ANIMATION_NOTHING;
            ship->madSpecialStatus = MAD_STATUS_SPECIAL_OPEN;
            break;
        case MAD_ANIMATION_SPECIAL_CLOSING:
            ship->cuedAnimationType = MAD_ANIMATION_NOTHING;
            ship->madSpecialStatus = MAD_STATUS_SPECIAL_CLOSED;
            madAnimationStart(ship, ship->staticinfo->madStatic->specialOpenIndexes[0]);    //start 0th animaiton
            madAnimationPause(ship,!ship->madBindings->bPaused);
            break;
        }

        bitClear(ship->madAnimationFlags,MAD_ANIMATION_NEED_PROC);

        //play animations that are waiting...
        if(ship->nextAnim != 0)
        {
            switch(ship->nextAnim)
            {
            case MAD_ANIMATION_GUN_OPENING:
                madOpenGunsShip(ship);
                break;
            case MAD_ANIMATION_GUN_CLOSING:
                madLinkInCloseGunsShip(ship);
                break;
            case MAD_ANIMATION_WINGS_OPENING:
                madLinkInPostDockingShip(ship);
                break;
            case MAD_ANIMATION_WINGS_CLOSING:
                madLinkInPreDockingShip(ship);
                break;
            case MAD_ANIMATION_DOOR_OPENING:
                madLinkInOpenDoor(ship);
                break;
            case MAD_ANIMATION_DOOR_CLOSING:
                madLinkInCloseDoor(ship);
                break;
            case MAD_ANIMATION_SPECIAL_OPENING:
                madLinkInOpenSpecialShip(ship);
                break;
            case MAD_ANIMATION_SPECIAL_CLOSING:
                madLinkInCloseSpecialShip(ship);
                break;
            default:
                dbgFatalf(DBG_Loc,"\nUnknown animation in nextAnim variable.");
                break;
            }
            ship->nextAnim = 0;
        }
    }
    if(ship->shiptype == Mothership)
    {
        MothershipDoorUpKeep(ship);
    }
}