本文整理汇总了C++中tgt类的典型用法代码示例。如果您正苦于以下问题:C++ tgt类的具体用法?C++ tgt怎么用?C++ tgt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tgt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTex
void TransFunc1DKeys::updateTexture() {
if (!tex_ || (tex_->getDimensions() != dimensions_))
createTex();
tgtAssert(tex_, "No texture");
//get tresholds of the transfer function
int front_end = tgt::iround(lowerThreshold_*dimensions_.x);
int back_start = tgt::iround(upperThreshold_*dimensions_.x);
//all values before front_end and after back_start are set to zero
//all other values are taken from the TF
for (int x = 0; x < front_end; ++x)
tex_->texel<col4>(x) = col4(0, 0, 0, 0);
for (int x = front_end; x < back_start; ++x)
tex_->texel<col4>(x) = col4(getMappingForValue(static_cast<float>(x) / dimensions_.x));
for (int x = back_start; x < dimensions_.x; ++x)
tex_->texel<col4>(x) = col4(0, 0, 0, 0);
tex_->uploadTexture();
LGL_ERROR;
textureInvalid_ = false;
}
示例2: resetCameraPosition
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());
}
示例3: unsetCursor
void TransFuncMappingCanvasRamp::mouseMoveEvent(QMouseEvent* event) {
unsetCursor();
event->accept();
mousePos_ = event->pos();
vec2 sHit = vec2(event->x(), static_cast<float>(height()) - event->y());
vec2 hit = stow(sHit);
// return when no key was inserted or selected
if (!dragging_)
return;
// keep location within valid texture coord range
hit = tgt::clamp(hit, 0.f, 1.f);
if (selectedKey_ != 0) {
TransFuncMappingKey* leftKey = tf_->getKey(0);
TransFuncMappingKey* rightKey = tf_->getKey(1);
if (selectedKey_ == leftKey) {
// obey ramp function restrictions:
// left key has to stay left of right key
hit.x = std::min<float>(hit.x, rightKey->getIntensity());
// max width = 1.f, min center = 0.f
float minX = rightKey->getIntensity() - 1.f;
float maxY = std::min(-minX, 0.5f);
hit.y = std::min(hit.y, maxY);
if (rightKey->getIntensity() == 1.f) {
minX = rightKey->getIntensity() - rightKey->getColorL().a / 255.f;
hit.x = std::max(hit.x, minX);
}
// moving left upwards only allowed if at left border (ramp function)
if (hit.x != 0.f)
hit.y = 0.f;
}
else {
// obey ramp function restrictions:
// right key has to stay right of right key
hit.x = std::max<float>(hit.x, leftKey->getIntensity());
// max width = 1.f, max center = 1.f
float maxX = leftKey->getIntensity() + 1.f;
float minY = std::max(2.f - maxX, 0.5f);
hit.y = std::max(hit.y, minY);
if (leftKey->getIntensity() == 0.f) {
float maxX = 1.f - leftKey->getColorL().a / 255.f;
hit.x = std::min(hit.x, maxX);
}
// moving right downwards only allowed if at right border (ramp function)
if (hit.x != 1.f)
hit.y = 1.f;
}
selectedKey_->setIntensity(hit.x);
selectedKey_->setAlphaL(hit.y);
calcRampParameterFromKeys();
updateCoordinates(event->pos(), vec2(hit.x, selectedKey_->getAlphaL()));
repaint();
emit changed();
}
}
示例4: setUniform
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());
}
示例5: RenderProcessor
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));
}
示例6: result
tgt::vec4 TransFunc1DKeys::getMeanValue(float segStart, float segEnd) const {
ivec4 result(0);
float width = static_cast<float>(tex_->getWidth());
for (int i = static_cast<int>(segStart*width); i < segEnd*width; ++i)
result += ivec4(tex_->texel<col4>(i));
return static_cast<tgt::vec4>(result)/(segEnd*width-segStart*width);
}
示例7: length
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;
}
}
示例8: GeometryRendererBase
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;
}
示例9: getKey
bool TransFunc1DKeys::isStandardFunc() const {
if(getDomain() == tgt::vec2(0.0f, 1.0f) && (getNumKeys() == 2)) {
const TransFuncMappingKey* k0 = getKey(0);
if((k0->getIntensity() == 0.0f) && !(k0->isSplit()) && (k0->getColorL() == col4(0, 0, 0, 0))) {
const TransFuncMappingKey* k1 = getKey(1);
if((k1->getIntensity() == 1.0f) && !(k1->isSplit()) && (k1->getColorL() == col4(255)))
return true;
}
}
return false;
}
示例10: glClear
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;
}
示例11: result
tgt::vec4 TransFunc1DKeys::getMeanValue(float segStart, float segEnd) const {
ivec4 result(0);
if (!tex_ || textureInvalid_) {
LWARNING("getMeanValue(): texture is invalid");
return result;
}
float width = static_cast<float>(tex_->getWidth());
for (int i = static_cast<int>(segStart*width); i < segEnd*width; ++i)
result += ivec4(tex_->texel<col4>(i));
return static_cast<tgt::vec4>(result)/(segEnd*width-segStart*width);
}
示例12: LWARNING
void PointSegmentListRenderer::initializeColorMap() {
if (!segmentColors_) {
LWARNING("SegmentColors property vector not initialized");
return;
}
std::vector<tgt::Color> colorMap;
colorMap.push_back(vec4(255,0,0,255) / 255.f);
colorMap.push_back(vec4(0,255,0,255) / 255.f);
colorMap.push_back(vec4(0,0,255,255) / 255.f);
colorMap.push_back(vec4(255,0,255,255) / 255.f);
colorMap.push_back(vec4(0,255,255,255) / 255.f);
colorMap.push_back(vec4(255,255,0,255) / 255.f);
colorMap.push_back(vec4(255,100,20,255) / 255.f);
colorMap.push_back(vec4(250,200,150,255) / 255.f);
colorMap.push_back(vec4(150,200,250,255) / 255.f);
colorMap.push_back(vec4(30,30,30,255) / 255.f);
for (int i=0; i<segmentColors_->size(); ++i)
segmentColors_->getProperty<FloatVec4Property*>(i)->set(colorMap[i % colorMap.size()]);
}
示例13: mouseMoveEvent
void TrackballNavigation::mouseMoveEvent(tgt::MouseEvent* e) {
e->ignore();
if (!trackball_ || !tracking_)
return;
if (trackballEnabled_) {
vec2 newMouse = scaleMouse( ivec2(e->x(), e->y()), e->viewport() );
if (mode_ == ROTATE_MODE) {
trackball_->rotate(newMouse, lastMousePosition_);
e->accept();
}
if (mode_ == SHIFT_MODE) {
trackball_->move(newMouse, lastMousePosition_);
e->accept();
}
if (mode_ == ZOOM_MODE) {
trackball_->zoom(newMouse, lastMousePosition_, mouseZoomInDirection_);
e->accept();
}
if (mode_ == ROLL_MODE) {
rollCameraHorz((newMouse.x-lastMousePosition_.x) / mouseRollAcuteness_);
e->accept();
}
lastMousePosition_ = newMouse;
// restrict distance within specified range
if (trackball_->getCenterDistance() < minDistance_)
trackball_->zoomAbsolute(minDistance_);
if (trackball_->getCenterDistance() > maxDistance_)
trackball_->zoomAbsolute(maxDistance_);
}
}
示例14: tgtAssert
void CPURaycaster::process() {
tgtAssert(volumePort_.getData()->getRepresentation<Volume>(), "no input volume");
transferFunc_.setVolumeHandle(volumePort_.getData());
LGL_ERROR;
// determine TF type
intensityGradientTF_ = false;
if (transferFunc_.get()) {
TransFuncIntensity* tfi = dynamic_cast<TransFuncIntensity*>(transferFunc_.get());
if (tfi == 0) {
TransFuncIntensityGradient* tfig = dynamic_cast<TransFuncIntensityGradient*>(transferFunc_.get());
if (tfig == 0) {
LWARNING("CPURaycaster::process: unsupported tf");
return;
}
else {
intensityGradientTF_ = true;
}
}
}
// if 2D TF: check whether gradient volume is supplied
if (intensityGradientTF_ ) {
if (!gradientVolumePort_.hasData() || gradientVolumePort_.getData()->getRepresentation<Volume>()->getNumChannels() < 3) {
LERROR("To use 2D tfs a RGB or RGBA gradient volume is needed");
return;
}
if (gradientVolumePort_.getData()->getRepresentation<Volume>()->getDimensions() != volumePort_.getData()->getRepresentation<Volume>()->getDimensions()) {
LERROR("Gradient volume dimensions differ from intensity volume dimensions");
return;
}
}
// activate outport
outport_.activateTarget();
outport_.clearTarget();
LGL_ERROR;
// create output buffer
tgt::vec4* output = new tgt::vec4[entryPort_.getSize().x * entryPort_.getSize().y];
// download entry/exit point textures
tgt::vec4* entryBuffer = reinterpret_cast<tgt::vec4*>(
entryPort_.getColorTexture()->downloadTextureToBuffer(GL_RGBA, GL_FLOAT));
tgt::vec4* exitBuffer = reinterpret_cast<tgt::vec4*>(
exitPort_.getColorTexture()->downloadTextureToBuffer(GL_RGBA, GL_FLOAT));
LGL_ERROR;
// iterate over viewport and perform ray casting for each fragment
for (int y=0; y < entryPort_.getSize().y; ++y) {
for (int x=0; x < entryPort_.getSize().x; ++x) {
vec4 gl_FragColor = vec4(0.f);
int p = (y * entryPort_.getSize().x + x);
vec4 frontPos = entryBuffer[p];
vec4 backPos = exitBuffer[p];
if ((frontPos == vec4(0.0)) && (backPos == vec4(0.0))) {
//background needs no raycasting
}
else {
//fragCoords are lying inside the boundingbox
gl_FragColor = directRendering(frontPos.xyz(), backPos.xyz());
}
output[p] = gl_FragColor;
}
}
delete[] entryBuffer;
delete[] exitBuffer;
// draw output buffer to outport
glWindowPos2i(0, 0);
glDrawPixels(outport_.getSize().x, outport_.getSize().y, GL_RGBA, GL_FLOAT, output);
LGL_ERROR;
delete[] output;
outport_.deactivateTarget();
LGL_ERROR;
}
示例15: vec4
vec4 CPURaycaster::apply2DTF(tgt::Texture* tfTexture, float intensity, float gradientMagnitude) {
vec4 value = vec4(tfTexture->texel<tgt::vec4>(size_t(intensity * (tfTexture->getWidth()-1)),
size_t(gradientMagnitude * (tfTexture->getHeight()-1))));
return value;
}