Esempio n. 1
0
void CUnitScript::Spin(int piece, int axis, float speed, float accel)
{
	struct AnimInfo *ai;
	ai = FindAnim(ASpin, piece, axis);

	//If we are already spinning, we may have to decelerate to the new speed
	if (ai) {
		ai->dest = speed;
		if (accel > 0) {
			ai->accel = accel;
		}
		else {
			//Go there instantly. Or have a defaul accel?
			ai->speed = speed;
			ai->accel = 0;
		}
	}
	else {
		//No accel means we start at desired speed instantly
		if (accel <= 0)
			AddAnim(ASpin, piece, axis, speed, speed, 0);
		else
			AddAnim(ASpin, piece, axis, 0, speed, accel);
	}
}
void CCobInstance::Spin(int piece, int axis, int speed, int accel)
{
	struct AnimInfo *ai;
	ai = FindAnim(ASpin, piece, axis);

	//logOutput.Print("Spin called %d %d %d %d", piece, axis, speed, accel);

	//Test of default acceleration
	if (accel == 0)
		accel = 1000;

	//If we are already spinning, we may have to decelerate to the new speed
	if (ai) {
		ai->dest = speed;		
		if (accel > 0) {
			if (ai->speed > ai->dest)
				ai->accel = -accel;
			else
				ai->accel = accel;
		}
		else {
			//Go there instantly. Or have a defaul accel?
			ai->speed = speed;
			ai->accel = 0;
		}
	}
	else {
		//No accel means we start at desired speed instantly
		if (accel == 0)
			AddAnim(ASpin, piece, axis, speed, speed, accel);			
		else
			AddAnim(ASpin, piece, axis, 0, speed, accel);
	}
}
Esempio n. 3
0
void CModel::Load( const char * szFile )
{
    CXMLElement * pModelXML = NULL;
    g_pXMLWrapper->LoadXML( szFile, &pModelXML );

    if ( !pModelXML )
        return;

    CXMLElement * pMeshXML = pModelXML->GetChild( "Mesh" );

    if ( pMeshXML )
    {
        CXMLAttr * pMeshAttr = pMeshXML->GetAttr( "File" );

        if ( pMeshAttr )
        {
            LoadObjects( pMeshAttr->GetValue() );
        }

        //----------------------------------------------------------------------
        // Tip: Читаем материалы
        //----------------------------------------------------------------------
        for ( uint n = 0; n < pMeshXML->GetNumChilds(); ++n )
        {
            LoadMaterial( pMeshXML->GetChild( n ) );
        }
    }

    //--------------------------------------------------------------------------
    //
    //--------------------------------------------------------------------------
    CXMLElement * pAnimXML = pModelXML->GetChild( "Animations" );

    if ( pAnimXML )
    {
        for ( uint n = 0; n < pAnimXML->GetNumChilds(); ++n )
        {
            CXMLElement * pCurAnimXML = pAnimXML->GetChild( n );

            CXMLAttr * pFileAttr = pCurAnimXML->GetAttr( "File" );
            CXMLAttr * pNameAttr = pCurAnimXML->GetAttr( "Name" );

            CAnim * pAnim = NEW CAnim;

            if ( pAnim->Load( pFileAttr->GetValue() ) )
            {
                pAnim->SetName( pNameAttr->GetValue() );
                AddAnim( pAnim );
                PlayAnim( "test_anim" );
                continue;
            }

            DEL( pAnim );
        }
    }

    DEL( pModelXML );
}
Esempio n. 4
0
void FTextureManager::AddComplexAnim (FTextureID picnum, const TArray<FAnimDef::FAnimFrame> &frames)
{
	FAnimDef *anim = (FAnimDef *)M_Malloc (sizeof(FAnimDef) + (frames.Size()-1) * sizeof(frames[0]));
	anim->BasePic = picnum;
	anim->NumFrames = frames.Size();
	anim->CurFrame = 0;
	anim->AnimType = FAnimDef::ANIM_DiscreteFrames;
	anim->SwitchTime = 0;
	memcpy (&anim->Frames[0], &frames[0], frames.Size() * sizeof(frames[0]));
	AddAnim (anim);
}
void CCobInstance::StopSpin(int piece, int axis, int decel)
{
	struct AnimInfo *ai;
	ai = FindAnim(ASpin, piece, axis);
	if (!ai)
		return;

	if (decel == 0) {
		RemoveAnim(ASpin, piece, axis);
	}
	else
		AddAnim(ASpin, piece, axis, ai->speed, 0, -decel);
}
Esempio n. 6
0
void FTextureManager::AddSimpleAnim (FTextureID picnum, int animcount, int animtype, DWORD speedmin, DWORD speedrange)
{
	if (AreTexturesCompatible(picnum, picnum + (animcount - 1)))
	{
		FAnimDef *anim = (FAnimDef *)M_Malloc (sizeof(FAnimDef));
		anim->CurFrame = 0;
		anim->BasePic = picnum;
		anim->NumFrames = animcount;
		anim->AnimType = animtype;
		anim->SwitchTime = 0;
		anim->Frames[0].SpeedMin = speedmin;
		anim->Frames[0].SpeedRange = speedrange;
		anim->Frames[0].FramePic = anim->BasePic;
		AddAnim (anim);
	}
}
Esempio n. 7
0
FAnimDef *FTextureManager::AddSimpleAnim (FTextureID picnum, int animcount, DWORD speedmin, DWORD speedrange)
{
	if (AreTexturesCompatible(picnum, picnum + (animcount - 1)))
	{
		FAnimDef *anim = (FAnimDef *)M_Malloc (sizeof(FAnimDef));
		anim->CurFrame = 0;
		anim->BasePic = picnum;
		anim->NumFrames = animcount;
		anim->AnimType = FAnimDef::ANIM_Forward;
		anim->bDiscrete = false;
		anim->SwitchTime = 0;
		anim->Frames[0].SpeedMin = speedmin;
		anim->Frames[0].SpeedRange = speedrange;
		anim->Frames[0].FramePic = anim->BasePic;
		return AddAnim (anim);
	}
	return NULL;
}
Esempio n. 8
0
void CUnitScript::Move(int piece, int axis, float speed, float destination)
{
	AddAnim(AMove, piece, axis, speed, destination, 0);
}
Esempio n. 9
0
void CUnitScript::Turn(int piece, int axis, float speed, float destination)
{
	AddAnim(ATurn, piece, axis, speed, destination, 0);
}
Esempio n. 10
0
void CUnitScript::Move(int piece, int axis, float speed, float destination, bool interpolated)
{
	AddAnim(AMove, piece, axis, speed, destination, 0, interpolated);
}
Esempio n. 11
0
void CCobInstance::Move(int piece, int axis, int speed, int destination, bool interpolated)
{
	AddAnim(AMove, piece, axis, speed, destination, 0, interpolated);
}
Esempio n. 12
0
void CCobInstance::Turn(int piece, int axis, int speed, int destination, bool interpolated)
{
	AddAnim(ATurn, piece, axis, speed, destination % 65536, 0, interpolated);
}
Esempio n. 13
0
void AnimManager::InitAnimComponent(AnimationComponent& animComponent)
{
	AddAnim(animComponent, "idle", 0, 0, false);
	PlayAnim(animComponent, "idle");
}