Ejemplo n.º 1
0
//------------------------------------------------------------------------
void CVehiclePartAnimated::Reset()
{
	CVehiclePartBase::Reset();

	SetDrivingProxy(false);

	if (m_slot > -1 && m_pCharInstance)
	{
		ISkeletonAnim* pSkeletonAnim = m_pCharInstance->GetISkeletonAnim();
		CRY_ASSERT(pSkeletonAnim);
		ISkeletonPose* pSkeletonPose = m_pCharInstance->GetISkeletonPose();
		CRY_ASSERT(pSkeletonPose);
		IDefaultSkeleton &rIDefaultSkeleton = m_pCharInstance->GetIDefaultSkeleton();
		pSkeletonAnim->StopAnimationsAllLayers();
		pSkeletonPose->SetDefaultPose();
		pSkeletonPose->SetForceSkeletonUpdate(0);

		for (int i = 0; i < rIDefaultSkeleton.GetJointCount(); ++i)
		{
			pSkeletonPose->SetMaterialOnJoint(i, NULL);
		}
	}

	m_iRotChangedFrameId = 0;
}
Ejemplo n.º 2
0
void CScriptbind_Entity::StopAnimationsInAllLayers(IEntity *pEntity, int slot)
{
	ICharacterInstance *pCharacter = pEntity->GetCharacter(slot);
	if(!pCharacter)
		return;

	ISkeletonAnim *pSkeletonAnim = pCharacter->GetISkeletonAnim();
	if(!pSkeletonAnim)
		return;

	pSkeletonAnim->StopAnimationsAllLayers();
}
Ejemplo n.º 3
0
//------------------------------------------------------------------------
void CVehiclePartAnimated::InitGeometry()
{
	if (!m_pSharedParameters->m_filename.empty())
	{
		m_slot          = GetEntity()->LoadCharacter(m_slot, m_pSharedParameters->m_filename.c_str());
		m_pCharInstance = GetEntity()->GetCharacter(m_slot);

		if (m_pCharInstance)
		{
			if (m_pCharInstance->GetIMaterial() && !GetEntity()->GetMaterial())
			{
				SetMaterial(m_pCharInstance->GetIMaterial());
			}

			ISkeletonAnim*    pSkeletonAnim     = m_pCharInstance->GetISkeletonAnim();
			ISkeletonPose*    pSkeletonPose     = m_pCharInstance->GetISkeletonPose();
			IDefaultSkeleton &rIDefaultSkeleton = m_pCharInstance->GetIDefaultSkeleton();

			if (pSkeletonAnim)
				pSkeletonAnim->StopAnimationsAllLayers();

			if (m_hideCount == 0)
				GetEntity()->SetSlotFlags(m_slot, GetEntity()->GetSlotFlags(m_slot) | ENTITY_SLOT_RENDER);
			else
				GetEntity()->SetSlotFlags(m_slot, GetEntity()->GetSlotFlags(m_slot) & ~(ENTITY_SLOT_RENDER | ENTITY_SLOT_RENDER_NEAREST));

#if ENABLE_VEHICLE_DEBUG
			if (IsDebugParts())
			{
				CryLog("joint transformations for %s", m_pCharInstance->GetFilePath());

				for (int i = 0; i < rIDefaultSkeleton.GetJointCount(); ++i)
				{
					VehicleUtils::LogMatrix(rIDefaultSkeleton.GetJointNameByID(i), Matrix34(pSkeletonPose->GetRelJointByID(i)));
				}
			}
#endif
		}

		if (!m_pCharInstanceDestroyed && !m_pSharedParameters->m_filenameDestroyed.empty())
			m_pCharInstanceDestroyed = gEnv->pCharacterManager->CreateInstance(m_pSharedParameters->m_filenameDestroyed.c_str());

		if (m_pCharInstanceDestroyed)
		{
			m_pCharInstanceDestroyed->AddRef();

#if ENABLE_VEHICLE_DEBUG
			if (IsDebugParts())
			{
				CryLog("joint transformations for %s", m_pCharInstanceDestroyed->GetFilePath());

				ISkeletonPose*    pSkeletonDestroyed = m_pCharInstanceDestroyed->GetISkeletonPose();
				IDefaultSkeleton &rIDefaultSkeleton  = m_pCharInstanceDestroyed->GetIDefaultSkeleton();
				for (int i = 0; i < rIDefaultSkeleton.GetJointCount(); ++i)
				{
					VehicleUtils::LogMatrix(rIDefaultSkeleton.GetJointNameByID(i), Matrix34(pSkeletonDestroyed->GetRelJointByID(i)));
				}
			}
#endif
		}
	}

	if (m_pSharedParameters->m_isPhysicalized && m_slot > -1)
		GetEntity()->UnphysicalizeSlot(m_slot);

	if (m_pCharInstance)
	{
		m_pCharInstance->GetISkeletonAnim()->StopAnimationsAllLayers();

		if (m_hideCount == 0)
			GetEntity()->SetSlotFlags(m_slot, GetEntity()->GetSlotFlags(m_slot) | ENTITY_SLOT_RENDER);
		else
			GetEntity()->SetSlotFlags(m_slot, GetEntity()->GetSlotFlags(m_slot) & ~(ENTITY_SLOT_RENDER | ENTITY_SLOT_RENDER_NEAREST));
	}

	// Disable hand-placed (static) decals on vehicles
	GetEntity()->SetFlags(GetEntity()->GetFlags() | ENTITY_FLAG_NO_DECALNODE_DECALS);
}