Ejemplo n.º 1
0
const vector<double> Avatar::getCenterEyePosition() const {
	vector<double> headPos(getTilePosition());
	// NAO center eye is 524mm above the base
	// see http://doc.aldebaran.com/1-14/family/nao_h25/dimensions_h25.html
	headPos[1] += 0.524;
	return headPos;
}
void CPlayerRotation::ProcessLean()
{
	float leanAmt(0.0f);

	if(m_stats.isOnLadder)
	{
		return;
	}

	if (!m_stats.inZeroG || m_stats.inAir < 0.1f)
	{
		if(float sLean = m_player.GetSpeedLean())
		{
			leanAmt = std::min(1.0f, sLean * 0.05f);
		}
		else if((m_actions & (ACTION_LEANLEFT | ACTION_LEANRIGHT)) != 0)
		{
			leanAmt = ((m_actions & ACTION_LEANLEFT) ? -1.0f : 0.0f) + ((m_actions & ACTION_LEANRIGHT) ? 1.0f : 0.0f);
		}
		else if(fabsf(m_desiredLeanAmount) > 0.01f)
		{
			leanAmt = m_desiredLeanAmount;
		}
	}

	EStance stance = m_player.GetStance();

	if (stance == STANCE_PRONE)
	{
		leanAmt *= 0.65f;
	}

	m_leanAmount = leanAmt;

	//check if its possible
	if (m_leanAmount * m_leanAmount > 0.01f)
	{
		float noLean(0.0f);
		Vec3 headPos(m_player.GetEntity()->GetWorldPos() + m_baseQuat * m_player.GetStanceViewOffset(stance, &noLean));
		Vec3 newPos(m_player.GetEntity()->GetWorldPos() + m_baseQuat * m_player.GetStanceViewOffset(stance, &m_leanAmount));
		/*gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(headPos, 0.05f, ColorB(0,0,255,255) );
		gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(newPos, 0.05f, ColorB(0,0,255,255) );
		gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(headPos, ColorB(0,0,255,255), newPos, ColorB(0,0,255,255));*/
		ray_hit hit;
		int rayFlags(rwi_stop_at_pierceable | rwi_colltype_any); //COLLISION_RAY_PIERCABILITY & rwi_pierceability_mask);
		IPhysicalEntity *pSkip(m_player.GetEntity()->GetPhysics());
		float distMult(3.0f);

		if (gEnv->pPhysicalWorld->RayWorldIntersection(headPos + m_viewQuat.GetColumn1() * 0.25f, (newPos - headPos)*distMult, ent_terrain | ent_static | ent_rigid | ent_sleeping_rigid, rayFlags, &hit, 1, &pSkip, 1))
		{
			float dist((headPos - newPos).len2() * distMult);
			m_leanAmount *= ((hit.pt - headPos).len2() / dist) / distMult;
			//gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(hit.pt, 0.05f, ColorB(0,255,0,255) );
		}
	}
}
Ejemplo n.º 3
0
void SelfLocator::drawSamples()
{
  const int numberOfSamples(samples->size());
  const float maxWeighting = 2 * totalWeighting / numberOfSamples;
  for(int i = 0; i < numberOfSamples; ++i)
  {
    const Sample& s(samples->at(i));
    const Pose2D pose(s.angle, (float) s.translation.x, (float) s.translation.y);
    unsigned char weighting = (unsigned char)(s.weighting / maxWeighting * 255);
    Vector2<> bodyPoints[4] = {Vector2<>(55, 90),
                               Vector2<>(-55, 90),
                               Vector2<>(-55, -90),
                               Vector2<>(55, -90)
                              };
    for(int j = 0; j < 4; ++j)
    {
      bodyPoints[j] = Geometry::rotate(bodyPoints[j], pose.rotation);
      bodyPoints[j] += pose.translation;
    }
    Vector2<> headPos(30, 0);
    headPos = Geometry::rotate(headPos, pose.rotation);
    headPos += pose.translation;
    //ColorRGBA color = s.weighting ? ColorRGBA(weighting, weighting, weighting) : ColorRGBA(255, 0, 0);
    if(s.cluster == poseCalculator->getIndexOfBestCluster())
    {
      //color = ColorRGBA(200, 0, 200);
    }
    /*POLYGON("module:SelfLocator:samples", 4, bodyPoints,
            0, // pen width
            Drawings::ps_solid,
            ColorRGBA(180, 180, 180),
            Drawings::bs_solid,
            color);
    CIRCLE("module:SelfLocator:samples",
           headPos.x,
           headPos.y,
           30,
           0, // pen width
           Drawings::ps_solid,
           ColorRGBA(180, 180, 180),
           Drawings::bs_solid,
           ColorRGBA(180, 180, 180));*/
  }
}
Ejemplo n.º 4
0
// has to be changed! (maybe bone position)
//------------------------------------------------------------------------
int CScriptBind_Actor::GetHeadPos(IFunctionHandler *pH)
{
	CActor *pActor = GetActor(pH);
	if (!pActor)
		return pH->EndFunction();
	
	//FIXME:dir is not used
	//	Vec3 dir(0,0,0);
	//	Vec3 pos(0,0,0);
	//	pActor->GetActorInfo(pos,dir);

	Vec3 headPos(0,0,0);

	if (IMovementController * pMC = pActor->GetMovementController())
	{
		SMovementState ms;
		pMC->GetMovementState( ms );
		headPos = ms.eyePosition;
	}

	return pH->EndFunction(Script::SetCachedVector( headPos, pH, 1 ));	
}
Ejemplo n.º 5
0
void CPlayerRotation::ProcessLean()
{
	float leanAmt(0.0f);

	if(m_stats.isOnLadder)
		return;

	if (!m_stats.inZeroG || m_stats.inAir<0.1f)
	{
		if(float sLean = m_player.GetSpeedLean())
			leanAmt = std::min(1.0f, sLean * 0.05f);
		else if((m_actions & (ACTION_LEANLEFT|ACTION_LEANRIGHT)) != 0)
			leanAmt = ((m_actions & ACTION_LEANLEFT)?-1.0f:0.0f) + ((m_actions & ACTION_LEANRIGHT)?1.0f:0.0f);
		else if(fabsf(m_desiredLeanAmount) > 0.01f)
			leanAmt = m_desiredLeanAmount;
	}
	
	
	// head offset model for leaning and for forward tilting based on tracker info...
	if (m_player.IsClient() && g_vr->initialized())
	{	
		Ang3 tmp;
		g_vr->headOrientation(tmp);
		float headRoll = RAD2DEG(tmp.y);

		if ( headRoll > 180.f ) //handle wrap around
		{
			headRoll = -360.f + headRoll;
		}
		else if ( headRoll < -180.f )
		{
			headRoll = 360 + headRoll;
		}

		leanAmt = headRoll / 45.f;

		// CryLogAlways("Head Roll: %f Lean: %f", headRoll, leanAmt);

	}
			
	EStance stance = m_player.GetStance();
	if (stance == STANCE_PRONE)
		leanAmt *= 0.65f;

	m_leanAmount = leanAmt;
	
	//check if its possible
	if (m_leanAmount*m_leanAmount > 0.01f)
	{
		float noLean(0.0f);
		Vec3 headPos(m_player.GetEntity()->GetWorldPos() + m_baseQuat * m_player.GetStanceViewOffset(stance,&noLean));
		Vec3 newPos(m_player.GetEntity()->GetWorldPos() + m_baseQuat * m_player.GetStanceViewOffset(stance,&m_leanAmount));

		/*gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(headPos, 0.05f, ColorB(0,0,255,255) );
		gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(newPos, 0.05f, ColorB(0,0,255,255) );
		gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(headPos, ColorB(0,0,255,255), newPos, ColorB(0,0,255,255));*/

		ray_hit hit;
		int rayFlags(rwi_stop_at_pierceable|rwi_colltype_any);//COLLISION_RAY_PIERCABILITY & rwi_pierceability_mask);
		IPhysicalEntity *pSkip(m_player.GetEntity()->GetPhysics());

		float distMult(3.0f);

		if (gEnv->pPhysicalWorld->RayWorldIntersection(headPos + m_viewQuat.GetColumn1() * 0.25f, (newPos - headPos)*distMult, ent_terrain|ent_static|ent_rigid|ent_sleeping_rigid, rayFlags, &hit, 1, &pSkip, 1))
		{
			float dist((headPos - newPos).len2() * distMult);
			m_leanAmount *= ((hit.pt - headPos).len2() / dist) / distMult;

			//gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(hit.pt, 0.05f, ColorB(0,255,0,255) );
		}
	}
}