Beispiel #1
0
void Sprite::SetSecondsIntoAnimation( float fSeconds )
{
	SetState( 0 );	// rewind to the first state
	if( m_pTexture )
		m_pTexture->SetPosition( fSeconds );
	m_fSecsIntoState = fSeconds;
	UpdateAnimationState();
}
Beispiel #2
0
void UpdateAnimationStates(EntityContainer *entityContainer, F32 deltaTime) {
  BeginTimedBlock("Update Animation States");
  EntityBlock *block = entityContainer->firstAvaibleBlock;
  for (U64 i = 0; i < entityContainer->capacityPerBlock; i++) {
    if (block->flags[i] & EntityFlag_PRESENT) {
      Entity* entity = &block->entities[i];
      ModelAsset *model = GetModelAsset(entity->modelID);
      if (model == nullptr) continue;
      if (model->jointCount > 0) {
        UpdateAnimationState(&entity->animation_state, model, deltaTime);
      }
    }
  }
  EndTimedBlock("Update Animation States");
}
Beispiel #3
0
// todo: see if "current" practice is just that. -aj
void Sprite::Update( float fDelta )
{
	Actor::Update( fDelta ); // do tweening

	const bool bSkipThisMovieUpdate = m_bSkipNextUpdate;
	m_bSkipNextUpdate = false;

	if( !m_bIsAnimating )
		return;

	if( !m_pTexture ) // no texture, nothing to animate
		return;

	float fTimePassed = GetEffectDeltaTime();
	m_fSecsIntoState += fTimePassed;

	if( m_fSecsIntoState < 0 )
		wrap( m_fSecsIntoState, GetAnimationLengthSeconds() );

	UpdateAnimationState();

	// If the texture is a movie, decode frames.
	if(!bSkipThisMovieUpdate && m_DecodeMovie)
		m_pTexture->DecodeSeconds( max(0, fTimePassed) );

	// update scrolling
	if( m_fTexCoordVelocityX != 0 || m_fTexCoordVelocityY != 0 )
	{
		float fTexCoords[8];
		Sprite::GetActiveTextureCoords( fTexCoords );
 
		// top left, bottom left, bottom right, top right
		fTexCoords[0] += fDelta*m_fTexCoordVelocityX;
		fTexCoords[1] += fDelta*m_fTexCoordVelocityY; 
		fTexCoords[2] += fDelta*m_fTexCoordVelocityX;
		fTexCoords[3] += fDelta*m_fTexCoordVelocityY;
		fTexCoords[4] += fDelta*m_fTexCoordVelocityX;
		fTexCoords[5] += fDelta*m_fTexCoordVelocityY;
		fTexCoords[6] += fDelta*m_fTexCoordVelocityX;
		fTexCoords[7] += fDelta*m_fTexCoordVelocityY;

		/* When wrapping, avoid gradual loss of precision and sending
		 * unreasonably large texture coordinates to the renderer by pushing
		 * texture coordinates back to 0. As long as we adjust all four
		 * coordinates by the same amount, this won't be visible. */
		if( m_bTextureWrapping )
		{
			const float fXAdjust = floorf( fTexCoords[0] );
			const float fYAdjust = floorf( fTexCoords[1] );
			fTexCoords[0] -= fXAdjust;
			fTexCoords[2] -= fXAdjust;
			fTexCoords[4] -= fXAdjust;
			fTexCoords[6] -= fXAdjust;
			fTexCoords[1] -= fYAdjust;
			fTexCoords[3] -= fYAdjust;
			fTexCoords[5] -= fYAdjust;
			fTexCoords[7] -= fYAdjust;
		}

		Sprite::SetCustomTextureCoords( fTexCoords );
	}
}
Beispiel #4
0
void CLivingEntitySample::PostUpdate( float frameTime )
{
	UpdateEntityVelocities( frameTime );
	UpdateAnimationState( frameTime );
	UpdateAnimationParams( frameTime );
}
Beispiel #5
0
void Sprite::SetSecondsIntoAnimation( float fSeconds )
{
	SetState( 0 );	// rewind to the first state
	m_fSecsIntoState = fSeconds;
	UpdateAnimationState();
}