本文整理汇总了C++中AxisAlignedBoundingBox类的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBoundingBox类的具体用法?C++ AxisAlignedBoundingBox怎么用?C++ AxisAlignedBoundingBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AxisAlignedBoundingBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rescaleScene
// Workaround to avoid invisible objects due to wrong clipping planes
// all scenes are scaled to a radius of 5
void AbstractNavigation::rescaleScene( Group * scene )
{
AxisAlignedBoundingBox bb = scene->boundingBox();
glm::mat4 scale_matrix = glm::scale(glm::vec3(5.0f / bb.radius()));
m_sceneTransform = scale_matrix * scene->transform();
scene->setTransform(m_sceneTransform);
}
示例2:
void
AxisAlignedBoundingBox< T >::merge( const AxisAlignedBoundingBox< T >& aabb )
{
if ( aabb._empty )
return; // nothing to do
if ( _empty )
{
// copy non-empty aabb
_min = aabb._min;
_max = aabb._max;
_empty = _dirty = false;
return;
}
// else merge the two aabbs
const vector< 3, T >& min = aabb.getMin();
const vector< 3, T >& max = aabb.getMax();
if ( min.x() < _min.x() )
_min.x() = min.x();
if ( min.y() < _min.y() )
_min.y() = min.y();
if ( min.z() < _min.z() )
_min.z() = min.z();
if ( max.x() > _max.x() )
_max.x() = max.x();
if ( max.y() > _max.y() )
_max.y() = max.y();
if ( max.z() > _max.z() )
_max.z() = max.z();
}
示例3: cost
//------------------------------------------------------------------------
float KdTreeNode::cost(const AxisAlignedBoundingBox& aabb, unsigned int lowerCount, unsigned int greaterCount, float distance, Vector3::AXIS direction) const
{
float lowerSurfaceArea = aabb.getLowerSubAABB(distance, direction).getSurfaceArea();
float greaterSurfaceArea = aabb.getGreaterSubAABB(distance, direction).getSurfaceArea();
return 2.f + 10.f * (lowerSurfaceArea * lowerCount + greaterSurfaceArea * greaterCount);
}
示例4: AxisAlignedBoundingBox
const AxisAlignedBoundingBox PolygonalDrawable::boundingBox(glm::mat4 transform) const
{
AxisAlignedBoundingBox aabb = AxisAlignedBoundingBox();
glm::mat4 newTransform;
if( m_geometry == nullptr ) {
return aabb;
}
if (m_rf == RF_Absolute) {
newTransform = transform;
} else {
newTransform = this->transform() * transform;
}
t_VertexListP myVList = m_geometry->vertices();
myVList->foreachVertexAttribute<glm::vec3>(0, myVList->size(), "position", nullptr,
[&aabb, &newTransform](int i, const glm::vec3 & pos)
{
aabb.extend( glm::vec3(newTransform * glm::vec4(pos, 1.0f)) );
}
);
return aabb;
}
示例5: encloses
bool BoundingSphere::encloses(const AxisAlignedBoundingBox& axisAlignedBox) const
{
float halfDiagonal = glusMathLengthf(axisAlignedBox.getHalfWidth(), axisAlignedBox.getHalfHeight(), axisAlignedBox.getHalfDepth());
float distance = center.distance(axisAlignedBox.getCenter());
return distance + halfDiagonal <= radius;
}
示例6: sceneChanged
// gets called at every program start and when a new file is opened in the viewer
void AbstractNavigation::sceneChanged(Group * scene)
{
AxisAlignedBoundingBox bb = scene->boundingBox();
m_BBRadius = bb.radius();
m_frontView = glm::lookAt(bb.center() + glm::vec3(0.f, 0.f, bb.radius()*2.5), bb.center(), glm::vec3(0.f, 1.f, 0.f));
setFromMatrix(topRightView());
updateCamera();
}
示例7: TEST
TEST(AxisAlignedBoundingBox, setExtents)
{
Vector3 min(-1, -1, -1);
Vector3 max(1, 1, 1);
AxisAlignedBoundingBox aabb;
aabb.setExtents(min, max);
ASSERT_EQ(min, aabb.getMinimum());
ASSERT_EQ(max, aabb.getMaximum());
}
示例8: sceneChanged
void LightSourcePass::sceneChanged(Group * scene)
{
if(m_scene)
m_lightcam->remove(m_scene);
m_lightcam->append(scene);
AxisAlignedBoundingBox bb = scene->boundingBox();
m_lightcam->setView(glm::lookAt(glm::vec3(4.0f, 5.5f, 6.0f) + bb.center(),
bb.center(), glm::vec3(0.0f,1.0f,0.0f)));
m_scene = scene;
}
示例9: plane_aabb
IntersectionTest::Result IntersectionTest::plane_aabb(const Vec4f &plane, const AxisAlignedBoundingBox &aabb)
{
Vec3f center = aabb.center();
Vec3f extents = aabb.extents();
float e = extents.x * std::abs(plane.x) + extents.y * std::abs(plane.y) + extents.z * std::abs(plane.z);
float s = center.x * plane.x + center.y * plane.y + center.z * plane.z + plane.w;
if (s - e > 0)
return inside;
else if (s + e < 0)
return outside;
else
return intersecting;
}
示例10: updatePos
void PlayableEmotion::updatePos(Vec2 center) {
centerPos = center;
//update axis aligned bouding box
AxisAlignedBoundingBox *box = (AxisAlignedBoundingBox *) collisionVolume;
box->setLeftTopCorner(centerPos + center_LT_displacement);
//update auxliar collision circles
const Vec2 &aux = Vec2::getVec2FromPolar(box->axisAlignedRectangle.h / 4, (float) M_PI_2);
auxCollisionVolume[0].setCenter(centerPos + aux);
auxCollisionVolume[1].setCenter(centerPos);
auxCollisionVolume[2].setCenter(centerPos + aux * (-1.0));
}
示例11: updateLocalBoundingBox
void SimObject::expandAxisAlignedBoundingBox(AxisAlignedBoundingBox& box)
{
updateLocalBoundingBox();
ObjectList::iterator pos;
for(pos = childNodes.begin(); pos != childNodes.end(); ++pos)
{
(*pos)->expandAxisAlignedBoundingBox(boundingBox);
}
box.expand(boundingBox);
}
示例12: AxisAlignedBoundingBox
const AxisAlignedBoundingBox TriangleObject::boundingBox(glm::mat4 transform) const
{
AxisAlignedBoundingBox aabb = AxisAlignedBoundingBox();
glm::mat4 newTransform;
if ( m_triangles->size() == 0 )
return aabb;
if (m_rf == RF_Absolute) {
newTransform = transform;
} else {
newTransform = this->transform() * transform;
}
for ( auto vertex : *m_triangles ) {
glm::vec4 transformedVertex = newTransform * glm::vec4(vertex, 1.0f);
aabb.extend( transformedVertex.xyz * (1.0f / transformedVertex.w) );
}
return aabb;
}
示例13: ray_aabb
IntersectionTest::OverlapResult IntersectionTest::ray_aabb(const Vec3f &ray_start, const Vec3f &ray_end, const AxisAlignedBoundingBox &aabb)
{
Vec3f c = (ray_start + ray_end) * 0.5f;
Vec3f w = ray_end - c;
Vec3f h = aabb.extents();
c -= aabb.center();
Vec3f v(std::abs(w.x), std::abs(w.y), std::abs(w.z));
if (std::abs(c.x) > v.x + h.x || std::abs(c.y) > v.y + h.y || std::abs(c.z) > v.z + h.z)
return disjoint;
if (std::abs(c.y * w.z - c.z * w.y) > h.y * v.z + h.z * v.y ||
std::abs(c.x * w.z - c.z * w.x) > h.x * v.z + h.z * v.x ||
std::abs(c.x * w.y - c.y * w.x) > h.x * v.y + h.y * v.x)
return disjoint;
return overlap;
}
示例14: retrieveAxisAlignedBoundingBox
AxisAlignedBoundingBox AssimpScene::retrieveAxisAlignedBoundingBox(const aiScene * scene)
{
AxisAlignedBoundingBox aabb;
for (unsigned int m = 0; m < scene->mNumMeshes; ++m)
{
aiMesh * mesh = scene->mMeshes[m];
for (unsigned int v = 0; v < mesh->mNumVertices; ++v)
{
const QVector3D vec3(
mesh->mVertices[v].x
, mesh->mVertices[v].y
, mesh->mVertices[v].z);
aabb.extend(vec3);
}
}
return aabb;
}
示例15: addToGeometry
void PathTracingBVH::addToGeometry(Node *node) {
AxisAlignedBoundingBox aabb = node->boundingBox();
int aabbIndex = m_geometry->size();
m_geometry->push_back(glm::vec4()); //llf dummy
m_geometry->push_back(glm::vec4()); //urb dummy
//add triangles
for (auto child : node->children()) {
if (child->children().size() == 0) { //the current child is a leaf ==> it is a triangle object
TriangleObject *triangleObject = dynamic_cast<TriangleObject *>(child);
if (triangleObject == nullptr) { //we have to be safe because it could also be an empty Group
qDebug() << "PathTracingBVH : addToGeometry(Node *) : dynamic cast to TriangleObject * failed";
continue;
}
p_TriangleList triangles = triangleObject->triangles();
for (int i = 2; i < triangles->size(); i += 3) {
m_geometry->push_back(glm::vec4(triangles->at(i - 2), 3.0f)); // data1
m_geometry->push_back(glm::vec4(triangles->at(i - 1), 0.0f)); // data2
m_geometry->push_back(glm::vec4(triangles->at(i ), 0.0f)); // data3
}
} else { //internal node
addToGeometry(child);
}
}
glm::vec3 aabbEnlargement = aabb.radius() * glm::vec3(0.000001f, 0.000001f, 0.000001f);
m_geometry->at(aabbIndex) = glm::vec4(
aabb.llf() - aabbEnlargement, //llf
0.0f //we are a bounding box
); //data1
m_geometry->at(aabbIndex + 1) = glm::vec4(
aabb.urb() + aabbEnlargement, //urb
float(m_geometry->size()) // points to one behind the last entry in geometry list,
// that is the next object on the same hierarchy level (or a higher hierarchy level
// if there is none on the same)
); //data2
}