예제 #1
0
void DrawPoints::process() {
    utilgl::activateTargetAndCopySource(outport_, inport_, ImageType::ColorOnly);
    {
        utilgl::PointSizeState pointsize(static_cast<GLfloat>(pointSize_));
        pointShader_.activate();
        pointShader_.setUniform("color", pointColor_);
        pointDrawer_.draw();
        pointShader_.deactivate();
    }
    utilgl::deactivateCurrentTarget();
    compositePortsToOutport(outport_, ImageType::ColorOnly, inport_);
}
예제 #2
0
void EntryExitPoints::process() {
    // Check if no renderer exist or if geometry changed
    if (inport_.isChanged() && inport_.hasData()) {
        drawer_ = MeshDrawerFactory::getPtr()->create(inport_.getData().get());
    }
    if (!drawer_) return;

    utilgl::DepthFuncState depthfunc(GL_ALWAYS);
    utilgl::PointSizeState pointsize(1.0f);

    shader_.activate();
    auto geom = inport_.getData();
    mat4 modelMatrix = geom->getCoordinateTransformer(camera_.get()).getDataToClipMatrix();
    shader_.setUniform("dataToClip", modelMatrix);

    {
        // generate exit points
        utilgl::activateAndClearTarget(exitPort_, ImageType::ColorDepth);
        utilgl::CullFaceState cull(GL_FRONT);
        drawer_->draw();
        utilgl::deactivateCurrentTarget();
    }

    {
        // generate entry points
        if (capNearClipping_) {
            if (!tmpEntry_ ||
                tmpEntry_->getDimensions() != entryPort_.getDimensions() ||
                tmpEntry_->getDataFormat() != entryPort_.getData()->getDataFormat()) {
                tmpEntry_.reset(
                    new Image(entryPort_.getDimensions(), entryPort_.getData()->getDataFormat()));
            }
            utilgl::activateAndClearTarget(*tmpEntry_);
        } else {
            utilgl::activateAndClearTarget(entryPort_, ImageType::ColorDepth);
        }

        utilgl::CullFaceState cull(GL_BACK);
        drawer_->draw();
        shader_.deactivate();
        utilgl::deactivateCurrentTarget();
    }

    if (capNearClipping_ && tmpEntry_) {
        // render an image plane aligned quad to cap the proxy geometry
        utilgl::activateAndClearTarget(entryPort_, ImageType::ColorDepth);
        clipping_.activate();

        TextureUnitContainer units;
        utilgl::bindAndSetUniforms(clipping_, units, *tmpEntry_, "entry", ImageType::ColorDepth);
        utilgl::bindAndSetUniforms(clipping_, units, exitPort_, ImageType::ColorDepth);

        // the rendered plane is specified in camera coordinates
        // thus we must transform from camera to world to texture coordinates
        mat4 clipToTexMat = geom->getCoordinateTransformer(camera_.get()).getClipToDataMatrix();
        clipping_.setUniform("NDCToTextureMat", clipToTexMat);
        clipping_.setUniform("nearDist", camera_.getNearPlaneDist());

        utilgl::singleDrawImagePlaneRect();
        clipping_.deactivate();
        utilgl::deactivateCurrentTarget();
    }
}