当前位置: 首页>>代码示例>>C++>>正文


C++ CServerDE::GetFrameTime方法代码示例

本文整理汇总了C++中CServerDE::GetFrameTime方法的典型用法代码示例。如果您正苦于以下问题:C++ CServerDE::GetFrameTime方法的具体用法?C++ CServerDE::GetFrameTime怎么用?C++ CServerDE::GetFrameTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CServerDE的用法示例。


在下文中一共展示了CServerDE::GetFrameTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateSpinDown

void Rotating::UpdateSpinDown()
{
	CServerDE* pServerDE = BaseClass::GetServerDE();
	if (!pServerDE) return;

	DBOOL bXDone = DFALSE, bYDone = DFALSE, bZDone = DFALSE;
	DFLOAT fDeltaTime = pServerDE->GetFrameTime();

	// Calculate current velocity...

	m_vSpinTimeLeft.x -= fDeltaTime;
	if (m_vSaveVelocity.x > 0.0f && m_vSpinTimeLeft.x >= 0.0f)
	{
		m_vVelocity.x = m_vSaveVelocity.x - (m_vSaveVelocity.x * (m_vSpinDownTime.x - m_vSpinTimeLeft.x) / m_vSpinDownTime.x);
	}
	else
	{
		m_vVelocity.x = 0.0f;
		bXDone = DTRUE;
	}

	m_vSpinTimeLeft.y -= fDeltaTime;
	if (m_vSaveVelocity.y > 0.0f && m_vSpinTimeLeft.y >= 0.0f)
	{
		m_vVelocity.y = m_vSaveVelocity.y - (m_vSaveVelocity.y * (m_vSpinDownTime.y - m_vSpinTimeLeft.y) / m_vSpinDownTime.y);
	}
	else
	{
		m_vVelocity.y = 0.0f;
		bYDone = DTRUE;
	}

	m_vSpinTimeLeft.z -= fDeltaTime;
	if (m_vSaveVelocity.z > 0.0f && m_vSpinTimeLeft.z >= 0.0f)
	{
		m_vVelocity.z = m_vSaveVelocity.z - (m_vSaveVelocity.z * (m_vSpinDownTime.z - m_vSpinTimeLeft.z) / m_vSpinDownTime.z);
	}
	else
	{
		m_vVelocity.z = 0.0f;
		bZDone = DTRUE;
	}

	// Call normal update to do the work...

	UpdateNormalRotation();

	if (bXDone && bYDone && bZDone)
	{
		SetOff();
	}
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:52,代码来源:Rotating.cpp

示例2: UpdatePhysics

void VolumeBrush::UpdatePhysics(ContainerPhysics* pCPStruct)
{
    CServerDE* pServerDE = GetServerDE();
    if (m_bHidden || !pServerDE || !pCPStruct || !pCPStruct->m_hObject) return;

    DFLOAT fUpdateDelta = pServerDE->GetFrameTime();

    // Check to see if this object is the player object...

    if (!pServerDE->IsKindOf(pServerDE->GetObjectClass(pCPStruct->m_hObject), m_hPlayerClass))
    {
        // Check to see if this object is a character object...

        DBOOL bCharacter = DFALSE;
        HCLASS hBaseCharClass = pServerDE->GetClass("CBaseCharacter");

        if (pServerDE->IsKindOf(pServerDE->GetObjectClass(pCPStruct->m_hObject), hBaseCharClass))
        {
            bCharacter = DTRUE;

            if (m_bLocked)
            {
                // See if they have the key we need to unlock
                HMESSAGEWRITE hMessage = pServerDE->StartMessageToObject((LPBASECLASS)this, pCPStruct->m_hObject, MID_KEYQUERY);
                pServerDE->WriteToMessageHString(hMessage, m_hstrKeyName);
                pServerDE->EndMessage(hMessage);
            }
        }


        // Update velocity...

        // Dampen velocity and acceleration based on the viscosity of the container...

        if (m_fViscosity > 0.0f)
        {
            VEC_MULSCALAR(pCPStruct->m_Velocity, pCPStruct->m_Velocity, m_fViscosity);
            VEC_MULSCALAR(pCPStruct->m_Acceleration, pCPStruct->m_Acceleration, m_fViscosity);
        }


        // Do special liquid / zero gravity handling...

        if (IsLiquid(m_eContainerCode))
        {
            UpdateLiquidPhysics(pCPStruct, bCharacter);
        }


        // Add any current...

        // Make current relative to update delta (actually change the REAL velocity)...

        DVector vCurrent;
        VEC_MULSCALAR(vCurrent, m_vCurrent, fUpdateDelta);

        VEC_ADD(pCPStruct->m_Velocity, pCPStruct->m_Velocity, vCurrent);
    }

    // Update damage...

    // Make damage relative to update delta...

    if (m_fDamage)
    {
        DFLOAT fTime = pServerDE->GetTime();
        DFLOAT fDamageDeltaTime = fTime - m_fLastDamageTime;

        if (fDamageDeltaTime >= DAMAGE_UPDATE_DELTA || fTime == m_fLastDamageTime)
        {
            m_fLastDamageTime = fTime;

            DVector vDir;
            VEC_INIT(vDir);

            DamageObject(m_hObject, this, pCPStruct->m_hObject, m_fDamage * DAMAGE_UPDATE_DELTA, vDir, vDir, m_nDamageType);
        }
    }

}
开发者ID:jordandavidson,项目名称:lithtech,代码行数:80,代码来源:VolumeBrush.cpp


注:本文中的CServerDE::GetFrameTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。