void CubeProxyGeometry::defineBoxBrickingRegion() { vec3 llfPlane = vec3(clipLeftX_.get(), clipFrontY_.get(), clipBottomZ_.get() ); vec3 urbPlane = vec3(clipRightX_.get(), clipBackY_.get(), clipTopZ_.get() ); vec3 geomLlf = -(volumeSize_ / 2.f) + volumeCenter_; vec3 geomUrb = (volumeSize_ / 2.f) + volumeCenter_; llfPlane = llfPlane / 100.f; urbPlane = urbPlane / 100.f; llfPlane = geomLlf + (volumeSize_ * llfPlane); urbPlane = geomUrb - (volumeSize_ * urbPlane); if (currentVolumeHandle_) { LargeVolumeManager* lvm = currentVolumeHandle_->getLargeVolumeManager(); if (lvm) { lvm->addBoxBrickingRegion(brickSelectionPriority_.get(), llfPlane, urbPlane); } } }
void CameraWidget::resetCameraPosition() { // all trackball operations assume an initial view along the negative z-axis with the // y-axis as up vector cameraProp_->set(tgt::Camera(vec3(0.f, 0.f, 1.f), vec3(0.f, 0.f, 0.f), vec3(0.f, 1.f, 0.f))); cameraPosition_->set(cameraProp_->get().getPosition()); }
void setUniform(tgt::Shader* shader, const std::string& volumeUniform, const std::string& structUniform, const VolumeBase* vh, const tgt::TextureUnit* texUnit, const tgt::Camera* camera, const tgt::vec4& lightPosition) { if(texUnit) shader->setUniform(volumeUniform, texUnit->getUnitNumber()); // volume size, i.e. dimensions of the proxy geometry in world coordinates shader->setUniform(structUniform + ".datasetDimensions_", tgt::vec3(vh->getDimensions())); shader->setUniform(structUniform + ".datasetDimensionsRCP_", vec3(1.f) / tgt::vec3(vh->getDimensions())); // volume spacing, i.e. voxel size shader->setUniform(structUniform + ".datasetSpacing_", vh->getSpacing()); shader->setUniform(structUniform + ".datasetSpacingRCP_", vec3(1.f) / vh->getSpacing()); // volume's size in its physical coordinates shader->setUniform(structUniform + ".volumeCubeSize_", vh->getCubeSize()); shader->setUniform(structUniform + ".volumeCubeSizeRCP_", vec3(1.f) / vh->getCubeSize()); shader->setUniform(structUniform + ".volumeOffset_", vh->getOffset()); shader->setUniform(structUniform + ".numChannels_", static_cast<GLint>(vh->getNumChannels())); // volume's transformation matrix shader->setUniform(structUniform + ".physicalToWorldMatrix_", vh->getPhysicalToWorldMatrix()); tgt::mat4 invTm = vh->getWorldToPhysicalMatrix(); shader->setUniform(structUniform + ".worldToPhysicalMatrix_", invTm); shader->setUniform(structUniform + ".worldToTextureMatrix_", vh->getWorldToTextureMatrix()); shader->setUniform(structUniform + ".textureToWorldMatrix_", vh->getTextureToWorldMatrix()); // camera position in volume object coords if (camera) shader->setUniform(structUniform + ".cameraPositionPhysical_", invTm*camera->getPosition()); // light position in volume object coords shader->setUniform(structUniform + ".lightPositionPhysical_", (invTm*lightPosition).xyz()); LGL_ERROR; // bit depth of the volume shader->setUniform(structUniform + ".bitDepth_", (GLint)(vh->getBytesPerVoxel() * 8)); // construct shader real-world mapping by combining volume rwm and pixel transfer mapping RealWorldMapping rwm = vh->getRealWorldMapping(); RealWorldMapping transferMapping; if (vh->getRepresentation<VolumeGL>()) transferMapping = vh->getRepresentation<VolumeGL>()->getPixelTransferMapping(); else LWARNINGC("voreen.glsl", "setUniform(): no VolumeGL"); RealWorldMapping shaderMapping = RealWorldMapping::combine(transferMapping.getInverseMapping(), rwm); shader->setUniform(structUniform + ".rwmScale_", shaderMapping.getScale()); shader->setUniform(structUniform + ".rwmOffset_", shaderMapping.getOffset()); }
Serializable* KeyValueFactory::createType(const std::string& typeString) { using tgt::ivec2; using tgt::ivec3; using tgt::ivec4; using tgt::vec2; using tgt::vec3; using tgt::vec4; using tgt::mat2; using tgt::mat3; using tgt::mat4; if (typeString == "KeyValue_float") return new PropertyKeyValue<float>(0, 0); else if (typeString == "KeyValue_int") return new PropertyKeyValue<int>(0, 0); else if (typeString == "KeyValue_bool") return new PropertyKeyValue<bool>(0, 0); else if (typeString == "KeyValue_ivec2") return new PropertyKeyValue<ivec2>(ivec2(0), 0); else if (typeString == "KeyValue_ivec3") return new PropertyKeyValue<ivec3>(ivec3(0), 0); else if (typeString == "KeyValue_ivec4") return new PropertyKeyValue<ivec4>(ivec4(0), 0); else if (typeString == "KeyValue_vec2") return new PropertyKeyValue<vec2>(vec2(0.0f), 0); else if (typeString == "KeyValue_vec3") return new PropertyKeyValue<vec3>(vec3(0.0f), 0); else if (typeString == "KeyValue_vec4") return new PropertyKeyValue<vec4>(vec4(0.0f), 0); else if (typeString == "KeyValue_mat2") return new PropertyKeyValue<mat2>(mat2(0.0f), 0); else if (typeString == "KeyValue_mat3") return new PropertyKeyValue<mat3>(mat3(0.0f), 0); else if (typeString == "KeyValue_mat4") return new PropertyKeyValue<mat4>(mat4(0.0f), 0); else if (typeString == "KeyValue_Camera") return new PropertyKeyValue<tgt::Camera>(tgt::Camera(vec3(0.0f), vec3(0.0f), vec3(0.0f)), 0); else if (typeString == "KeyValue_string") return new PropertyKeyValue<std::string>("", 0); else if (typeString == "KeyValue_ShaderSource") return new PropertyKeyValue<ShaderSource>(ShaderSource(), 0); else if (typeString == "KeyValue_TransFunc") return new PropertyKeyValue<TransFunc*>(new TransFunc(), 0); else if (typeString == "KeyValue_VolumeCollection") return new PropertyKeyValue<VolumeCollection*>(new VolumeCollection(), 0); else if (typeString == "KeyValue_VolumeHandle") return new PropertyKeyValue<VolumeHandle*>(new VolumeHandle(), 0); else return 0; }
void TrackballNavigation::touchMoveEvent(tgt::TouchEvent* e) { if (!trackball_ || !tracking_) return; if (trackballEnabled_) { vec2 pointPos1 = e->touchPoints()[0].pos(); vec2 pointPos2 = e->touchPoints()[1].pos(); float newDistance = length(pointPos1 - pointPos2); float zoomFactor = newDistance / lastDistance_; vec2 newConnection = pointPos1 - pointPos2; // normalice vector to calculate angle newConnection = tgt::normalize(newConnection); lastConnection_ = tgt::normalize(lastConnection_); float angle = acos(newConnection.x * lastConnection_.x + newConnection.y * lastConnection_.y) ; float angleDegree = tgt::rad2deg(angle); // check crossproduct to determine whether it is a left or a right rotation vec3 cross = tgt::cross(vec3(newConnection,0),vec3(lastConnection_,0)); // rotation if angle is big enough if(angleDegree > 8.f) { if (cross.z >= 0) { angle = -angle; } // rotation around the z axis trackball_ ->rotate(vec3(0.f, 0.f, 1.f), angle); } // zoom if the angle is low else { trackball_->zoom(zoomFactor); } e->accept(); lastDistance_ = newDistance; lastConnection_ = newConnection; } }
CameraPositionRenderer::CameraPositionRenderer() : GeometryRendererBase() , enable_("enable", "Enable", true) , displayCamera_("displayCamera", "Display Camera", tgt::Camera(vec3(0.f, 0.f, 3.5f), vec3(0.f, 0.f, 0.f), vec3(0.f, 1.f, 0.f))) { addProperty(enable_); addProperty(displayCamera_); // light parameters light_pos[0] = 0.0f; light_pos[1] = 1.0f; light_pos[2] = 1.1f; light_pos[3] = 1.0f; light_ambient[0] = 1.0f; light_ambient[1] = 1.0f; light_ambient[2] = 1.0f; light_ambient[3] = 1.0f; light_diffuse[0] = 1.0f; light_diffuse[1] = 1.0f; light_diffuse[2] = 1.0f; light_diffuse[3] = 1.0f; light_specular[0] = 1.0f; light_specular[1] = 1.0f; light_specular[2] = 1.0f; light_specular[3] = 1.0f; // parameters for yellow plastic //ye_ambient[0] = 0.25f; //ye_ambient[1] = 0.2f; //ye_ambient[2] = 0.07f; //ye_ambient[3] = 1.0f; //ye_diffuse[0] = 0.75f; //ye_diffuse[1] = 0.61f; //ye_diffuse[2] = 0.23f; //ye_diffuse[3] = 1.0f; //ye_specular[0] = 0.63f; //ye_specular[1] = 0.56f; //ye_specular[2] = 0.37f; //ye_specular[3] = 1.0f; //ye_shininess = 51.0f; ye_ambient[0] = 0.25f; ye_ambient[1] = 0.25f; ye_ambient[2] = 0.25f; ye_ambient[3] = 1.0f; ye_diffuse[0] = 0.75f; ye_diffuse[1] = 0.75f; ye_diffuse[2] = 0.75f; ye_diffuse[3] = 1.0f; ye_specular[0] = 0.6f; ye_specular[1] = 0.6f; ye_specular[2] = 0.6f; ye_specular[3] = 1.0f; ye_shininess = 51.0f; }
void TripleView::renderLargeSmallSmall(RenderPort& large, RenderPort& small1, RenderPort& small2) { MatStack.matrixMode(tgt::MatrixStack::MODELVIEW); outport_.activateTarget(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (large.isReady()) renderPortQuad(large, vec3(-0.333333f, 0.0f, 0.0f), vec3(0.666666, 1.0f, 1.0f)); if (small1.isReady()) renderPortQuad(small1, vec3(0.666666f, 0.5f, 0.0f), vec3(0.333333f, 0.5f, 1.0f)); if (small2.isReady()) renderPortQuad(small2, vec3(0.666666f, -0.5f, 0.0f), vec3(0.333333f, 0.5f, 1.0f)); glActiveTexture(GL_TEXTURE0); if(showGrid_.get()) { glDepthFunc(GL_ALWAYS); glColor4f(gridColor_.get().r, gridColor_.get().g, gridColor_.get().b, gridColor_.get().a); glBegin(GL_LINES); glVertex2f(0.333333f, -1.0f); glVertex2f(0.333333f, 1.0f); glVertex2f(0.333333f, 0.0f); glVertex2f(1.f, 0.0f); glEnd(); glDepthFunc(GL_LESS); } outport_.deactivateTarget(); MatStack.matrixMode(tgt::MatrixStack::MODELVIEW); MatStack.loadIdentity(); LGL_ERROR; }
InteractiveRegistrationWidget::InteractiveRegistrationWidget() : RenderProcessor() , inport_(Port::INPORT, "input", "Image Input") , outport_(Port::OUTPORT, "output", "Image Output") , pickingPort_(Port::OUTPORT, "picking") , textPort_(Port::OUTPORT, "text", "Text Output") , transformMatrix_("transformMatrix", "Transformation Matrix", tgt::mat4::identity, tgt::mat4(-2000.0), tgt::mat4(2000.0)) , point_("point", "Point", vec3(0.0f), vec3(-999999.9f), vec3(999999.9f)) , plane_("plane", "Plane", vec3(1.0f, 0.0f, 0.0f), vec3(-5.0f), vec3(5.0f), Processor::VALID) , planeDist_("planeDist", "Plane Distance", 0.0f, -1000.0f, 1000.0f, Processor::VALID) , render_("render", "Render", true) , camera_("camera", "Camera", tgt::Camera(vec3(0.f, 0.f, 3.5f), vec3(0.f, 0.f, 0.f), vec3(0.f, 1.f, 0.f))) , sphereRadius_("sphereRadius", "Sphere Radius", 5.0f, 1.0f, 100.0f) , ringRadius_("ringRadius", "Ring Radius", 50.0f, 1.0f, 300.0f) , ringColor_("ringColor", "Ring Color", vec4(0.0f, 1.0f, 0.0f, 0.8f)) , sphereColor_("sphereColor", "Sphere Color", vec4(0.0f, 0.0f, 1.0f, 0.8f)) , centerPoint_("centerWidget", "Center Widget", Processor::VALID) , copyShader_(0) , lastCoord_(0) , startDragCoord_(0.0f) , curDragCoord_(0.0f) , rotAngle_(0.0f) , mouseDown_(-1) { addPort(inport_); addPort(outport_); addPrivateRenderPort(pickingPort_); addPort(textPort_); addProperty(render_); addProperty(transformMatrix_); addProperty(point_); addProperty(plane_); addProperty(planeDist_); addProperty(camera_); addProperty(sphereRadius_); addProperty(ringRadius_); addProperty(ringColor_); ringColor_.setViews(Property::COLOR); addProperty(sphereColor_); sphereColor_.setViews(Property::COLOR); addProperty(centerPoint_); plane_.onChange(CallMemberAction<InteractiveRegistrationWidget>(this, &InteractiveRegistrationWidget::planeChanged)); planeDist_.onChange(CallMemberAction<InteractiveRegistrationWidget>(this, &InteractiveRegistrationWidget::planeChanged)); centerPoint_.onChange(CallMemberAction<InteractiveRegistrationWidget>(this, &InteractiveRegistrationWidget::centerPoint)); }
void setUniform(tgt::Shader* shader, const std::string& imageUniform, const std::string& structUniform, const Slice* sl, const tgt::TextureUnit* texUnit) { bool ignoreErr = shader->getIgnoreUniformLocationError(); shader->setIgnoreUniformLocationError(true); if(texUnit) shader->setUniform(imageUniform, texUnit->getUnitNumber()); // volume size, i.e. dimensions of the proxy geometry in world coordinates shader->setUniform(structUniform + ".datasetDimensions_", tgt::vec3(sl->getTexture()->getDimensions())); shader->setUniform(structUniform + ".datasetDimensionsRCP_", vec3(1.f) / tgt::vec3(sl->getTexture()->getDimensions())); // volume spacing, i.e. voxel size //shader->setUniform(structUniform + ".datasetSpacing_", sl->getSpacing()); //shader->setUniform(structUniform + ".datasetSpacingRCP_", vec3(1.f) / sl->getSpacing()); shader->setUniform(structUniform + ".numChannels_", static_cast<GLint>(sl->getTexture()->getNumChannels())); //shader->setUniform(structUniform + ".numChannels_", static_cast<GLint>(1)); // volume's transformation matrix //shader->setUniform(structUniform + ".physicalToWorldMatrix_", sl->getPhysicalToWorldMatrix()); //tgt::mat4 invTm = sl->getWorldToPhysicalMatrix(); //shader->setUniform(structUniform + ".worldToPhysicalMatrix_", invTm); shader->setUniform(structUniform + ".worldToTextureMatrix_", sl->getWorldToTextureMatrix()); shader->setUniform(structUniform + ".textureToWorldMatrix_", sl->getTextureToWorldMatrix()); LGL_ERROR; // construct shader real-world mapping by combining volume rwm and pixel transfer mapping RealWorldMapping rwm = sl->getRealWorldMapping(); //RealWorldMapping transferMapping; //if (sl->getRepresentation<VolumeGL>()) //transferMapping = sl->getRepresentation<VolumeGL>()->getPixelTransferMapping(); //else //LWARNINGC("voreen.glsl", "setUniform(): no VolumeGL"); //RealWorldMapping shaderMapping = RealWorldMapping::combine(transferMapping.getInverseMapping(), rwm); RealWorldMapping shaderMapping = rwm; shader->setUniform(structUniform + ".rwmScale_", shaderMapping.getScale()); shader->setUniform(structUniform + ".rwmOffset_", shaderMapping.getOffset()); shader->setIgnoreUniformLocationError(ignoreErr); }
vec4 CPURaycaster::directRendering(const vec3& first, const vec3& last) { tgtAssert(transferFunc_.get(), "no transfunc"); // retrieve intensity volume const Volume* volume = volumePort_.getData()->getRepresentation<Volume>(); tgtAssert(volume, "no input volume"); tgt::svec3 volDim = volume->getDimensions(); tgt::vec3 volDimF = tgt::vec3((volume->getDimensions() - svec3(1))); // retrieve gradient volume, if 2D TF is to be applied const Volume* volumeGradient = 0; if (intensityGradientTF_) { volumeGradient = gradientVolumePort_.getData()->getRepresentation<Volume>(); tgtAssert(volumeGradient, "no gradient volume"); tgtAssert(volumeGradient->getNumChannels() >= 3, "gradient volume has less than three channels"); tgtAssert(volumeGradient->getDimensions() == volDim, "dimensions mismatch"); } // use dimension with the highest resolution for calculating the sampling step size float samplingStepSize = 1.f / (tgt::max(volDim) * samplingRate_.get()); // retrieve tf texture tgt::Texture* tfTexture = transferFunc_.get()->getTexture(); tfTexture->downloadTexture(); // calculate ray parameters float tend; float t = 0.0f; vec3 direction = last - first; // if direction is a nullvector the entry- and exitparams are the same // so special handling for tend is needed, otherwise we divide by zero // furthermore both for-loops will cause only 1 pass overall. // The test whether last and first are nullvectors is already done in main-function // but however the framerates are higher with this test. if (direction == vec3(0.0f) && last != vec3(0.0f) && first != vec3(0.0f)) tend = samplingStepSize / 2.0f; else { tend = length(direction); direction = normalize(direction); } // ray-casting loop vec4 result = vec4(0.0f); float depthT = -1.0f; bool finished = false; for (int loop=0; !finished && loop<255*255; ++loop) { vec3 sample = first + t * direction; float intensity = 0.f; if (texFilterMode_.getValue() == GL_NEAREST) intensity = volume->getVoxelFloat(tgt::iround(sample*volDimF)); else if (texFilterMode_.getValue() == GL_LINEAR) intensity = volume->getVoxelFloatLinear(sample*volDimF); else LERROR("Unknown texture filter mode"); // no shading is applied vec4 color; if (!intensityGradientTF_) color = apply1DTF(tfTexture, intensity); else { tgt::vec3 grad; if (texFilterMode_.getValue() == GL_NEAREST) { tgt::ivec3 iSample = tgt::iround(sample*volDimF); grad.x = volumeGradient->getVoxelFloat(iSample, 0); grad.y = volumeGradient->getVoxelFloat(iSample, 1); grad.z = volumeGradient->getVoxelFloat(iSample, 2); } else if (texFilterMode_.getValue() == GL_LINEAR) { grad.x = volumeGradient->getVoxelFloatLinear(sample*volDimF, 0); grad.y = volumeGradient->getVoxelFloatLinear(sample*volDimF, 1); grad.z = volumeGradient->getVoxelFloatLinear(sample*volDimF, 2); } else LERROR("Unknown texture filter mode"); float gradMag = tgt::clamp(tgt::length(grad), 0.f, 1.f); color = apply2DTF(tfTexture, intensity, gradMag); } // perform compositing if (color.a > 0.0f) { // multiply alpha by samplingStepSize // to accommodate for variable sampling rate color.a *= samplingStepSize*200.f; vec3 result_rgb = vec3(result.elem) + (1.0f - result.a) * color.a * vec3(color.elem); result.a = result.a + (1.0f - result.a) * color.a; result.r = result_rgb.r; result.g = result_rgb.g; result.b = result_rgb.b; } // save first hit ray parameter for depth value calculation if (depthT < 0.0f && result.a > 0.0f) depthT = t; // early ray termination if (result.a >= 0.95f) { result.a = 1.0f; finished = true; } t += samplingStepSize; finished = finished || (t > tend); } // ray-casting loop // calculate depth value from ray parameter (todo) // gl_FragDepth = 1.0; // if (depthT >= 0.0) // gl_FragDepth = calculateDepthValue(depthT / tend); return result; }
MeshListGeometry* ROICube::generateNormalizedMesh() const { MeshListGeometry* geometry = new MeshListGeometry(); geometry->addMesh(MeshGeometry::createCube(vec3(-1.0f), vec3(1.0f), vec3(0.0f), vec3(1.0f), getColor().xyz(), getColor().xyz())); return geometry; }
bool ROICube::inROINormalized(tgt::vec3 p) const { if(tgt::hand(tgt::greaterThanEqual(p, vec3(-1.0f))) && tgt::hand(tgt::lessThanEqual(p, vec3(1.0f)))) return true; else return false; }
void QuadricRenderer::render() { if (!enabled_.get()) return; glPushAttrib(GL_ALL_ATTRIB_BITS); glShadeModel(GL_SMOOTH); GLUquadricObj* quadric = gluNewQuadric(); LGL_ERROR; if (applyLighting_.get()) { glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient_.get().elem); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse_.get().elem); glLightfv(GL_LIGHT0, GL_SPECULAR, lightSpecular_.get().elem); glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 128.f); tgt::Material material(color_.get(), color_.get(), color_.get(), materialShininess_.get()); material.activate(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLightfv(GL_LIGHT0, GL_POSITION, lightPosition_.get().elem); glPopMatrix(); } else { // no lighting glColor4fv(color_.get().elem); } LGL_ERROR; glMatrixMode(GL_MODELVIEW); glPushMatrix(); if (quadricType_.isSelected("cylinder")) { glTranslatef(start_.get().x, start_.get().y, start_.get().z); //calculate correct rotation matrix: vec3 rotz = normalize(end_.get() - start_.get()); vec3 roty = normalize(vec3(rotz.y, -rotz.z, 0.0f)); vec3 rotx = cross(roty, rotz); float m[16]; m[0] = rotx.x; m[1] = rotx.y; m[2] = rotx.z; m[3] = 0.0f; m[4] = roty.x; m[5] = roty.y; m[6] = roty.z; m[7] = 0.0f; m[8] = rotz.x; m[9] = rotz.y; m[10] = rotz.z; m[11] = 0.0f; m[12] = 0.0f; m[13] = 0.0f; m[14] = 0.0f; m[15] = 1.0f; glMultMatrixf(m); float l = length(start_.get() - end_.get()); gluCylinder(quadric, radius_.get(), radius_.get(), l, 200, 200); } else if (quadricType_.isSelected("sphere")) { glTranslatef(position_.get().x, position_.get().y, position_.get().z); gluSphere(quadric, radius_.get(), 20, 20); } else { LERROR("Unknown quadric type: " << quadricType_.get()); } LGL_ERROR; glPopMatrix(); glPopAttrib(); gluDeleteQuadric(quadric); LGL_ERROR; }
void TripleView::process() { switch(configuration_.getValue()) { case abc: { MatStack.matrixMode(tgt::MatrixStack::MODELVIEW); outport_.activateTarget(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (inport1_.isReady()) renderPortQuad(inport1_, vec3(-0.66666f, 0.0f, 0.0f), vec3(0.333333f, 1.0f, 1.0f)); if (inport2_.isReady()) renderPortQuad(inport2_, vec3(0.0f, 0.0f, 0.0f), vec3(0.333333f, 1.0f, 1.0f)); if (inport3_.isReady()) renderPortQuad(inport3_, vec3(0.666666f, 0.0f, 0.0f), vec3(0.333333f, 1.0f, 1.0f)); glActiveTexture(GL_TEXTURE0); if(showGrid_.get()) { glDepthFunc(GL_ALWAYS); glColor4f(gridColor_.get().r, gridColor_.get().g, gridColor_.get().b, gridColor_.get().a); glBegin(GL_LINES); glVertex2f(-0.333333f, -1.0f); glVertex2f(-0.333333f, 1.0f); glVertex2f(0.333333f, -1.0f); glVertex2f(0.333333f, 1.0f); glEnd(); glDepthFunc(GL_LESS); } outport_.deactivateTarget(); MatStack.matrixMode(tgt::MatrixStack::MODELVIEW); MatStack.loadIdentity(); LGL_ERROR; } break; case Abc: renderLargeSmallSmall(inport1_, inport2_, inport3_); break; case Bac: renderLargeSmallSmall(inport2_, inport1_, inport3_); break; case Cab: renderLargeSmallSmall(inport3_, inport1_, inport2_); break; //maximized: case A: if(!inport1_.isReady()) return; outport_.activateTarget(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderPortQuad(inport1_, vec3(0.0f, 0.0f, 0.0f), vec3(1.0f, 1.0f, 1.0f)); outport_.deactivateTarget(); break; case B: if(!inport2_.isReady()) return; outport_.activateTarget(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderPortQuad(inport2_, vec3(0.0f, 0.0f, 0.0f), vec3(1.0f, 1.0f, 1.0f)); outport_.deactivateTarget(); break; case C: if(!inport3_.isReady()) return; outport_.activateTarget(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderPortQuad(inport3_, vec3(0.0f, 0.0f, 0.0f), vec3(1.0f, 1.0f, 1.0f)); outport_.deactivateTarget(); break; } }
void TrackballNavigation::keyEvent(tgt::KeyEvent* e) { e->ignore(); bool accepted = false; if ( (keyRotateMod_ == e->modifiers() || keyRotateMod_ & e->modifiers()) && e->pressed() == keyRotatePressed_) { if (e->keyCode() == keyRotateLeft_) { trackball_->rotate(vec3(0.f, 1.f, 0.f), getRotationAngle(keyRotateAcuteness_)); accepted = true; } else if (e->keyCode() == keyRotateRight_) { trackball_->rotate(vec3(0.f, 1.f, 0.f), -getRotationAngle(keyRotateAcuteness_)); accepted = true; } else if (e->keyCode() == keyRotateUp_) { trackball_->rotate(vec3(1.f, 0.f, 0.f), -getRotationAngle(keyRotateAcuteness_)); accepted = true; } else if (e->keyCode() == keyRotateDown_) { trackball_->rotate(vec3(1.f, 0.f, 0.f), getRotationAngle(keyRotateAcuteness_)); accepted = true; } } if ( (keyMoveMod_ == e->modifiers() || keyMoveMod_ & e->modifiers()) && e->pressed() == keyMovePressed_) { if (e->keyCode() == keyMoveLeft_) { trackball_->move(getMovementLength(keyMoveAcuteness_), vec3(-1.f, 0.f, 0.f)); accepted = true; } else if (e->keyCode() == keyMoveRight_) { trackball_->move(getMovementLength(keyMoveAcuteness_), vec3( 1.f, 0.f, 0.f)); accepted = true; } else if (e->keyCode() == keyMoveUp_) { trackball_->move(getMovementLength(keyMoveAcuteness_), vec3(0.f, 1.f, 0.f)); accepted = true; } else if (e->keyCode() == keyMoveDown_) { trackball_->move(getMovementLength(keyMoveAcuteness_), vec3(0.f, -1.f, 0.f)); accepted = true; } } if ( (keyZoomMod_ == e->modifiers() || keyZoomMod_ & e->modifiers()) && e->pressed() == keyZoomPressed_) { if (e->keyCode() == keyZoomIn_) { trackball_->zoom(getZoomFactor(keyZoomAcuteness_, true)); accepted = true; } else if (e->keyCode() == keyZoomOut_) { trackball_->zoom(getZoomFactor(keyZoomAcuteness_, false)); accepted = true; } } if ( (keyRollMod_ == e->modifiers() || keyRollMod_ & e->modifiers()) && e->pressed() == keyRollPressed_) { if (e->keyCode() == keyRollLeft_) { rollCameraHorz(getRollAngle(keyRollAcuteness_, true)); accepted = true; } else if (e->keyCode() == keyRollRight_) { rollCameraHorz(getRollAngle(keyRollAcuteness_, false)); accepted = true; } } if (accepted) e->accept(); }