本文整理汇总了C++中AABBox类的典型用法代码示例。如果您正苦于以下问题:C++ AABBox类的具体用法?C++ AABBox怎么用?C++ AABBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AABBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OS_SCALAR
//-----------------------------------------------------------------------------
void ZonePlugin::zoneUtility( void )
{
const osScalar drawExtent = _zoneExtent.x * OS_SCALAR( 2.0 ) - 0.005f;
if( 1 == _solid )
{
// colors for checkerboard
const Color gray(0.27f);
Color zoneGray( getZoneColor() );
zoneGray.setR( zoneGray.r() * gray.r() );
zoneGray.setG( zoneGray.g() * gray.g() );
zoneGray.setB( zoneGray.b() * gray.b() );
// draw checkerboard grid
drawXZCheckerboardGrid( drawExtent, 10, position(), zoneGray, gray);
#if 0
AABBox kZoneAABBox;
kZoneAABBox.initializeWithCenterAndExtent( position(), _zoneExtent );
kZoneAABBox.draw( getZoneColor() );
#endif
}
else
{
// alternate style
drawXZLineGrid( drawExtent, 1, position(), _ZoneColor );
}
const osScalar borderWidth = getBorderWidth();
if( borderWidth > 0 )
{
drawXZLineGrid( drawExtent + borderWidth * OS_SCALAR( 2.0 ), 1, position(), _BorderColor );
}
}
示例2: nVertex
/**
* @return True if the bounding box collides or is inside this frustum
*/
template<class T> bool Frustum<T>::collideWithAABBox(const AABBox<T> &bbox) const
{
for (auto &plane : planes)
{
const Vector3<T> &normal = plane.getNormal();
Point3<T> nVertex(bbox.getMax());
if(normal.X >= 0.0)
{
nVertex.X = bbox.getMin().X;
}
if(normal.Y >= 0.0)
{
nVertex.Y = bbox.getMin().Y;
}
if(normal.Z >= 0.0)
{
nVertex.Z = bbox.getMin().Z;
}
if (plane.distance(nVertex) > 0.0)
{
return false;
}
}
return true;
}
示例3: minPoint
/**
* Split the bounding box in several bounding boxes at limitSize.
* If original box doesn't exceed limit size, the original box is returned.
*/
std::vector<AABBox<float>> SplitBoundingBox::split(const AABBox<float> &aabbox) const
{
std::vector<float> axisSplits[3];
for(unsigned int axis=0; axis<3; ++axis)
{
float size = aabbox.getHalfSize(axis) * 2.0f;
axisSplits[axis].push_back(aabbox.getMin()[axis]);
auto nbSplits = static_cast<int>(std::ceil(size/limitSize));
float maxValue = aabbox.getMax()[axis];
for(int split = 0; split < nbSplits; ++split)
{
float splitValue = std::min(aabbox.getMin()[axis] + limitSize*(split+1), maxValue);
axisSplits[axis].push_back(splitValue);
}
}
std::vector<AABBox<float>> splittedBoundingBox;
for(unsigned int x=1; x<axisSplits[0].size(); ++x)
{
for(unsigned int y=1; y<axisSplits[1].size(); ++y)
{
for(unsigned int z=1; z<axisSplits[2].size(); ++z)
{
Point3<float> minPoint(axisSplits[0][x-1], axisSplits[1][y-1], axisSplits[2][z-1]);
Point3<float> maxPoint(axisSplits[0][x], axisSplits[1][y], axisSplits[2][z]);
splittedBoundingBox.emplace_back(AABBox<float>(minPoint, maxPoint));
}
}
}
return splittedBoundingBox;
}
示例4: areIdenticalAABBox
bool FrustumShadowData::areIdenticalAABBox(const AABBox<float> &shadowCasterReceiverBox1, const AABBox<float> &shadowCasterReceiverBox2) const
{
constexpr float SQUARE_EPSILON = 0.0001f * 0.0001f;
return shadowCasterReceiverBox1.getMin().squareDistance(shadowCasterReceiverBox2.getMin())<SQUARE_EPSILON
&& shadowCasterReceiverBox1.getMax().squareDistance(shadowCasterReceiverBox2.getMax())<SQUARE_EPSILON;
}
示例5: isVehicleInsideBorder
bool ZonePlugin::isVehicleInsideBorder( const AbstractVehicle& vehicle ) const
{
osVector3 checkZoneExtent = _zoneExtent;
checkZoneExtent.x += _borderWidth;
checkZoneExtent.z += _borderWidth;
AABBox testBox;
testBox.initializeWithCenterAndExtent( position(), checkZoneExtent );
return testBox.insideXZWithRadius(vehicle);
}
示例6: toAABBox
Vector3<float> CollisionConvexHullShape::computeLocalInertia(float mass) const
{
AABBox<float> aabbox = toAABBox(PhysicsTransform());
float width = 2.0 * aabbox.getHalfSize(0);
float height = 2.0 * aabbox.getHalfSize(1);
float depth = 2.0 * aabbox.getHalfSize(2);
float localInertia1 = (1.0/12.0) * mass * (height*height + depth*depth);
float localInertia2 = (1.0/12.0) * mass * (width*width + depth*depth);
float localInertia3 = (1.0/12.0) * mass * (width*width + height*height);
return Vector3<float>(localInertia1, localInertia2, localInertia3);
}
示例7: BoundVisible
BoundOverlap OCTree::BoundVisible(size_t index, AABBox const & aabb) const
{
BOOST_ASSERT(index < octree_.size());
octree_node_t const & node = octree_[index];
if ((node.visible != BO_No) && MathLib::intersect_aabb_aabb(node.bb, aabb))
{
if (BO_Yes == node.visible)
{
return BO_Yes;
}
else
{
BOOST_ASSERT(BO_Partial == node.visible);
if (node.first_child_index != -1)
{
float3 const center = node.bb.Center();
int mark[6];
mark[0] = aabb.Min().x() >= center.x() ? 1 : 0;
mark[1] = aabb.Min().y() >= center.y() ? 2 : 0;
mark[2] = aabb.Min().z() >= center.z() ? 4 : 0;
mark[3] = aabb.Max().x() >= center.x() ? 1 : 0;
mark[4] = aabb.Max().y() >= center.y() ? 2 : 0;
mark[5] = aabb.Max().z() >= center.z() ? 4 : 0;
for (int j = 0; j < 8; ++ j)
{
if (j == ((j & 1) ? mark[3] : mark[0])
+ ((j & 2) ? mark[4] : mark[1])
+ ((j & 4) ? mark[5] : mark[2]))
{
BoundOverlap const bo = this->BoundVisible(node.first_child_index + j, aabb);
if (bo != BO_No)
{
return bo;
}
}
}
return BO_No;
}
else
{
return BO_Partial;
}
}
}
else
{
return BO_No;
}
}
示例8: fatMargin3
void AABBNode::updateAABBox(float fatMargin)
{
if (isLeaf())
{
Point3<float> fatMargin3(fatMargin, fatMargin, fatMargin);
AABBox<float> bodyBox = bodyNodeData->retrieveBodyAABBox();
aabbox = AABBox<float>(bodyBox.getMin()-fatMargin3, bodyBox.getMax()+fatMargin3);
}else
{
aabbox = children[0]->getAABBox().merge(children[1]->getAABBox());
}
}
示例9: collisionBox
void ShapeToAABBoxTest::boxConversion()
{
CollisionBoxShape collisionBox(Vector3<float>(1.0, 2.0, 1.0)); //box 1x2x1
PhysicsTransform transform(urchin::Point3<float>(0.0, 0.0, 0.0), //move 0 unit on X, Y and Z axis
urchin::Quaternion<float>(urchin::Vector3<float>(0.0, 0.0, 1.0), 3.14159265358979/4)); //rotate 45° on Z axis
AABBox<float> box = collisionBox.toAABBox(transform);
AssertHelper::assertFloatEquals(box.getHalfSize(0), 2.12132034356);
AssertHelper::assertFloatEquals(box.getHalfSize(1), 2.12132034356);
AssertHelper::assertFloatEquals(box.getHalfSize(2), 1.0);
AssertHelper::assertPoint3FloatEquals(box.getMin(), Point3<float>(-2.12132034356, -2.12132034356, -1.0));
AssertHelper::assertPoint3FloatEquals(box.getMax(), Point3<float>(2.12132034356, 2.12132034356, 1.0));
}
示例10: inside
bool ShadowPolygon::inside (const Vector2& pos, const AABBox& bbox) const {
Vector2 corners[4];
bbox.getCorners(pos, corners);
for (int i=0; i<4; i++)
if (!inside(corners[i]))
return false;
return true;
}
示例11: boxPoints
void ShapeToAABBoxTest::convexHullConversion()
{
Point3<float> boxPointsTab[] = {
Point3<float>(-1.0, -2.0, 1.0), Point3<float>(1.0, -2.0, 1.0), Point3<float>(1.0, 2.0, 1.0), Point3<float>(-1.0, 2.0, 1.0),
Point3<float>(-1.0, -2.0, -1.0), Point3<float>(1.0, -2.0, -1.0), Point3<float>(1.0, 2.0, -1.0), Point3<float>(-1.0, 2.0, -1.0),
};
std::vector<Point3<float>> boxPoints(boxPointsTab, boxPointsTab+sizeof(boxPointsTab)/sizeof(Point3<float>));
CollisionConvexHullShape collisionConvexHull(0.0, boxPoints);
PhysicsTransform transform(urchin::Point3<float>(0.0, 0.0, 0.0), //move 0 unit on X, Y and Z axis
urchin::Quaternion<float>(urchin::Vector3<float>(0.0, 0.0, 1.0), -3.14159265358979/4)); //rotate 45° on Z axis
AABBox<float> box = collisionConvexHull.toAABBox(transform);
AssertHelper::assertFloatEquals(box.getHalfSize(0), 2.12132034356);
AssertHelper::assertFloatEquals(box.getHalfSize(1), 2.12132034356);
AssertHelper::assertFloatEquals(box.getHalfSize(2), 1.0);
AssertHelper::assertPoint3FloatEquals(box.getMin(), Point3<float>(-2.12132034356, -2.12132034356, -1.0));
AssertHelper::assertPoint3FloatEquals(box.getMax(), Point3<float>(2.12132034356, 2.12132034356, 1.0));
}
示例12: shapeWorldTransform
AABBox<float> CollisionCompoundShape::toAABBox(const PhysicsTransform &physicsTransform) const
{
Point3<float> rotatedTranslation = physicsTransform.getOrientation().rotatePoint(Point3<float>(localizedShapes[0]->translation));
Point3<float> finalPosition = physicsTransform.getPosition().translate(rotatedTranslation.toVector());
PhysicsTransform shapeWorldTransform(finalPosition, physicsTransform.getOrientation());
AABBox<float> globalCompoundBox = localizedShapes[0]->shape->toAABBox(shapeWorldTransform);
for(unsigned int i=1; i<localizedShapes.size(); ++i)
{
rotatedTranslation = physicsTransform.getOrientation().rotatePoint(Point3<float>(localizedShapes[i]->translation));
finalPosition = physicsTransform.getPosition().translate(rotatedTranslation.toVector());
shapeWorldTransform.setPosition(finalPosition);
AABBox<float> compoundBox = localizedShapes[i]->shape->toAABBox(shapeWorldTransform);
globalCompoundBox = globalCompoundBox.merge(compoundBox);
}
return globalCompoundBox;
}
示例13: _Assert
void ModelPreviewCanvas::AddjustCameraPos()
{
_Assert(mCamera != NULL);
_Assert(mModel != NULL);
AABBox bound;
mModel->CalcDynamicAABBox(IDENTITY_MATRIX, &bound);
float width = bound.GetSize().x;
float height = bound.GetSize().y;
float length = bound.GetSize().z;
float aspect = 0;
float fov = 0;
mCamera->GetCameraParams(NULL, NULL, &fov, &aspect);
float distY = (height / 2.0f) / tan(fov / 2.0f);
float distX = (height / 2.0f) / (aspect * tan(fov / 2.0f));
float dist = Max(distX, distY);
mCamera->SetWorldPosition(bound.GetCenter());
mCamera->Translate(0, 0, -dist - length);
mCamera->LookAt(bound.GetCenter());
HoverCameraController* hoverCameraController = New HoverCameraController(5.0f, 20.0f, -4*PI/9, 4*PI/9,
2.0f, 1000.0f, bound.GetCenter(), dist + length);
mCamera->SetCameraController(hoverCameraController);
}
示例14: updateShadowCasterReceiverBox
void FrustumShadowData::updateShadowCasterReceiverBox(const AABBox<float> &shadowCasterReceiverBox, bool forceUpdateAllShadowMap)
{
if(areIdenticalAABBox(shadowCasterReceiverBox, this->shadowCasterReceiverBox) && !forceUpdateAllShadowMap)
{
this->shadowCasterReceiverBoxUpdated = false;
}else
{
this->shadowCasterReceiverBox = shadowCasterReceiverBox;
this->lightProjectionMatrix = shadowCasterReceiverBox.toProjectionMatrix();
this->shadowCasterReceiverBoxUpdated = true;
}
}
示例15: boxInFrustum
int Frustum::boxInFrustum(const AABBox &bbox)
{
int result = INSIDE;
for(unsigned int i=0; i<PLANECOUNT; i++)
{
if(planes[i]->isBehind(bbox.positiveVertex(planes[i]->normal)))
{
return OUTSIDE;
}
}
return result;
}