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


C++ IEntityPhysicalProxy::GetPhysicalEntity方法代码示例

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


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

示例1: NetSerialize

//------------------------------------------------------------------------
bool CProjectile::NetSerialize(TSerialize ser, EEntityAspects aspect, uint8 profile, int pflags)
{
	if(aspect == eEA_Physics)
	{
		pe_type type = PE_NONE;

		switch(profile)
		{
		case ePT_Rigid:
			type = PE_RIGID;
			break;

		case ePT_Particle:
			type = PE_PARTICLE;
			break;

		case ePT_None:
			return true;

		case ePT_Static:
		{
			Vec3 pos = GetEntity()->GetWorldPos();
			Quat ori = GetEntity()->GetWorldRotation();
			ser.Value("pos", pos, 'wrld');
			ser.Value("ori", ori, 'ori1');

			if(ser.IsReading())
				GetEntity()->SetWorldTM(Matrix34::Create(Vec3(1,1,1), ori, pos));
		}

		return true;

		default:
			return false;
		}

		IEntityPhysicalProxy *pEPP = (IEntityPhysicalProxy *) GetEntity()->GetProxy(ENTITY_PROXY_PHYSICS);

		if(ser.IsWriting())
		{
			if(!pEPP || !pEPP->GetPhysicalEntity() || pEPP->GetPhysicalEntity()->GetType() != type)
			{
				gEnv->pPhysicalWorld->SerializeGarbageTypedSnapshot(ser, type, 0);
				return true;
			}
		}
		else if(!pEPP)
		{
			return false;
		}

		pEPP->SerializeTyped(ser, type, pflags);
	}

	return true;
}
开发者ID:Hellraiser666,项目名称:CryGame,代码行数:57,代码来源:Projectile.cpp

示例2: NetSerialize

//-----------------------------------------------------------------------------
bool CNetworkedPhysicsEntity::NetSerialize( TSerialize ser, EEntityAspects aspect, uint8 profile, int flags )
{
	NET_PROFILE_SCOPE("NetworkedPhysicsEntity", ser.IsReading());

	if (aspect == eEA_Physics)
	{
		pe_type type = PE_NONE;
		
		switch (profile)
		{
			case ePhys_PhysicalizedRigid:
			{
				type = PE_RIGID;
				break;
			}
			case ePhys_PhysicalizedStatic:
			{
				type = PE_STATIC;

				// Serialise the position ourselves - physics system won't do it for static entities
				const Matrix34 &worldTM = GetEntity()->GetWorldTM();
				Vec3 worldPos = worldTM.GetTranslation();
				ser.Value("worldPos", worldPos, 'wrld');
				if (ser.IsReading())
				{
					Matrix34 newTM = worldTM;
					newTM.SetTranslation(worldPos);
					GetEntity()->SetWorldTM(newTM);
				}

				break;
			}
		}

		if (type == PE_NONE)
			return true;

		IEntityPhysicalProxy * pEPP = (IEntityPhysicalProxy *) GetEntity()->GetProxy(ENTITY_PROXY_PHYSICS);
		if (ser.IsWriting())
		{
			if (!pEPP || !pEPP->GetPhysicalEntity() || pEPP->GetPhysicalEntity()->GetType() != type)
			{
				gEnv->pPhysicalWorld->SerializeGarbageTypedSnapshot( ser, type, 0 );
				return true;
			}
		}
		else if (!pEPP)
		{
			return false;
		}

		pEPP->SerializeTyped( ser, type, flags );
	}
	return true;
}
开发者ID:Xydrel,项目名称:Infected,代码行数:56,代码来源:NetworkedPhysicsEntity.cpp


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