예제 #1
0
void CURRENT_CLASS::apply(osg::Geode &geode)
{
    // Contained drawables will only be individually considered if we are
    // allowed to continue traversing.
    if(shouldContinueTraversal(geode))
    {
        osg::Drawable *drawable;
        double zNear, zFar;

        // Handle each drawable in this geode
        for(unsigned int i = 0; i < geode.getNumDrawables(); ++i)
        {
            drawable = geode.getDrawable(i);

            const osg::BoundingBox &bb = drawable->getBound();
            if(bb.valid())
            {
                bool containsTest = _localFrusta.back().contains(bb);
                // Make sure drawable will be visible in the scene
                if(!containsTest)
                    continue;

                // Compute near/far distances for current drawable
                zNear = distanceDA(bb.corner(_bbCorners.back().first),
                        _viewMatrices.back());
                zFar = distanceDA(bb.corner(_bbCorners.back().second),
                        _viewMatrices.back());
                if(zNear > zFar)
                    std::swap(zNear,zFar);
                pushDistancePair(zNear,zFar);
            }
        }
    }
}
예제 #2
0
void CURRENT_CLASS::apply(osg::Transform &transform)
{
    if(shouldContinueTraversal(transform))
    {
        // Compute transform for current node
        osg::Matrix currMatrix = _viewMatrices.back();
        bool pushMatrix = transform.computeLocalToWorldMatrix(currMatrix,this);

        if(pushMatrix)
        {
            // Store the new modelview matrix and view frustum
            _viewMatrices.push_back(currMatrix);
            pushLocalFrustum();
        }

        ++_currentDepth;
        traverse(transform);
        --_currentDepth;

        if(pushMatrix)
        {
            // Restore the old modelview matrix and view frustum
            _localFrusta.pop_back();
            _bbCorners.pop_back();
            _viewMatrices.pop_back();
        }
    }
}
예제 #3
0
void CURRENT_CLASS::apply(osg::Node &node)
{
    if(shouldContinueTraversal(node))
    {
        // Traverse this node
        ++_currentDepth;
        traverse(node);
        --_currentDepth;
    }
}
void DistanceAccumulator::apply(osg::Node &node)
{
    if(shouldContinueTraversal(node))
    {
      // Traverse this node
      ++_currentDepth;
      traverse(node);
      --_currentDepth;
    }
}
예제 #5
0
void CURRENT_CLASS::apply(osg::Projection &proj)
{
    if(shouldContinueTraversal(proj))
    {
        // Push the new projection matrix view frustum
        _projectionMatrices.push_back(proj.getMatrix());
        pushLocalFrustum();

        // Traverse the group
        ++_currentDepth;
        traverse(proj);
        --_currentDepth;

        // Reload original matrix and frustum
        _localFrusta.pop_back();
        _bbCorners.pop_back();
        _projectionMatrices.pop_back();
    }
}