void MeshPicking::process() { utilgl::activateAndClearTarget(outport_, ImageType::ColorDepthPicking); MeshDrawerGL drawer(meshInport_.getData().get()); shader_.activate(); shader_.setUniform("pickingColor_", picking_.getPickingObject()->getPickingColor()); const auto& ct = meshInport_.getData()->getCoordinateTransformer(camera_.get()); mat4 dataToClip = ct.getWorldToClipMatrix() * glm::translate(position_.get()) * ct.getDataToWorldMatrix(); shader_.setUniform("dataToClip", dataToClip); { utilgl::GlBoolState depthTest(GL_DEPTH_TEST, true); utilgl::CullFaceState culling(cullFace_.get()); utilgl::DepthFuncState depthfunc(GL_ALWAYS); drawer.draw(); } shader_.deactivate(); utilgl::deactivateCurrentTarget(); compositePortsToOutport(outport_, ImageType::ColorDepthPicking, imageInport_); }
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(); } }