本文整理汇总了C++中Vec3::Dot方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec3::Dot方法的具体用法?C++ Vec3::Dot怎么用?C++ Vec3::Dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec3
的用法示例。
在下文中一共展示了Vec3::Dot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsPointOnMyFlank
bool IsPointOnMyFlank(EntityId actorEntityID, const Vec3& actorPos, const Vec3& targetPos, const Vec3& pointPos)
{
CAIBattleFrontGroup* group = gGameAIEnv.battleFrontModule->GetGroupForEntity(actorEntityID);
ASSERT_IS_NOT_NULL(group);
if (!group || group->GetMemberCount() == 1)
return true; // I'm alone so this is my flank
const Vec3& groupAveragePos = group->GetAveragePosition();
// Set up a coordinate system where Y corresponds to the direction
// from the battle group's center position towards the target
Vec3 Y = (targetPos - groupAveragePos);
Vec3 X = Vec3(0,0,-1).Cross(Y);
// Calculate flank side sign
Vec3 vGroupAveragePosToActor = actorPos - groupAveragePos;
float flankSideSign = (vGroupAveragePosToActor.Dot(X) > 0.0f) ? 1.0f : -1.0f; // Flank side sign (-1 for left, +1 for right)
// Calculate how far the point is on the X-axis
Vec3 groupAveragePosToPoint = pointPos - groupAveragePos;
float pointDistOnXAxis = groupAveragePosToPoint.Dot(X);
bool pointIsOnMyFlank = pointDistOnXAxis * flankSideSign > 0.0f;
return pointIsOnMyFlank;
}
示例2: InvSqrt
bool OrE::Math::HitTest( Ellipsoid e1, Ellipsoid e2 )
{
// Absolute squared distance vector from e2 to e1
Vec3 vDist = e1.vMiddlePoint - e2.vMiddlePoint;
vDist *= vDist;
// Project ray to both ellipsoid surfaces. All what matters is,
// the the sum of the distances to surface is smaller than the length of
// the distance vector.
// Vec3 vRSum = vDist * ( InvSqrt( vDist.Dot( vDist * e1.vRadiiInvSq ) ) + InvSqrt( vDist.Dot( vDist * e2.vRadiiInvSq ) ) );
// return vRSum.LengthSq() >= vDist.LengthSq();
return InvSqrt( vDist.Dot( e1.vRadiiInvSq ) ) + InvSqrt( vDist.Dot( e2.vRadiiInvSq ) ) >= 1.0f;
}
示例3: Update
EStatus Update(float timePassed)
{
if (IsTransitioningOut())
{
const float ROTATION_LERP_SPEED = 10.0f;
//--- Blend body rotation to match current view
Ang3 targetViewDir = m_player.GetAngles();
Quat targetRotation = Quat::CreateRotationZ(targetViewDir.z);
Quat newRotation = Quat::CreateNlerp(m_player.GetEntity()->GetRotation(), targetRotation, timePassed*ROTATION_LERP_SPEED);
m_player.GetEntity()->SetRotation(newRotation);
}
else
{
static uint32 leanParamCRC = gEnv->pSystem->GetCrc32Gen()->GetCRC32Lowercase("SlideFactor");
const Matrix34 &worldTM = m_player.GetEntity()->GetWorldTM();
const Vec3 baseRgt = worldTM.GetColumn0();
const Vec3 baseFwd = worldTM.GetColumn1();
const Vec3 lookFwd = m_player.GetViewQuatFinal().GetColumn1();
const float leanAngle = cry_acosf(baseFwd.Dot(lookFwd));
float targetLeanFactor = clamp(leanAngle / MAX_LEAN_ANGLE, 0.0f, 1.0f);
if (baseRgt.Dot(lookFwd) < 0.0f)
{
targetLeanFactor *= -1.0f;
}
CWeapon *pWeapon = m_player.GetWeapon(m_player.GetCurrentItemId());
if (pWeapon)
{
IFireMode *pFiremode = pWeapon->GetFireMode(pWeapon->GetCurrentFireMode());
if (pFiremode && (pFiremode->GetNextShotTime() > 0.0f))
{
targetLeanFactor = 0.0f;
}
}
const float delta = targetLeanFactor - m_leanFactor;
const float step = LEAN_RATE * timePassed;
const float newLeanFactor = (float)__fsel(delta, min(m_leanFactor + step, targetLeanFactor), max(m_leanFactor - step, targetLeanFactor));
SWeightData weightData;
weightData.weights[0] = newLeanFactor;
SetParam(leanParamCRC, weightData);
m_leanFactor = newLeanFactor;
if (GetRootScope().IsDifferent(m_fragmentID, m_fragTags))
{
SetFragment(m_fragmentID, m_fragTags);
}
}
return TPlayerAction::Update(timePassed);
}
示例4: LookAtRH
static Transform LookAtRH(const Vec3 eye, const Vec3 at, const Vec3 up)
{
Vec3 n = (eye - at).Normalized();
Vec3 u = up.Cross(n).Normalized();
Vec3 v = n.Cross(u);
float w = sqrtf(1.0f + u.x + v.y + n.z) * 0.5f;
float w4 = 1.0f / (4.0f * w);
return Transform( Vec3(-u.Dot(eye), -v.Dot(eye), -n.Dot(eye)), // Position
Quat((v.z-n.y) * w4, (n.x-u.z) * w4, (u.y-v.x) * w4, -w).Normalized(), // Rotation
1); // Scale
}
示例5: AdjustLaserFPDirection
//------------------------------------------------------------------
void CLam::AdjustLaserFPDirection(CItem* parent, Vec3 &dir, Vec3 &pos)
{
pos = parent->GetSlotHelperPos(eIGS_FirstPerson,m_laserHelperFP.c_str(),true);
Quat lamRot = Quat(parent->GetSlotHelperRotation(eIGS_FirstPerson,m_laserHelperFP.c_str(),true));
dir = -lamRot.GetColumn0();
if(!m_lamparams.isLamRifle)
dir = lamRot.GetColumn1();
CActor *pActor = parent->GetOwnerActor();
IMovementController * pMC = pActor ? pActor->GetMovementController() : NULL;
if (pMC)
{
SMovementState info;
pMC->GetMovementState(info);
CWeapon* pWep = static_cast<CWeapon*>(parent->GetIWeapon());
if(pWep && (pWep->IsReloading() || (!pActor->CanFire() && !pWep->IsZoomed())))
return;
if(dir.Dot(info.fireDirection)<0.985f)
return;
CCamera& camera = gEnv->pSystem->GetViewCamera();
pos = camera.GetPosition();
dir = camera.GetMatrix().GetColumn1();
dir.Normalize();
}
}
示例6: _updateProjector
void UnderWaterGodRay::_updateProjector()
{
Plane p(Vec3(0, 1, 0), mWaterPosition);
Vec3 sunDir = Environment::Instance()->GetEvParam()->SunDir;
Vec3 sunPos = Environment::Instance()->GetEvParam()->SunPos;
Ray r(sunPos, sunDir);
RayIntersectionInfo info = r.Intersection(p);
mEnable = info.iterscetion;
mProjPosition = sunPos + sunDir * info.distance;
Vec3 y(0, 1, 0);
if (sunDir.Dot(y) < 0.001)
y = Vec3(0, 0, -1);
Vec3 x = y.Cross(sunDir);
y = sunDir.Cross(x);
mProjMatrix.MakeRotationAxis(x, y, sunDir);
mProjMatrix._41 = mProjPosition.x;
mProjMatrix._42 = mProjPosition.y;
mProjMatrix._43 = mProjPosition.z;
}
示例7: Inside
bool Plane::Inside( Vec3 p, const float radius ) const
{
float distance = p.Dot( n ) + d;
// we need to consider if the point is outside the plane, but its radius may compensate for it
// -> we should test distance + radius >= 0
return ( distance >= -radius );
}
示例8: Arccos
// ******************************************************************************** //
// The spherical interpolation applies only to normal vectors
Vec3 OrE::Math::Slerp(const Vec3& v1, const Vec3& v2, const float t)
{
float fOmega = Arccos( Clamp(v1.Dot(v2), -1.0f, 1.0f) );
float f1 = Sin( fOmega * (1.0f-t) );
float f2 = Sin( fOmega * t );
return Vec3( v1.x*f1+v2.x*f2, v1.y*f1+v2.y*f2, v1.z*f1+v2.z*f2 ).Normalize();
}
示例9: CalculateStayAliveTime_Direction
float CRateOfDeathHelper_Target::CalculateStayAliveTime_Direction( const CRateOfDeathHelper_AttackerInfo& attacker ) const
{
CRY_ASSERT( m_pTarget );
const float directionInc = RateOfDeath::GetDirectionInc();
const Vec3& attackerPosition = attacker.GetPosition();
const Vec3& targetPosition = m_pTarget->GetPos();
Vec3 targetDirection = targetPosition - attackerPosition;
const float targetDistance = targetDirection.NormalizeSafe();
const float thr1 = cosf( DEG2RAD( 30.0f ) );
const float thr2 = cosf( DEG2RAD( 95.0f ) );
const Vec3& targetViewDirection = m_pTarget->GetViewDir();
const float dot = -targetDirection.Dot( targetViewDirection );
if ( dot < thr2 )
{
return directionInc * 2.0f;
}
else if ( dot < thr1 )
{
return directionInc;
}
return 0;
}
示例10: Hit
//------------------------------------------------------------------------
void CMelee::Hit(geom_contact *contact, const Vec3 &dir, float damageScale, bool remote)
{
CActor *pOwner = m_pWeapon->GetOwnerActor();
if (!pOwner)
{
return;
}
Vec3 view(0.0f, 1.0f, 0.0f);
if (IMovementController *pMC = pOwner->GetMovementController())
{
SMovementState state;
pMC->GetMovementState(state);
view = state.eyeDirection;
}
// some corrections to make sure the impulse is always away from the camera, and is not a backface collision
bool backface = dir.Dot(contact->n) > 0;
bool away = dir.Dot(view.normalized()) > 0; // away from cam?
Vec3 normal = contact->n;
Vec3 ndir = dir;
if (backface)
{
if (away)
{
normal = -normal;
}
else
{
ndir = -dir;
}
}
else
{
if (!away)
{
ndir = -dir;
normal = -normal;
}
}
IPhysicalEntity *pCollider = gEnv->pPhysicalWorld->GetPhysicalEntityById(contact->iPrim[0]);
Hit(contact->pt, ndir, normal, pCollider, contact->iPrim[1], 0, contact->id[1], damageScale, remote);
}
示例11: OnCollision
void CScriptProxy::OnCollision(CEntity* pTarget, int matId, const Vec3 &pt, const Vec3 &n, const Vec3 &vel, const Vec3 &targetVel, int partId, float mass)
{
if (!CurrentState()->IsStateFunctionImplemented(ScriptState_OnCollision))
return;
FUNCTION_PROFILER( GetISystem(), PROFILE_ENTITY );
if (!m_hitTable)
m_hitTable.Create(gEnv->pScriptSystem);
{
Vec3 dir(0, 0, 0);
CScriptSetGetChain chain(m_hitTable);
chain.SetValue("normal", n);
chain.SetValue("pos", pt);
if (vel.GetLengthSquared() > 1e-6f)
{
dir = vel.GetNormalized();
chain.SetValue("dir", dir);
}
chain.SetValue("velocity", vel);
chain.SetValue("target_velocity", targetVel);
chain.SetValue("target_mass", mass);
chain.SetValue("partid", partId);
chain.SetValue("backface", n.Dot(dir) >= 0);
chain.SetValue("materialId", matId);
if (pTarget)
{
ScriptHandle sh;
sh.n = pTarget->GetId();
if (pTarget->GetPhysics())
{
chain.SetValue("target_type", (int)pTarget->GetPhysics()->GetType());
}
else
{
chain.SetToNull("target_type");
}
chain.SetValue("target_id", sh);
if (pTarget->GetScriptTable())
{
chain.SetValue("target", pTarget->GetScriptTable());
}
}
else
{
chain.SetToNull("target_type");
chain.SetToNull("target_id");
chain.SetToNull("target");
}
}
m_pScript->CallStateFunction( CurrentState(),m_pThis,ScriptState_OnCollision, m_hitTable);
}
示例12: RemovePenetratingComponent
Vec3 CAnimatedCharacter::RemovePenetratingComponent(const Vec3& v, const Vec3& n) const
{
float penetration = n.Dot(v);
if (penetration >= 0.0f)
return v;
return (v - n * penetration);
}
示例13: AngleBetweenVectors
inline float AngleBetweenVectors( const Vec3 &v1,const Vec3 &v2 )
{
float a = acos_tpl(v1.Dot(v2));
Vec3 r = v1.Cross(v2);
if (r.z < 0)
a = -a;
return a;
}
示例14: forward
// MakeLookAt
//------------------------------------------------------------------------------
void Mat44::MakeLookAt( const Vec3 & pos, const Vec3 & lookAt, const Vec3 & upVector )
{
// generate the forward vector
Vec3 forward( pos - lookAt );
forward.Normalise();
Vec3 right = upVector.Cross( forward );
right.Normalise();
Vec3 up = forward.Cross( right );
up.Normalise();
col0 = Vec4( right.x, up.x, forward.x, 0.0f );
col1 = Vec4( right.y, up.y, forward.y, 0.0f ),
col2 = Vec4( right.z, up.z, forward.z, 0.0f ),
col3 = Vec4( -right.Dot( pos ), -up.Dot( pos ), -forward.Dot( pos ), 1.0f );
}
示例15: IsGotYourBackKill
bool SkillKill::IsGotYourBackKill(CPlayer* pShooterPlayer, CPlayer* pTargetPlayer)
{
//To use the new actor manager stuff when merged back to postalpha
const float maxDistSq = sqr(g_pGameCVars->g_gotYourBackKill_targetDistFromFriendly);
const float fovRange = cry_cosf(DEG2RAD(g_pGameCVars->g_gotYourBackKill_FOVRange));
IActorIteratorPtr pActorIterator = g_pGame->GetIGameFramework()->GetIActorSystem()->CreateActorIterator();
Vec3 targetLocation = pTargetPlayer->GetEntity()->GetWorldPos();
SMovementState targetMovementState;
pTargetPlayer->GetMovementController()->GetMovementState(targetMovementState);
Vec3 targetAimDirection = targetMovementState.aimDirection;
while(CActor* pActor = static_cast<CActor*>(pActorIterator->Next()))
{
if(pActor != pShooterPlayer && !pActor->IsDead() && pShooterPlayer->IsFriendlyEntity(pActor->GetEntityId()))
{
Vec3 actorLocation = pActor->GetEntity()->GetWorldPos();
Vec3 distance = actorLocation - targetLocation;
if(distance.GetLengthSquared() < maxDistSq)
{
distance.Normalize();
if(distance.Dot(targetAimDirection) > fovRange)
{
SMovementState actorMovementState;
pActor->GetMovementController()->GetMovementState(actorMovementState);
Vec3 actorAimDirection = actorMovementState.aimDirection;
if(actorAimDirection.Dot(-distance) < fovRange)
{
return true;
}
}
}
}
}
return false;
}