int CParticle::Update(float fDelta) { if(m_tTargetStage.fTime == 0.0f) { m_bIsAlive = false; return -1; } m_fDuration += fDelta; if(m_fDuration >= m_tTargetStage.fTime) { m_nCurStage++; return m_nCurStage; } float tween = m_tTargetStage.fTime - m_tPrevStage.fTime; float lambda = (m_fDuration - m_tPrevStage.fTime)/tween; m_d3dVelocity = ((m_tTargetStage.d3dVelocity - m_tPrevStage.d3dVelocity) * lambda) + m_tPrevStage.d3dVelocity + m_d3dRandVel; m_d3dCurVelocity = (m_d3dVelocity * fDelta); m_d3dPosition *= GetTranslateMatrix(); m_d3dColor = ((m_tTargetStage.d3dColor - m_tPrevStage.d3dColor) * lambda) + m_tPrevStage.d3dColor; m_d3dCurScale = ((m_tTargetStage.d3dScale - m_tPrevStage.d3dScale) * lambda) + m_tPrevStage.d3dScale; m_d3dCurRotation = ((m_tTargetStage.d3dRotation - m_tPrevStage.d3dRotation) * lambda) + m_tPrevStage.d3dRotation; return 0; }
bool PODNode::TryGetMatrix( float frame,Matrix4& outMatrix ) const { outMatrix.LoadIdentity(); RETURN_FALSE_IF(frame<0.f); uint frameIndex=(uint)frame; float frameBlend=frame-(float)frameIndex; outMatrix=Matrix4::Identity; if (!AnimationMatrixes.IsEmpty()) { GetMatrix(frameIndex,outMatrix); } else { GetScaleMatrix(frameIndex,frameBlend,outMatrix); GetRotateMatrix(frameIndex,frameBlend,outMatrix); GetTranslateMatrix(frameIndex,frameBlend,outMatrix); } return true; }