Ejemplo n.º 1
0
void BoundingBoxf::expandBy(const BoundingBoxf& bbox)
{
    if(!bbox.empty()){
        if(bbox.min().x() < min_.x()){
            min_.x() = bbox.min().x();
        }
        if(bbox.max().x() > max_.x()){
            max_.x() = bbox.max().x();
        }
        if(bbox.min().y() < min_.y()){
            min_.y() = bbox.min().y();
        }
        if(bbox.max().y() > max_.y()){
            max_.y() = bbox.max().y();
        }
        if(bbox.min().z() < min_.z()){
            min_.z() = bbox.min().z();
        }
        if(bbox.max().z() > max_.z()){
            max_.z() = bbox.max().z();
        }
        if(empty_){
            empty_ = (min_.x() >= max_.x()) && (min_.y() >= max_.y()) && (min_.z() >= max_.z());
        }
    }
}
Ejemplo n.º 2
0
void SceneGraphViewImpl::renderMarker(GLSceneRenderer& renderer)
{
    SgNode* node = 0;
    SgTransform* trans = 0;
    SgMeshBase* mesh = 0;

    if(selectedSgvItem->markerNode){
        node = selectedSgvItem->markerNode;
    }else if(dynamic_cast<SgScaleTransform*>(selectedSgvItem->node) ||
             dynamic_cast<SgPosTransform*>(selectedSgvItem->node)){
        trans = dynamic_cast<SgTransform*>(selectedSgvItem->node);
    }else{
        mesh = dynamic_cast<SgMeshBase*>(selectedSgvItem->node);
        if(!mesh)
            node = dynamic_cast<SgNode*>(selectedSgvItem->node);
    }

    BoundingBoxf bb;
    if(trans)
        bb = trans->untransformedBoundingBox();
    else if(mesh){
        bb = mesh->boundingBox();
    }else if(node){
        bb = node->boundingBox();
    }else
        return;
    if(bb.empty())
        return;

    glPushAttrib(GL_LIGHTING_BIT | GL_CURRENT_BIT);
    glDisable(GL_LIGHTING);

    glColor3f(1.0f, 0.0f, 1.0f);

    glBegin(GL_LINES);

    const Vector3f& min = bb.min();
    const Vector3f& max = bb.max();

    float y[2];
    y[0] = min.y();
    y[1] = max.y();
            
    for(int i=0; i < 2; ++i){
        glVertex3f(min.x(), y[i], min.z());
        glVertex3f(min.x(), y[i], max.z());
        glVertex3f(min.x(), y[i], max.z());
        glVertex3f(max.x(), y[i], max.z());

        glVertex3f(max.x(), y[i], max.z());
        glVertex3f(max.x(), y[i], min.z());
        glVertex3f(max.x(), y[i], min.z());
        glVertex3f(min.x(), y[i], min.z());
    }

    float z[2];
    z[0] = min.z();
    z[1] = max.z();
    for(int i=0; i < 2; ++i){
        glVertex3f(min.x(), min.y(), z[i]);
        glVertex3f(min.x(), max.y(), z[i]);
        glVertex3f(max.x(), min.y(), z[i]);
        glVertex3f(max.x(), max.y(), z[i]);
    }

    glEnd();
    glPopAttrib();
}
Ejemplo n.º 3
0
BoundingBox::BoundingBox(const BoundingBoxf& org)
{
    min_ = org.min().cast<Vector3::Scalar>();
    max_ = org.max().cast<Vector3::Scalar>();
    empty_ = org.empty();
}