本文整理汇总了C++中AxisAlignedBox::getMaximum方法的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBox::getMaximum方法的具体用法?C++ AxisAlignedBox::getMaximum怎么用?C++ AxisAlignedBox::getMaximum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AxisAlignedBox
的用法示例。
在下文中一共展示了AxisAlignedBox::getMaximum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//------------------------------------------------------------------------------
void SegmentedDynamicLightManager::LightData::setBounds(const AxisAlignedBox& i_Bounds)
{
mMinX = i_Bounds.getMinimum().x;
mMaxX = i_Bounds.getMaximum().x;
mMinZ = i_Bounds.getMinimum().z;
mMaxZ = i_Bounds.getMaximum().z;
}
示例2: if
//-------------------------------------------------------------------------
TerrainTile * OverhangTerrainPage::getTerrainTile( const Vector3 & pt )
{
/* Since we don't know if the terrain is square, or has holes, we use a line trace
to find the containing tile...
*/
TerrainTile * tile = tiles[ 0 ][ 0 ];
while ( tile != 0 )
{
AxisAlignedBox b = tile -> getBoundingBox();
if ( pt.x < b.getMinimum().x )
tile = tile -> _getNeighbor( TerrainTile::WEST );
else if ( pt.x > b.getMaximum().x )
tile = tile -> _getNeighbor( TerrainTile::EAST );
else if ( pt.z < b.getMinimum().z )
tile = tile -> _getNeighbor( TerrainTile::NORTH );
else if ( pt.z > b.getMaximum().z )
tile = tile -> _getNeighbor( TerrainTile::SOUTH );
else
return tile;
}
return 0;
}
示例3: _isTwiceSize
/** Returns true is the box will fit in a child.
*/
bool Octree::_isTwiceSize( const AxisAlignedBox &box ) const
{
return ( ( box.getMaximum().x - box.getMinimum().x ) <= ( mBox.getMaximum().x - mBox.getMinimum().x ) / 2 ) &&
( ( box.getMaximum().y - box.getMinimum().y ) <= ( mBox.getMaximum().y - mBox.getMinimum().y ) / 2 ) &&
( ( box.getMaximum().z - box.getMinimum().z ) <= ( mBox.getMaximum().z - mBox.getMinimum().z ) / 2 ) ;
}
示例4: isBoundOkForMcGuire
// ------------------------------------------------------------------------
static bool isBoundOkForMcGuire(const AxisAlignedBox& lightCapBounds, const Ogre::Vector3& lightPosition)
{
// If light position is inside light cap bound then extrusion could be in opposite directions
// and McGuire cap could intersect near clip plane of camera frustum without being noticed
if(lightCapBounds.contains(lightPosition))
return false;
// If angular size of object is too high then extrusion could be in almost opposite directions,
// interpolated points would be extruded by shorter distance, and strange geometry of McGuire cap
// could be visible even for well tesselated meshes. As a heuristic we will avoid McGuire cap if
// angular size is larger than 60 degrees - it guarantees that interpolated points would be
// extruded by at least cos(60deg/2) ~ 86% of the original extrusion distance.
if(lightCapBounds.getHalfSize().length() / (lightCapBounds.getCenter() - lightPosition).length() > 0.5) // if boundingSphereAngularSize > 60deg
{
// Calculate angular size one more time using edge corners angular distance comparision,
// Determine lit sides of the bound, store in mask
enum { L = 1, R = 2, B = 4, T = 8, F = 16, N = 32 }; // left, right, bottom, top, far, near
unsigned lightSidesMask =
(lightPosition.x < lightCapBounds.getMinimum().x ? L : 0) | // left
(lightPosition.x > lightCapBounds.getMaximum().x ? R : 0) | // right
(lightPosition.y < lightCapBounds.getMinimum().y ? B : 0) | // bottom
(lightPosition.y > lightCapBounds.getMaximum().y ? T : 0) | // top
(lightPosition.z < lightCapBounds.getMinimum().z ? F : 0) | // far
(lightPosition.z > lightCapBounds.getMaximum().z ? N : 0); // near
// find corners on lit/unlit edge (should not be more than 6 simultaneously, but better be safe than sorry)
Ogre::Vector3 edgeCorners[8];
unsigned edgeCornersCount = 0;
std::pair<unsigned, AxisAlignedBox::CornerEnum> cornerMap[8] = {
{ F|L|B, AxisAlignedBox::FAR_LEFT_BOTTOM }, { F|R|B, AxisAlignedBox::FAR_RIGHT_BOTTOM },
{ F|L|T, AxisAlignedBox::FAR_LEFT_TOP }, { F|R|T, AxisAlignedBox::FAR_RIGHT_TOP },
{ N|L|B, AxisAlignedBox::NEAR_LEFT_BOTTOM },{ N|R|B, AxisAlignedBox::NEAR_RIGHT_BOTTOM },
{ N|L|T, AxisAlignedBox::NEAR_LEFT_TOP }, { N|R|T, AxisAlignedBox::NEAR_RIGHT_TOP }};
for(auto& c : cornerMap)
if((lightSidesMask & c.first) != 0 && (lightSidesMask & c.first) != c.first) // if adjacent sides not all lit or all unlit
edgeCorners[edgeCornersCount++] = lightCapBounds.getCorner(c.second);
// find max angular size in range [0..pi] by finding min cos of angular size, range [1..-1]
Real cosAngle = 1.0;
for(unsigned i0 = 0; i0 + 1 < edgeCornersCount; ++i0)
for(unsigned i1 = i0 + 1; i1 < edgeCornersCount; ++i1)
{
// 4~6 edge corners, 6~15 angular distance calculations
Vector3 a = (edgeCorners[i0] - lightPosition).normalisedCopy();
Vector3 b = (edgeCorners[i1] - lightPosition).normalisedCopy();
Real cosAB = a.dotProduct(b);
if(cosAngle > cosAB)
cosAngle = cosAB;
}
if(cosAngle < 0.5) // angularSize > 60 degrees
return false;
}
return true;
}
示例5: _isIn
/** Since we are loose, only check the center.
*/
bool OctreeNode::_isIn( AxisAlignedBox &box )
{
// Always fail if not in the scene graph or box is null
if (!mIsInSceneGraph || box.isNull()) return false;
// Always succeed if AABB is infinite
if (box.isInfinite())
return true;
Vector3 center = mWorldAABB.getMaximum().midPoint( mWorldAABB.getMinimum() );
Vector3 bmin = box.getMinimum();
Vector3 bmax = box.getMaximum();
bool centre = ( bmax > center && bmin < center );
if (!centre)
return false;
// Even if covering the centre line, need to make sure this BB is not large
// enough to require being moved up into parent. When added, bboxes would
// end up in parent due to cascade but when updating need to deal with
// bbox growing too large for this child
Vector3 octreeSize = bmax - bmin;
Vector3 nodeSize = mWorldAABB.getMaximum() - mWorldAABB.getMinimum();
return nodeSize < octreeSize;
}
示例6: _getChildIndexes
/** It's assumed the the given box has already been proven to fit into
* a child. Since it's a loose octree, only the centers need to be
* compared to find the appropriate node.
*/
void Octree::_getChildIndexes( const AxisAlignedBox &box, int *x, int *y, int *z ) const
{
Vector3 max = mBox.getMaximum();
Vector3 min = box.getMinimum();
Vector3 center = mBox.getMaximum().midPoint( mBox.getMinimum() );
Vector3 ncenter = box.getMaximum().midPoint( box.getMinimum() );
if ( ncenter.x > center.x )
* x = 1;
else
*x = 0;
if ( ncenter.y > center.y )
* y = 1;
else
*y = 0;
if ( ncenter.z > center.z )
* z = 1;
else
*z = 0;
}
示例7: intersects
//-----------------------------------------------------------------------
bool Math::intersects(const Sphere& sphere, const AxisAlignedBox& box)
{
if (box.isNull()) return false;
if (box.isInfinite()) return true;
// Use splitting planes
const Vector3& center = sphere.getCenter();
Real radius = sphere.getRadius();
const Vector3& min = box.getMinimum();
const Vector3& max = box.getMaximum();
// Arvo's algorithm
Real s, d = 0;
for (int i = 0; i < 3; ++i)
{
if (center.ptr()[i] < min.ptr()[i])
{
s = center.ptr()[i] - min.ptr()[i];
d += s * s;
}
else if(center.ptr()[i] > max.ptr()[i])
{
s = center.ptr()[i] - max.ptr()[i];
d += s * s;
}
}
return d <= radius * radius;
}
示例8: intersection
ParaEngine::AxisAlignedBox AxisAlignedBox::intersection(const AxisAlignedBox& b2) const
{
if (this->isNull() || b2.isNull())
{
return AxisAlignedBox();
}
else if (this->isInfinite())
{
return b2;
}
else if (b2.isInfinite())
{
return *this;
}
Vector3 intMin = mMinimum;
Vector3 intMax = mMaximum;
intMin.makeCeil(b2.getMinimum());
intMax.makeFloor(b2.getMaximum());
// Check intersection isn't null
if (intMin.x < intMax.x &&
intMin.y < intMax.y &&
intMin.z < intMax.z)
{
return AxisAlignedBox(intMin, intMax);
}
return AxisAlignedBox();
}
示例9:
/* Find the best (smallest) zone that contains a point
*/
PCZone * PCZSceneManager::findZoneForPoint(Vector3 & point)
{
PCZone * zone;
PCZone * bestZone = mDefaultZone;
Real bestVolume = Ogre::Math::POS_INFINITY;
ZoneMap::iterator zit = mZones.begin();
while ( zit != mZones.end() )
{
zone = zit->second;
AxisAlignedBox aabb;
zone->getAABB(aabb);
SceneNode * enclosureNode = zone->getEnclosureNode();
if (enclosureNode != 0)
{
// since this is the "local" AABB, add in world translation of the enclosure node
aabb.setMinimum(aabb.getMinimum() + enclosureNode->_getDerivedPosition());
aabb.setMaximum(aabb.getMaximum() + enclosureNode->_getDerivedPosition());
}
if (aabb.contains(point))
{
if (aabb.volume() < bestVolume)
{
// this zone is "smaller" than the current best zone, so make it
// the new best zone
bestZone = zone;
bestVolume = aabb.volume();
}
}
// proceed to next zone in the list
++zit;
}
return bestZone;
}
示例10: resize
void OctreeSceneManager::resize( const AxisAlignedBox &box )
{
list< SceneNode * >::type nodes;
list< SceneNode * >::type ::iterator it;
_findNodes( mOctree->mBox, nodes, 0, true, mOctree );
OGRE_DELETE mOctree;
mOctree = OGRE_NEW Octree( 0 );
mOctree->mBox = box;
const Vector3 &min = box.getMinimum();
const Vector3 &max = box.getMaximum();
mOctree->mHalfSize = ( max - min ) * 0.5f;
it = nodes.begin();
while ( it != nodes.end() )
{
OctreeNode * on = static_cast < OctreeNode * > ( *it );
on -> setOctant( 0 );
_updateOctreeNode( on );
++it;
}
}
示例11: fromJSAxisAlignedBox
TEST_FIXTURE(ScriptingTestEnvironment, ConvertFiniteAxisAlignedBoxFromJavaScript)
{
HandleScope handle_scope;
Handle<Value> result = pScriptingManager->execute("import_module('Athena.Math'); new Athena.Math.AxisAlignedBox(1, 2, 3, 4, 5, 6);");
AxisAlignedBox aab = fromJSAxisAlignedBox(result);
CHECK(aab.isFinite());
CHECK_CLOSE(1.0f, aab.getMinimum().x, 1e-6f);
CHECK_CLOSE(2.0f, aab.getMinimum().y, 1e-6f);
CHECK_CLOSE(3.0f, aab.getMinimum().z, 1e-6f);
CHECK_CLOSE(4.0f, aab.getMaximum().x, 1e-6f);
CHECK_CLOSE(5.0f, aab.getMaximum().y, 1e-6f);
CHECK_CLOSE(6.0f, aab.getMaximum().z, 1e-6f);
}
示例12: setHighlighted
void Actor::setHighlighted(bool highlight)
{
if (highlight != mHighlighted)
{
//getControlledObject()->setHighlighted(highlight);
mHighlighted = highlight;
}
if (mHighlighted && mDescription == NULL)
{
if (mSceneNode != NULL)
{
mDescription = new MovableText(mName + "_desc", mName);
mDescription->showOnTop(true);
mDescription->setAlignment(MovableText::ALIGN_CENTER);
if (mActorControlledObject && mActorControlledObject->isMeshObject())
{
MeshObject* mo = static_cast<MeshObject*>(mActorControlledObject);
AxisAlignedBox aabb = mo->getDefaultSize();
mDescription->setPositionOffset(Vector3(0, aabb.getMaximum().y * 1.1, 0));
}
mSceneNode->attachObject(mDescription);
}
}
else if (mDescription)
{
mDescription->setVisible(highlight);
}
}
示例13: intersect
/** Checks how the box intersects with the sphere.
*/
Intersection intersect( const Sphere &one, const AxisAlignedBox &two )
{
OctreeSceneManager::intersect_call++;
// Null box?
if (two.isNull()) return OUTSIDE;
if (two.isInfinite()) return INTERSECT;
float sradius = one.getRadius();
sradius *= sradius;
Vector3 scenter = one.getCenter();
const Vector3& twoMin = two.getMinimum();
const Vector3& twoMax = two.getMaximum();
float s, d = 0;
Vector3 mndistance = ( twoMin - scenter );
Vector3 mxdistance = ( twoMax - scenter );
if ( mndistance.squaredLength() < sradius &&
mxdistance.squaredLength() < sradius )
{
return INSIDE;
}
//find the square of the distance
//from the sphere to the box
for ( int i = 0 ; i < 3 ; i++ )
{
if ( scenter[ i ] < twoMin[ i ] )
{
s = scenter[ i ] - twoMin[ i ];
d += s * s;
}
else if ( scenter[ i ] > twoMax[ i ] )
{
s = scenter[ i ] - twoMax[ i ];
d += s * s;
}
}
bool partial = ( d <= sradius );
if ( !partial )
{
return OUTSIDE;
}
else
{
return INTERSECT;
}
}
示例14: axisAlignedBoxToString
String StringConv::axisAlignedBoxToString(const AxisAlignedBox& _val, size_t _precision)
{
String r;
r += toString(_val.getMinimum(), _precision);
r += " ";
r += toString(_val.getMaximum(), _precision);
return r;
}
示例15: extrudeBounds
// ------------------------------------------------------------------------
void ShadowCaster::extrudeBounds(AxisAlignedBox& box, const Vector4& light, Real extrudeDist) const
{
Vector3 extrusionDir;
if (light.w == 0)
{
// Parallel projection guarantees min/max relationship remains the same
extrusionDir.x = -light.x;
extrusionDir.y = -light.y;
extrusionDir.z = -light.z;
extrusionDir.normalise();
extrusionDir *= extrudeDist;
box.setExtents(box.getMinimum() + extrusionDir,
box.getMaximum() + extrusionDir);
}
else
{
Vector3 vmin, vmax;
Vector3 corner, tmp;
#define __EXTRUDE_POINT() \
{ \
extrusionDir.x = corner.x - light.x; \
extrusionDir.y = corner.y - light.y; \
extrusionDir.z = corner.z - light.z; \
extrusionDir.normalise(); \
extrusionDir *= extrudeDist; \
tmp = corner + extrusionDir; \
}
corner = box.getMinimum(); __EXTRUDE_POINT(); vmin = vmax = tmp;
corner.x = box.getMaximum().x; __EXTRUDE_POINT(); vmin.makeFloor(tmp); vmax.makeCeil(tmp);
corner.y = box.getMaximum().y; __EXTRUDE_POINT(); vmin.makeFloor(tmp); vmax.makeCeil(tmp);
corner.x = box.getMinimum().x; __EXTRUDE_POINT(); vmin.makeFloor(tmp); vmax.makeCeil(tmp);
corner.z = box.getMaximum().z; __EXTRUDE_POINT(); vmin.makeFloor(tmp); vmax.makeCeil(tmp);
corner.x = box.getMaximum().x; __EXTRUDE_POINT(); vmin.makeFloor(tmp); vmax.makeCeil(tmp);
corner.y = box.getMinimum().y; __EXTRUDE_POINT(); vmin.makeFloor(tmp); vmax.makeCeil(tmp);
corner.x = box.getMinimum().x; __EXTRUDE_POINT(); vmin.makeFloor(tmp); vmax.makeCeil(tmp);
#undef __EXTRUDE_POINT
box.setExtents(vmin, vmax);
}
}