本文整理汇总了C++中BoundingBox::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBox::Contains方法的具体用法?C++ BoundingBox::Contains怎么用?C++ BoundingBox::Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBox
的用法示例。
在下文中一共展示了BoundingBox::Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
std::vector<v2_t> GetPointProjections(const CameraInfo &cam,
const std::vector<PointData> &points,
const std::vector<int> &indices,
bool inside_only,
int &num_inside)
{
int num_points = (int) indices.size();
std::vector<v2_t> projs;
BoundingBox bbox = cam.GetBoundingBox();
num_inside = 0;
for (int i = 0; i < num_points; i++) {
int pidx = indices[i];
const PointData &p = points[pidx];
double proj[2];
#if 1
bool in_front = cam.Project(p.m_pos, proj);
if (!in_front)
continue;
bool inside = bbox.Contains(proj[0], proj[1]);
#else
bool inside = cam.Project(p.m_pos, proj);
#endif
if (inside)
num_inside++;
if (inside_only && inside)
projs.push_back(v2_new(proj[0], proj[1]));
else if (!inside_only)
projs.push_back(v2_new(proj[0], proj[1]));
}
return projs;
}
示例2: Collide
//--------------------------------------------------------------------------------------
// Test collisions between pairs of collision objects using XNACollision functions
//--------------------------------------------------------------------------------------
void Collide()
{
// test collisions between objects and frustum
g_SecondarySpheres[0].collision = g_PrimaryFrustum.Contains( g_SecondarySpheres[0].sphere );
g_SecondaryOrientedBoxes[0].collision = g_PrimaryFrustum.Contains( g_SecondaryOrientedBoxes[0].obox );
g_SecondaryAABoxes[0].collision = g_PrimaryFrustum.Contains( g_SecondaryAABoxes[0].aabox );
g_SecondaryTriangles[0].collision = g_PrimaryFrustum.Contains( g_SecondaryTriangles[0].pointa,
g_SecondaryTriangles[0].pointb,
g_SecondaryTriangles[0].pointc );
// test collisions between objects and aligned box
g_SecondarySpheres[1].collision = g_PrimaryAABox.Contains( g_SecondarySpheres[1].sphere );
g_SecondaryOrientedBoxes[1].collision = g_PrimaryAABox.Contains( g_SecondaryOrientedBoxes[1].obox );
g_SecondaryAABoxes[1].collision = g_PrimaryAABox.Contains( g_SecondaryAABoxes[1].aabox );
g_SecondaryTriangles[1].collision = g_PrimaryAABox.Contains( g_SecondaryTriangles[1].pointa,
g_SecondaryTriangles[1].pointb,
g_SecondaryTriangles[1].pointc );
// test collisions between objects and oriented box
g_SecondarySpheres[2].collision = g_PrimaryOrientedBox.Contains( g_SecondarySpheres[2].sphere );
g_SecondaryOrientedBoxes[2].collision = g_PrimaryOrientedBox.Contains( g_SecondaryOrientedBoxes[2].obox );
g_SecondaryAABoxes[2].collision = g_PrimaryOrientedBox.Contains( g_SecondaryAABoxes[2].aabox );
g_SecondaryTriangles[2].collision = g_PrimaryOrientedBox.Contains( g_SecondaryTriangles[2].pointa,
g_SecondaryTriangles[2].pointb,
g_SecondaryTriangles[2].pointc );
// test collisions between objects and ray
float fDistance = -1.0f;
float fDist;
if ( g_SecondarySpheres[3].sphere.Intersects( g_PrimaryRay.origin, g_PrimaryRay.direction, fDist ) )
{
fDistance = fDist;
g_SecondarySpheres[3].collision = INTERSECTS;
}
else
g_SecondarySpheres[3].collision = DISJOINT;
if ( g_SecondaryOrientedBoxes[3].obox.Intersects( g_PrimaryRay.origin, g_PrimaryRay.direction, fDist ) )
{
fDistance = fDist;
g_SecondaryOrientedBoxes[3].collision = INTERSECTS;
}
else
g_SecondaryOrientedBoxes[3].collision = DISJOINT;
if ( g_SecondaryAABoxes[3].aabox.Intersects( g_PrimaryRay.origin, g_PrimaryRay.direction, fDist ) )
{
fDistance = fDist;
g_SecondaryAABoxes[3].collision = INTERSECTS;
}
else
g_SecondaryAABoxes[3].collision = DISJOINT;
if ( TriangleTests::Intersects( g_PrimaryRay.origin, g_PrimaryRay.direction,
g_SecondaryTriangles[3].pointa,
g_SecondaryTriangles[3].pointb,
g_SecondaryTriangles[3].pointc,
fDist ) )
{
fDistance = fDist;
g_SecondaryTriangles[3].collision = INTERSECTS;
}
else
g_SecondaryTriangles[3].collision = DISJOINT;
// If one of the ray intersection tests was successful, fDistance will be positive.
// If so, compute the intersection location and store it in g_RayHitResultBox.
if( fDistance > 0 )
{
// The primary ray's direction is assumed to be normalized.
XMVECTOR HitLocation = XMVectorMultiplyAdd( g_PrimaryRay.direction, XMVectorReplicate( fDistance ),
g_PrimaryRay.origin );
XMStoreFloat3( &g_RayHitResultBox.aabox.Center, HitLocation );
g_RayHitResultBox.collision = INTERSECTS;
}
else
{
g_RayHitResultBox.collision = DISJOINT;
}
}