本文整理汇总了C++中AABB::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB::Add方法的具体用法?C++ AABB::Add怎么用?C++ AABB::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB
的用法示例。
在下文中一共展示了AABB::Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLocalBounds
bool CEntityObject::GetLocalBounds( AABB &bounds )
{
if (pStatObj)
{
bounds.Add(pStatObj->GetAABB());
return true;
}
else if (pCharacter)
{
bounds.Add(pCharacter->GetAABB());
return true;
}
else if (pLight)
{
bounds.Add(Vec3Constants<float>::fVec3_Zero, 0.1f);
return true;
}
else if (pChildRenderNode)
{
pChildRenderNode->GetLocalBounds(bounds);
return true;
}
return false;
}
示例2: GetAABB
AABB Node::GetAABB()
{
AABB box;
for (int i = 0; i < child_array_->Size(); i++)
{
Node * node = (Node*)child_array_->At(i);
AABB tbox = node->GetAABB();
vec3 v = tbox.GetMax();
box.Add(v.x, v.y, v.z);
v = tbox.GetMin();
box.Add(v.x, v.y, v.z);
}
vec3 v = aabb_.GetMax();
box.Add(v.x, v.y, v.z);
v = aabb_.GetMin();
box.Add(v.x,v.y, v.z);
mat4 t = this->GetTransform();
if (parents_)
{
t = parents_->GetTransform() * t;
}
box.SetToTransformedBox(t);
return box;
}
示例3: ComputeGlobalBox
bool AABBTreeOfAABBsBuilder::ComputeGlobalBox(const udword* primitives, udword nb_prims, AABB& global_box) const
{
// Checkings
if(!primitives || !nb_prims) return false;
// Initialize global box
global_box = mAABBArray[primitives[0]];
// Loop through boxes
for(udword i=1;i<nb_prims;i++)
{
// Update global box
global_box.Add(mAABBArray[primitives[i]]);
}
return true;
}
示例4: CalculateBounds
void CVTOLVehicleManager::CalculateBounds(IEntity* pVTOLEntity, SVTOLInfo& info)
{
// Work out final local bounds - includes all children's bounds
AABB aabb;
pVTOLEntity->GetLocalBounds(aabb);
const int numChildren = pVTOLEntity->GetChildCount();
AABB childAABB;
for(int child = 0; child < numChildren; ++child)
{
if(IEntity* pChild = pVTOLEntity->GetChild(child))
{
pChild->GetLocalBounds(childAABB);
aabb.Add(childAABB);
}
}
info.localBounds = aabb;
}
示例5: SerializeXML
void CAreaProxy::SerializeXML( XmlNodeRef &entityNode,bool bLoading )
{
if (m_nFlags & FLAG_NOT_SERIALIZE)
return;
if (bLoading)
{
XmlNodeRef areaNode = entityNode->findChild( "Area" );
if (!areaNode)
return;
int nId=0,nGroup=0,nPriority=0;
float fProximity = 0;
float fHeight = 0;
areaNode->getAttr( "Id",nId );
areaNode->getAttr( "Group",nGroup );
areaNode->getAttr( "Proximity",fProximity );
areaNode->getAttr( "Priority",nPriority );
m_pArea->SetID(nId);
m_pArea->SetGroup(nGroup);
m_pArea->SetProximity(fProximity);
m_pArea->SetPriority(nPriority);
const char* token(0);
XmlNodeRef pointsNode = areaNode->findChild( "Points" );
if (pointsNode)
{
for (int i = 0; i < pointsNode->getChildCount(); i++)
{
XmlNodeRef pntNode = pointsNode->getChild(i);
Vec3 pos;
if (pntNode->getAttr( "Pos",pos ))
m_localPoints.push_back(pos);
// Get sound obstruction
bool bObstructSound = 0;
pntNode->getAttr("ObstructSound", bObstructSound);
m_abObstructSound.push_back(bObstructSound);
}
m_pArea->SetAreaType( ENTITY_AREA_TYPE_SHAPE );
areaNode->getAttr( "Height",fHeight );
m_pArea->SetHeight(fHeight);
// Set points.
OnMove();
}
else if (areaNode->getAttr("SphereRadius",m_fRadius))
{
// Sphere.
areaNode->getAttr("SphereCenter",m_vCenter);
m_pArea->SetSphere( m_pEntity->GetWorldTM().TransformPoint(m_vCenter),m_fRadius );
}
else if (areaNode->getAttr("VolumeRadius",m_fRadius))
{
areaNode->getAttr("Gravity",m_fGravity);
areaNode->getAttr("DontDisableInvisible", m_bDontDisableInvisible);
AABB box;
box.Reset();
// Bezier Volume.
pointsNode = areaNode->findChild( "BezierPoints" );
if (pointsNode)
{
for (int i = 0; i < pointsNode->getChildCount(); i++)
{
XmlNodeRef pntNode = pointsNode->getChild(i);
Vec3 pt;
if (pntNode->getAttr( "Pos",pt))
{
m_bezierPoints.push_back(pt);
box.Add( pt );
}
}
}
m_pArea->SetAreaType( ENTITY_AREA_TYPE_GRAVITYVOLUME );
if (!m_pEntity->GetRenderProxy())
{
IEntityRenderProxyPtr pRenderProxy = crycomponent_cast<IEntityRenderProxyPtr>(m_pEntity->CreateProxy( ENTITY_PROXY_RENDER ));
m_pEntity->SetFlags(m_pEntity->GetFlags() | ENTITY_FLAG_SEND_RENDER_EVENT);
if (box.min.x > box.max.x)
box.min = box.max = Vec3(0,0,0);
box.min-=Vec3(m_fRadius, m_fRadius, m_fRadius);
box.max+=Vec3(m_fRadius, m_fRadius, m_fRadius);
Matrix34 tm = m_pEntity->GetWorldTM_Fast();
box.SetTransformedAABB( m_pEntity->GetWorldTM_Fast().GetInverted(),box );
pRenderProxy->SetLocalBounds(box, true);
}
OnEnable(m_bIsEnable);
}
else if (areaNode->getAttr("AreaSolidFileName",&token))
{
CCryFile file;
//.........这里部分代码省略.........
示例6: DoLocalPlayerChecks
bool CDialogActorContext::DoLocalPlayerChecks(const float dt)
{
// don't check this every frame, but only every .2 secs
m_checkPlayerTimeOut-=dt;
if (m_checkPlayerTimeOut <= 0.0f)
{
do // a dummy loop to use break
{
float awareDistance;
float awareDistanceSq;
float awareAngle;
m_pSession->GetPlayerAwarenessValues(awareDistance, awareAngle);
awareDistanceSq=awareDistance*awareDistance;
m_checkPlayerTimeOut = PLAYER_CHECKTIME;
const float spotAngleCos = cos_tpl(DEG2RAD(awareAngle));
const CDialogSession::TActorContextMap& contextMap = m_pSession->GetAllContexts();
if (contextMap.size() == 1 && contextMap.begin()->first == m_actorID)
{
m_bIsAware = true;
break;
}
// early out, when we don't have to do any checks
if (awareDistance <= 0.0f && awareAngle <= 0.0f)
{
m_bIsAware = true;
break;
}
IEntity* pThisEntity = m_pSession->GetActorEntity(m_actorID);
if (!pThisEntity)
{
assert (false);
m_bIsAware = true;
break;
}
IMovementController* pMC = (m_pIActor != NULL) ? m_pIActor->GetMovementController() : NULL;
if (!pMC)
{
assert (false);
m_bIsAware = true;
break;
}
SMovementState moveState;
pMC->GetMovementState(moveState);
Vec3 viewPos = moveState.eyePosition;
Vec3 viewDir = moveState.eyeDirection;
viewDir.z = 0.0f;
viewDir.NormalizeSafe();
// check the player's position
// check the player's view direction
AABB groupBounds;
groupBounds.Reset();
CDialogSession::TActorContextMap::const_iterator iter = contextMap.begin();
CDialogScript::SActorSet lookingAt = 0;
while (iter != contextMap.end())
{
if (iter->first != m_actorID)
{
IEntity* pActorEntity = m_pSession->GetActorEntity(iter->first);
if (pActorEntity)
{
Vec3 vEntityPos = pActorEntity->GetWorldPos();
AABB worldBounds;
pActorEntity->GetWorldBounds(worldBounds);
groupBounds.Add(worldBounds);
// calc if we look at it somehow
Vec3 vEntityDir = vEntityPos - viewPos;
vEntityDir.z = 0.0f;
vEntityDir.NormalizeSafe();
if (viewDir.IsUnit() && vEntityDir.IsUnit())
{
const float dot = clamp_tpl(viewDir.Dot(vEntityDir),-1.0f,+1.0f); // clamping should not be needed
if (spotAngleCos <= dot)
lookingAt.SetActor(iter->first);
DiaLOG::Log(DiaLOG::eDebugC, "Angle to actor %d is %f deg", iter->first, RAD2DEG(acos_tpl(dot)));
}
}
}
++iter;
}
const float distanceSq = pThisEntity->GetWorldPos().GetSquaredDistance(groupBounds.GetCenter());
CCamera& camera=gEnv->pSystem->GetViewCamera();
const bool bIsInAABB = camera.IsAABBVisible_F(groupBounds);
const bool bIsInRange = distanceSq <= awareDistanceSq;
const bool bIsLooking = contextMap.empty() || lookingAt.NumActors() > 0;
m_bIsAwareLooking = awareAngle <= 0.0f || (bIsInAABB || bIsLooking);
m_bIsAwareInRange = awareDistance <= 0.0f || bIsInRange;
m_bIsAware = m_bIsAwareLooking && m_bIsAwareInRange;
DiaLOG::Log(DiaLOG::eDebugB, "[DIALOG] LPC: %s awDist=%f awAng=%f AABBVis=%d IsLooking=%d InRange=%d [Distance=%f LookingActors=%d] Final=%saware",
m_pSession->GetDebugName(), awareDistance, awareAngle, bIsInAABB, bIsLooking, bIsInRange, sqrt_tpl(distanceSq), lookingAt.NumActors(), m_bIsAware ? "" : "not ");
} while (false);
}
//.........这里部分代码省略.........