コード例 #1
0
//------------------------------------------------------------------------
void CVehicleActionDeployRope::Update(const float deltaTime)
{
	if (!m_ropeUpperId && !m_ropeLowerId && !m_actorId)
		return;

	IActorSystem* pActorSystem = gEnv->pGame->GetIGameFramework()->GetIActorSystem();
	assert(pActorSystem);

	IActor* pActor = pActorSystem->GetActor(m_actorId);
	if (!pActor)
		return;

	Vec3 worldPos = pActor->GetEntity()->GetWorldTM().GetTranslation();

	if (IRopeRenderNode* pRopeUpper = GetRopeRenderNode(m_ropeUpperId))
	{
		Vec3 points[2];
		points[0] = m_pRopeHelper->GetWorldTM().GetTranslation();
		points[1] = worldPos;

		pRopeUpper->SetPoints(points, 2);

		float lenghtLeft = max(0.0f, g_ropeLenght - (points[0].z - points[1].z));

		if (IRopeRenderNode* pRopeLower = GetRopeRenderNode(m_ropeLowerId))
		{
			Vec3 points[2];
			points[0] = worldPos;
			points[1] = Vec3(worldPos.x, worldPos.y, worldPos.z - lenghtLeft);

			pRopeLower->SetPoints(points, 2);
		}
	}
}
コード例 #2
0
//------------------------------------------------------------------------
void CVehicleActionDeployRope::AttachOnRope(IEntity *pEntity)
{
	assert(pEntity);

	if(!pEntity)
		return;

	IRopeRenderNode *pRopeUpper = GetRopeRenderNode(m_ropeUpperId);

	if(!pRopeUpper)
		return;

	assert(pRopeUpper->GetPointsCount() >= 2);

	IPhysicalEntity *pRopePhys = pRopeUpper->GetPhysics();
	assert(pRopePhys);

	typedef std::vector <Vec3> TVec3Vector;
	TVec3Vector points;

	int pointCount;

	pe_status_rope ropeStatus;

	if(pRopePhys->GetStatus(&ropeStatus))
		pointCount = ropeStatus.nSegments + 1;
	else
		pointCount = 0;

	if(pointCount < 2)
		return;

	points.resize(pointCount);
	ropeStatus.pPoints = &points[0];

	if(pRopePhys->GetStatus(&ropeStatus))
	{
		Matrix34 worldTM;
		worldTM.SetIdentity();
		worldTM = Matrix33(m_pVehicle->GetEntity()->GetWorldTM());
		worldTM.SetTranslation(ropeStatus.pPoints[1]);
		pEntity->SetWorldTM(worldTM);
	}

	pRopeUpper->LinkEndEntities(m_pVehicle->GetEntity()->GetPhysics(), pEntity->GetPhysics());
}