本文整理汇总了C++中tgt类的典型用法代码示例。如果您正苦于以下问题:C++ tgt类的具体用法?C++ tgt怎么用?C++ tgt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tgt类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:emmaai,项目名称:fractalM,代码行数:25,代码来源:transfunc1dkeys.cpp
示例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());
}
开发者ID:alvatar,项目名称:smartmatter,代码行数:8,代码来源:camerawidget.cpp
示例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();
}
}
开发者ID:alvatar,项目名称:smartmatter,代码行数:58,代码来源:transfuncmappingcanvasramp.cpp
示例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());
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:52,代码来源:glsl.cpp
示例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));
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:47,代码来源:interactiveregistrationwidget.cpp
示例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);
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:8,代码来源:transfunc1dkeys.cpp
示例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;
}
}
开发者ID:151706061,项目名称:Voreen,代码行数:44,代码来源:trackballnavigation.cpp
示例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;
}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:55,代码来源:camerapositionrenderer.cpp
示例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;
}
开发者ID:emmaai,项目名称:fractalM,代码行数:11,代码来源:transfunc1dkeys.cpp
示例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;
}
开发者ID:151706061,项目名称:Voreen,代码行数:35,代码来源:tripleview.cpp
示例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);
}
开发者ID:emmaai,项目名称:fractalM,代码行数:13,代码来源:transfunc1dkeys.cpp
示例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()]);
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:23,代码来源:pointsegmentlistrenderer.cpp
示例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_);
}
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:37,代码来源:trackballnavigation.cpp
示例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;
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:82,代码来源:cpuraycaster.cpp
示例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;
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:5,代码来源:cpuraycaster.cpp
示例16: if
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;
}
开发者ID:alvatar,项目名称:smartmatter,代码行数:50,代码来源:serializationfactories.cpp
示例17: glPushAttrib
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;
}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:85,代码来源:quadricrenderer.cpp
示例18: glDeleteLists
void PointListRenderer::generateDisplayList(const std::vector<vec3>& pointList) {
if (glIsList(displayList_))
glDeleteLists(displayList_, 1);
displayList_ = glGenLists(1);
glNewList(displayList_, GL_COMPILE);
glPushAttrib(GL_ALL_ATTRIB_BITS);
if (coordinateSystem_.get() != "world") {
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
if (coordinateSystem_.get() == "viewport") {
glTranslatef(-1.f, -1.f, 0.f);
glScalef(2.f/viewport_.x, 2.f/viewport_.y, 1.f);
}
}
if (!depthTest_.get())
glDisable(GL_DEPTH_TEST);
// enable lighting for illuminated spheres
if (renderingPrimitiveProp_.get() == "illuminated-spheres") {
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_AMBIENT, vec4(0.3f, 0.3f, 0.3f, 1.f).elem);
glLightfv(GL_LIGHT0, GL_DIFFUSE, vec4(0.6f, 0.6f, 0.6f, 1.f).elem);
glLightfv(GL_LIGHT0, GL_SPECULAR, vec4(0.6f, 0.6f, 0.6f, 1.f).elem);
glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 128.f);
tgt::Material material(color_.get(), color_.get(), color_.get(), 75.f);
material.activate();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glLightfv(GL_LIGHT0, GL_POSITION, vec4(1.f, 1.f, 10.f, 1.f).elem);
glPopMatrix();
}
// render: point primitives
if (renderingPrimitiveProp_.get() == "points") {
glColor4fv(color_.get().elem);
glPointSize(pointSize_.get());
if (pointSmooth_.get())
glEnable(GL_POINT_SMOOTH);
glBegin(GL_POINTS);
for (size_t i=0; i<pointList.size(); ++i) {
tgt::vertex(pointList[i]);
}
glEnd();
}
// render: line strip
if (renderingPrimitiveProp_.get() == "line-strip") {
glColor4fv(color_.get().elem);
glLineWidth(pointSize_.get());
if (pointSmooth_.get())
glEnable(GL_LINE_SMOOTH);
glBegin(GL_LINE_STRIP);
for (size_t i=0; i<pointList.size(); ++i) {
tgt::vertex(pointList[i]);
}
glEnd();
}
// render: spheres
else if (renderingPrimitiveProp_.get() == "spheres" || renderingPrimitiveProp_.get() == "illuminated-spheres") {
GLUquadricObj* quadric = gluNewQuadric();
glColor4fv(color_.get().elem);
for (size_t i=0; i<pointList.size(); ++i) {
glPushMatrix();
tgt::translate(pointList[i]);
gluSphere(quadric, sphereDiameter_.get(), sphereSlicesStacks_.get(), sphereSlicesStacks_.get());
glPopMatrix();
}
gluDeleteQuadric(quadric);
}
if (coordinateSystem_.get() != "world") {
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
glPopAttrib();
glEndList();
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:95,代码来源:pointlistrenderer.cpp
示例19: set
void CameraProperty::set(const tgt::Camera& camera) {
value_ = Camera(camera);
invalidate();
}
开发者ID:emmaai,项目名称:fractalM,代码行数:4,代码来源:cameraproperty.cpp
示例20: invalidate
void LightWidgetRenderer::moveSphere(tgt::MouseEvent* e) {
LGL_ERROR;
if (!idManager_)
return;
if (e->action() & tgt::MouseEvent::PRESSED) {
if (idManager_->isHit(tgt::ivec2(e->x(), e->viewport().y - e->y() ), this)) {
lightPosition_.toggleInteractionMode(true, this);
e->accept();
invalidate();
isClicked_ = true;
lightPositionAbs_.x = lightPosition_.get().x;
lightPositionAbs_.y = lightPosition_.get().y;
lightPositionAbs_.z = lightPosition_.get().z;
startCoord_.x = e->coord().x;
startCoord_.y = e->coord().y;
}
return;
}
if (e->action() & tgt::MouseEvent::MOTION) {
if (isClicked_) {
e->accept();
LGL_ERROR;
GLint deltaX, deltaY;
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
GLdouble winX, winY, winZ;
GLdouble posX, posY, posZ;
deltaX = e->coord().x - startCoord_.x;
deltaY = startCoord_.y - e->coord().y;
tgt::mat4 projection_tgt = camera_.getProjectionMatrix(idManager_->getRenderTarget()->getSize());
tgt::mat4 modelview_tgt = camera_.getViewMatrix();
for (int i = 0; i < 4; ++i) {
modelview[i+0] = modelview_tgt[i].x;
modelview[i+4] = modelview_tgt[i].y;
modelview[i+8] = modelview_tgt[i].z;
modelview[i+12] = modelview_tgt[i].w;
projection[i+0] = projection_tgt[i].x;
projection[i+4] = projection_tgt[i].y;
projection[i+8] = projection_tgt[i].z;
projection[i+12] = projection_tgt[i].w;
}
viewport[0] = 0;
viewport[1] = 0;
//viewport[2] = static_cast<GLint>(e->viewport().x);
//viewport[3] = static_cast<GLint>(e->viewport().y);
viewport[2] = static_cast<GLint>(idManager_->getRenderTarget()->getSize().x);
viewport[3] = static_cast<GLint>(idManager_->getRenderTarget()->getSize().y);
posX = lightPositionAbs_.x;
posY = lightPositionAbs_.y;
posZ = lightPositionAbs_.z;
LGL_ERROR;
gluProject(posX, posY,posZ,modelview,projection, viewport,&winX, &winY, &winZ);
winX = winX + deltaX;
winY = winY + deltaY;
LGL_ERROR;
gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
LGL_ERROR;
lightPosition_.set(vec4(static_cast<float>(posX), static_cast<float>(posY), static_cast<float>(posZ), 1.f));
LGL_ERROR;
invalidate();
LGL_ERROR;
}
return;
}
if (e->action() & tgt::MouseEvent::RELEASED) {
if (isClicked_) {
lightPosition_.toggleInteractionMode(false, this);
e->accept();
isClicked_ = false;
invalidate();
}
return;
}
}
开发者ID:emmaai,项目名称:fractalM,代码行数:88,代码来源:lightwidgetrenderer.cpp
注:本文中的tgt类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论