示例#1
0
void CCamera::Update(float ftDelta)
{
	SRotator  Rot = this->Location().Rotation;

	if(m_bImpact)
	{
		if(m_ftElapsedTime < m_ftImpactTime/2.0f)
		{
			m_vctTargetEye = m_vctTargetEye*m_ftElapsedTime + m_vctCurrentEye*(m_ftImpactTime/2.0f-m_ftElapsedTime);
			m_vctTargetEye *= m_ftImpactTime/2.0f;
		}
		else
		{
			m_vctTargetEye = m_vctTargetEye*(m_ftElapsedTime-m_ftImpactTime/2.0f) + m_vctCurrentEye*(m_ftImpactTime-m_ftElapsedTime);
			m_vctTargetEye *= m_ftImpactTime/2.0f;
		}
	}
	
	float ftVelocityEye = 10.0f;
	
	SVector vctDelta = m_vctTargetEye - m_vctCurrentEye;

	if(vctDelta.Size2D() < ftDelta * ftVelocityEye)
	{
		m_vctCurrentEye = m_vctTargetEye;
	}
	else
	{
		vctDelta.Normalize();
		m_vctCurrentEye = m_vctCurrentEye + vctDelta * ftDelta * ftVelocityEye;
	}

	m_vctCurrentEye = m_vctTargetEye;

	if(m_bJerk)
	{		
		// if(((int)(m_fFlashTime * 5.0f)) % 2 == 0)
		SVector vctDelta = m_vctCurrentEye - m_vctCurrentAt;
		m_vctCurrentAt.Y += float(rand()%10-5)/10.0f * m_ftJerk * vctDelta.Size() / 20.0f;
	}

	CreateLookAt(m_vctCurrentEye, m_vctCurrentAt, SVector(0.0f, 1.0f, 0.0f));
}
示例#2
0
	Matrix Matrix::CreateLookAt(float eyex, float eyey, float eyez, float targetx, float targety, float targetz, float upx, float upy, float upz) {
		return CreateLookAt(Vector3(eyex, eyey, eyez), Vector3(targetx, targety, targetz), Vector3(upx, upy, upz));
	}