本文整理汇总了C++中AxisAlignedBox类的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBox类的具体用法?C++ AxisAlignedBox怎么用?C++ AxisAlignedBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AxisAlignedBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m_sceneMgr
Line2D::Line2D(Ogre::SceneManager &sceneMgr, const Vector2 &startPoint, const Vector2 &endPoint, const ColourValue &colour)
: m_sceneMgr(sceneMgr)
{
m_manObj = m_sceneMgr.createManualObject();
m_manObjNode = m_sceneMgr.getRootSceneNode()->createChildSceneNode();
const String materialName = "line2d_material" + StringConverter::toString(instanceId);
m_manObjMaterial = MaterialManager::getSingleton().create(materialName,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
m_manObjMaterial->setReceiveShadows(false);
m_manObjMaterial->getTechnique(0)->setLightingEnabled(true);
SetColour(colour);
m_manObj->setRenderQueueGroup(RENDER_QUEUE_OVERLAY);
m_manObj->setUseIdentityProjection(true);
m_manObj->setUseIdentityView(true);
m_manObj->setQueryFlags(0);
AxisAlignedBox box;
box.setInfinite();
m_manObj->setBoundingBox(box);
m_manObj->begin(materialName, Ogre::RenderOperation::OT_LINE_LIST);
m_manObj->position(Vector3(startPoint.x, startPoint.y, 0.0f));
m_manObj->position(Vector3(endPoint.x, endPoint.y, 0.0f));
m_manObj->end();
m_manObjNode->attachObject(m_manObj);
instanceId++;
}
示例2: calculateFrustumAABB
void Camera::calculateFrustumAABB( AxisAlignedBox& outAABB ) const
{
// calculate a bounding box around the frustum in camera's local space
AxisAlignedBox localSpaceAABB;
{
switch( m_projectionType )
{
case PT_PERSPECTIVE:
{
float y = tan( m_fov * 0.5f ) * m_farZPlane;
float x = y * m_aspectRatio;
localSpaceAABB.min.set( -x, -y, m_nearZPlane );
localSpaceAABB.max.set( x, y, m_farZPlane );
break;
}
case PT_ORTHO:
{
float x = m_nearPlaneWidth * 0.5f;
float y = m_nearPlaneHeight * 0.5f;
localSpaceAABB.min.set( -x, -y, m_nearZPlane );
localSpaceAABB.max.set( x, y, m_farZPlane );
break;
}
}
}
// transform the box to global space
const Matrix& globalMtx = getGlobalMtx();
localSpaceAABB.transform( globalMtx, outAABB );
}
示例3: 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;
}
示例4: IsVisible
//-----------------------------------------------------------------------
bool Frustum::IsVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy)
{
// Null boxes always invisible
if (bound.isNull()) return false;
// Infinite boxes always visible
if (bound.isInfinite()) return true;
// Make any pending updates to the calculated frustum planes
_UpdateFrustumPlanes();
// Get centre of the box
Vector3f centre = bound.getCenter();
// Get the half-size of the box
Vector3f halfSize = bound.getHalfSize();
// For each plane, see if all points are on the negative side
// If so, object is not visible
for (int plane = 0; plane < 6; ++plane)
{
// Skip far plane if infinite view frustum
if (plane == FRUSTUM_PLANE_FAR && m_farDist == 0)
continue;
Plane::Side side = m_frustumPlanes[plane].getSide(centre, halfSize);
if (side == Plane::NEGATIVE_SIDE)
{
// ALL corners on negative side therefore out of view
if (culledBy)
*culledBy = (FrustumPlane)plane;
return false;
}
}
return true;
}
示例5: Intersection
bool SelectionQuery::Intersection(const AxisAlignedBox& box,
const QVector3D& ray_start, const QVector3D& ray_dir, double* result) {
const QVector3D& bmin = box.Min();
const QVector3D& bmax = box.Max();
const double inv_x = 1 / ray_dir.x();
const double inv_y = 1 / ray_dir.y();
const double inv_z = 1 / ray_dir.z();
const double tx1 = (bmin.x() - ray_start.x()) * inv_x;
const double tx2 = (bmax.x() - ray_start.x()) * inv_x;
double tmin = std::min(tx1, tx2);
double tmax = std::max(tx1, tx2);
const double ty1 = (bmin.y() - ray_start.y()) * inv_y;
const double ty2 = (bmax.y() - ray_start.y()) * inv_y;
tmin = std::max(tmin, std::min(ty1, ty2));
tmax = std::min(tmax, std::max(ty1, ty2));
const double tz1 = (bmin.z() - ray_start.z()) * inv_z;
const double tz2 = (bmax.z() - ray_start.z()) * inv_z;
tmin = std::max(tmin, std::min(tz1, tz2));
tmax = std::min(tmax, std::max(tz1, tz2));
if (tmax >= tmin && tmax > 0) {
*result = std::max(0.0, std::min(tmin, tmax));
return true;
}
return false;
}
示例6: btCylinder
btoCylinder::btoCylinder(btoWorld *world, BulletOgreEngine *btoEngine, btScalar radius, btScalar height, const btTransform &transform, const btScalar density)
: btCylinder(world, radius, height, transform, density)
{
this->btoEngine = btoEngine;
// New entity
btoCylinder::mNumEntitiesInstanced++;
// Create Ogre Entity
entity = btoEngine->getOgreEngine()->getOgreSceneManager()->createEntity(
"CylinderEntity_" + StringConverter::toString(btoCylinder::mNumEntitiesInstanced),
"Barrel.mesh");
// Material
entity->setMaterialName("GeneCraft/RockWall");
entity->setCastShadows(true);
// Attach
node = btoEngine->getOgreEngine()->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode();
// Scale
AxisAlignedBox boundingB = entity->getBoundingBox(); // we need the bounding box of the box to be able to set the size of the Bullet-box
Vector3 sizeBB = boundingB.getSize();
sizeBB /= 2.0f; // only the half needed
sizeBB *= 0.95f; // Bullet margin is a bit bigger so we need a smaller size (Bullet 2.76 Physics SDK Manual page 18)
Vector3 ogreSize(radius*2,height,radius*2);
Vector3 scale = ogreSize / boundingB.getSize();
node->scale(scale); // the cube is too big for us
sizeBB *= scale; // don't forget to scale down the Bullet-box too
}
示例7: axisAlignedBoxFromString
//----------------------------------------------------------------------------
// AxisAlignedBox
AxisAlignedBox StringConv::axisAlignedBoxFromString(const String& _str, size_t _start, size_t& _readcount)
{
AxisAlignedBox aab;
size_t rdc;
_readcount = 0;
aab.setMinimum( fromString<Vector3>(_str, _start, rdc) );
if(!rdc)
{
_readcount = 0;
return AxisAlignedBox::BOX_NULL;
}
_readcount += rdc;
_start += rdc;
aab.setMaximum( fromString<Vector3>(_str, _start, rdc) );
if(!rdc)
{
_readcount = 0;
return AxisAlignedBox::BOX_NULL;
}
_readcount += rdc;
return aab;
}
示例8: cosf
void App::TerCircleInit()
{
moTerC = mSceneMgr->createManualObject();
moTerC->setDynamic(true);
moTerC->setCastShadows(false);
moTerC->estimateVertexCount(divs+2);
moTerC->estimateIndexCount(divs+2);
moTerC->begin("circle_deform", RenderOperation::OT_TRIANGLE_STRIP);
for (int d = 0; d < divs+2; ++d)
{
Real a = d/2 * aAdd; fTcos[d] = cosf(a); fTsin[d] = sinf(a);
Real r = (d % 2 == 0) ? 1.f : 0.9f;
Real x = r * fTcos[d], z = r * fTsin[d];
moTerC->position(x,0,z); //moTerC->normal(0,1,0);
moTerC->textureCoord(d/2*dTc, d%2);
}
moTerC->end();
AxisAlignedBox aab; aab.setInfinite();
moTerC->setBoundingBox(aab); // always visible
moTerC->setRenderQueueGroup(RQG_Hud2);
moTerC->setVisibilityFlags(RV_Hud);
ndTerC = mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(0,0,0));
ndTerC->attachObject(moTerC); ndTerC->setVisible(false);
}
示例9: getVisibility
OctreeCamera::Visibility OctreeCamera::getVisibility( const AxisAlignedBox &bound )
{
// Null boxes always invisible
if ( bound.isNull() )
return NONE;
// Get centre of the box
Vector3 centre = bound.getCenter();
// Get the half-size of the box
Vector3 halfSize = bound.getHalfSize();
bool all_inside = true;
for ( int plane = 0; plane < 6; ++plane )
{
// Skip far plane if infinite view frustum
if (plane == FRUSTUM_PLANE_FAR && mFarDist == 0)
continue;
// This updates frustum planes and deals with cull frustum
Plane::Side side = getFrustumPlane(plane).getSide(centre, halfSize);
if(side == Plane::NEGATIVE_SIDE) return NONE;
// We can't return now as the box could be later on the negative side of a plane.
if(side == Plane::BOTH_SIDE)
all_inside = false;
}
if ( all_inside )
return FULL;
else
return PARTIAL;
}
示例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: mat
//! Gets all triangles which lie within a specific bounding box.
void COctreeTriangleSelector::getTriangles(triangle3df* triangles,
SINT32 arraySize, SINT32& outTriangleCount,
const AxisAlignedBox& box,
const Matrix4* transform) const
{
Matrix4 mat(Matrix4::ZERO);
AxisAlignedBox invbox = box;
if (SceneNode)
{
//SceneNode->getAbsoluteTransformation().getInverse(mat);
mat = SceneNode->getAbsoluteTransformation();
mat.inverse();
//mat.transformBoxEx(invbox);
invbox.transform(mat);
}
if (transform)
mat = *transform;
else
mat = Matrix4::IDENTITY;
if (SceneNode)
//mat *= SceneNode->getAbsoluteTransformation();
mat = SceneNode->getAbsoluteTransformation() * mat;
SINT32 trianglesWritten = 0;
if (Root)
getTrianglesFromOctree(Root, trianglesWritten,
arraySize, invbox, &mat, triangles);
outTriangleCount = trianglesWritten;
}
示例12: getBoundingBox
AxisAlignedBox NavigationInputGeometry::getBoundingBox()
{
AxisAlignedBox bbox;
bbox.setMinimum( Math::floatArrayToOgreVec3( mBBoxMin ) );
bbox.setMaximum( Math::floatArrayToOgreVec3( mBBoxMax ) );
return bbox;
}
示例13: CheckWindowCollision
bool SystemWindowManager::CheckWindowCollision(bool canChangeSelection, Vector2 *outRelativePosition)
{
Vector3 origin = m_Controller->mRotationNode->convertLocalToWorldPosition(Vector3::ZERO);
Vector3 cursor = m_MosueCursor->GetPosition();
//convert to a vector 3 going into the screen
Vector3 other = cursor - origin;
Vector3 result;
Entity* entity = NULL;
float distToColl = -1.0f;
m_MosueCursor->SetVisible(false);
m_CollisionTools.raycastFromPoint(origin, other, result, entity, distToColl);
m_MosueCursor->SetVisible(true);
if(entity)
{
AxisAlignedBox bounds = entity->getBoundingBox();
SceneNode *node = entity->getParentSceneNode();
Vector3 nodePosition = node->getPosition();
Vector3 nodeWorldPosition = node->convertLocalToWorldPosition(Vector3::ZERO);
Vector3 position = node->convertWorldToLocalPosition(result);
double relx, rely = 0;
Vector3 topLeft = bounds.getCorner(AxisAlignedBox::FAR_LEFT_TOP);
Vector3 bottomRight = bounds.getCorner(AxisAlignedBox::FAR_RIGHT_BOTTOM);
relx = (position.x - topLeft.x) / (bottomRight.x - topLeft.x);
rely = (position.y - topLeft.y) / (bottomRight.y - topLeft.y);
if(m_SelectedWindow->GetMaterialName() == entity->getName())
{
//todo figure out the mouse coordiantes
m_SelectedWindow->CheckActiveWindow(relx, rely);
*outRelativePosition = Vector2(relx, rely);
return true;
}
else if(canChangeSelection)
{
for (std::vector<SystemWindow*>::iterator it = m_Windows.begin(); it != m_Windows.end(); ++it)
{
if((*it)->GetMaterialName() == entity->getName())
{
//todo deactivate the old window here
m_SelectedWindow = (*it);
m_SelectedWindow->CheckActiveWindow(relx, rely);
*outRelativePosition = Vector2(relx, rely);
return true;
}
}
}
return false;
}
else if(canChangeSelection)
{
RemoveHighlightedThumbnail();
}
return false;
}
示例14: AxisAlignedBox
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();
}
示例15: _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;
}