Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 38bfd697 authored by mostajab's avatar mostajab
Browse files

+ Using passthrough.vert and geometryrenderer.frag instead of the...

+ Using passthrough.vert and geometryrenderer.frag instead of the meshGeometryRenderer.vert and meshgeometryrenderer.frag
+ adding comments for the destroy function of GeometryTextureInfo and why to use it.
+ Change the depth buffer size changing part of Paint() function in datacontainerinspectorcanvas checking part.
+ Delete the commented codes which are not necessary.
+ Fix the opening braces and removing the redundant parts and only for debugging parts.
+ DVRVis and volumerendererdemo default file is revereted to the original locations.
+ Revert the shaders to the original ones.
+ StartMouseDrag and EndMouseDrag functions of the trackball are replaced with mousePress and mouseRelease.

- Delete the meshGeometryRenderer.vert and meshgeometryrenderer.frag.
parent 7f1300d5
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
in vec3 in_Position; ///< incoming vertex position
out vec4 ex_Position; ///< outgoing world coordinates
/// Matrix defining model-to-world transformation
uniform mat4 _modelMatrix = mat4(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
/// Matrix defining view transformation
uniform mat4 _viewMatrix = mat4(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
/// Matrix defining projection transformation
uniform mat4 _projectionMatrix = mat4(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
void main() {
gl_Position = _projectionMatrix * (_viewMatrix * (_modelMatrix * vec4(in_Position, 1.0)));
ex_Position = gl_Position;
}
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
in vec4 ex_Position; ///< incoming texture coordinate
uniform vec4 _Color = vec4(0, 1, 0, 1); ///< outgoing colorin
out vec4 out_Color; ///< outgoing fragment color
void main() {
out_Color = _Color;
}
......@@ -94,7 +94,7 @@ namespace campvis {
GLJobProc.registerContext(this);
_paintShader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "application/glsl/datacontainerinspector.frag", "", false);
_geometryRenderingShader = ShdrMgr.loadSeparate("application/glsl/meshgeometryrenderer.vert", "application/glsl/meshgeometryrenderer.frag", "", false);
_geometryRenderingShader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/glsl/geometryrenderer.frag", "", false);
_paintShader->setAttributeLocation(0, "in_Position");
_paintShader->setAttributeLocation(1, "in_TexCoords");
......@@ -162,19 +162,12 @@ namespace campvis {
void DataContainerInspectorCanvas::paint() {
/// if the window is resized, change the depth buffer size, also!
if(_depthBuffer)
if(_depthBuffer->getWidth() != width() || _depthBuffer->getHeight() != height()) {
if(!_depthBuffer || _depthBuffer->getWidth() != width() || _depthBuffer->getHeight() != height()) {
delete _depthBuffer;
_depthBuffer = new tgt::Texture(0, tgt::ivec3(width(), height(), 1), GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT24, GL_FLOAT, tgt::Texture::LINEAR); //, _renderingWndSize(tgt::ivec2(400, 100))
_texturesDirty = true;
}
else {
// Do nothing!
}
else {
_depthBuffer = new tgt::Texture(0, tgt::ivec3(width(), height(), 1), GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT24, GL_FLOAT, tgt::Texture::LINEAR); //, _renderingWndSize(tgt::ivec2(400, 100))
_texturesDirty = true;
}
LGL_ERROR;
tbb::mutex::scoped_lock lock(_localMutex);
......@@ -325,20 +318,15 @@ namespace campvis {
meshColor.g /= 255.0f;
meshColor.b /= 255.0f;
meshColor.a /= 255.0f;
_geometryRenderingShader->setUniform("_Color", meshColor);
_geometryRenderingShader->setUniform("_color", meshColor);
LGL_ERROR;
//_geometryRenderingShader->setUniform("_cameraPosition", _trackballEHs[trackballndx]->_trackball->getCamera()->getPosition());
_geometryRenderingShader->setIgnoreUniformLocationError(false);
LGL_ERROR;
_frameBuffer->activate();
LGL_ERROR;
// acqiure a new TextureUnit, so that we don't mess with other currently bound textures during texture upload...
//tgt::TextureUnit rtUnit;
//rtUnit.activate();
// Set OpenGL pixel alignment to 1 to avoid problems with NPOT textures
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
......@@ -368,7 +356,7 @@ namespace campvis {
// change the color to white for the wireframe.
_geometryRenderingShader->setUniform("_Color", 1.0f, 1.0f, 1.0f, 1.0f);
_geometryRenderingShader->setUniform("_color", 1.0f, 1.0f, 1.0f, 1.0f);
// Render wireframe around the geometry.
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
......@@ -377,7 +365,6 @@ namespace campvis {
LGL_ERROR;
colorBuffer->downloadTexture();
/*_depthBuffer.downloadTexture();*/
_frameBuffer->deactivate();
LGL_ERROR;
......@@ -439,17 +426,6 @@ namespace campvis {
void DataContainerInspectorCanvas::mouseMoveEvent(tgt::MouseEvent* e)
{
//LGL_ERROR;
/*if (_renderFullscreen) {
_renderFullscreen = false;
}
else {
tgt::ivec2 selectedIndex(e->x() / _quadSize.x, e->y() / _quadSize.y);
_selectedTexture = (selectedIndex.y * _numTiles.x) + selectedIndex.x;
_renderFullscreen = true;
}
e->ignore();
invalidate();*/
if(e->button() == tgt::MouseEvent::MOUSE_BUTTON_LEFT) {
tgt::MouseEvent* me = static_cast<tgt::MouseEvent*>(e);
......@@ -515,51 +491,43 @@ namespace campvis {
}
void DataContainerInspectorCanvas::mousePressEvent(tgt::MouseEvent* e) {
//LGL_ERROR;
//if (_renderFullscreen) {
tgt::ivec2 selectedIndex(e->x() / _quadSize.x, e->y() / _quadSize.y);
_selectedTrackball = -1;
std::vector<GeometryTextureInfo>::iterator geomTexInfoIter = _geomTextureInfos.begin();
tgt::ivec2 selectedIndex(e->x() / _quadSize.x, e->y() / _quadSize.y);
_selectedTrackball = -1;
std::vector<GeometryTextureInfo>::iterator geomTexInfoIter = _geomTextureInfos.begin();
switch (e->button()) {
case tgt::MouseEvent::MOUSE_BUTTON_LEFT:
//++_currentSlice; // we cant clamp the value here to the number of slices - we do this during rendering
switch (e->button()) {
case tgt::MouseEvent::MOUSE_BUTTON_LEFT:
//++_currentSlice; // we cant clamp the value here to the number of slices - we do this during rendering
_selectedTexture = (selectedIndex.y * _numTiles.x) + selectedIndex.x;
_selectedTexture = (selectedIndex.y * _numTiles.x) + selectedIndex.x;
for(; geomTexInfoIter != _geomTextureInfos.end(); geomTexInfoIter++) {
if((*geomTexInfoIter)._trackballIndx == _selectedTexture) {
_selectedTrackball = (*geomTexInfoIter)._trackballIndx;
break;
}
for(; geomTexInfoIter != _geomTextureInfos.end(); geomTexInfoIter++) {
if((*geomTexInfoIter)._trackballIndx == _selectedTexture) {
_selectedTrackball = (*geomTexInfoIter)._trackballIndx;
break;
}
}
if(_selectedTrackball >= 0)
_trackballEHs[_selectedTrackball]->getTrackball()->startMouseDrag(e);
// e->ignore();
break;
if(_selectedTrackball >= 0)
_trackballEHs[_selectedTrackball]->getTrackball()->mousePressEvent(e);
break;
default:
break;
}
//}
default:
break;
}
}
void DataContainerInspectorCanvas::mouseReleaseEvent(tgt::MouseEvent* e) {
if (_renderFullscreen) {
switch (e->button()) {
case tgt::MouseEvent::MOUSE_BUTTON_LEFT:
//++_currentSlice; // we cant clamp the value here to the number of slices - we do this during rendering
if(_selectedTrackball >= 0)
_trackballEHs[_selectedTrackball]->getTrackball()->endMouseDrag(e);
// e->ignore();
_trackballEHs[_selectedTrackball]->getTrackball()->mouseReleaseEvent(e);
break;
default:
break;
}
//invalidate();
}
}
......@@ -623,16 +591,14 @@ namespace campvis {
else if (const RenderData* rd = dynamic_cast<const RenderData*>(it->second.getData())) {
for (size_t i = 0; i < rd->getNumColorTextures(); ++i) {
const ImageRepresentationGL* imgGL = rd->getColorTexture(i)->getRepresentation<ImageRepresentationGL>();
if (imgGL)
{
if (imgGL) {
imgGL->downloadTexture();
_textures.push_back(imgGL->getTexture());
}
}
if (rd->hasDepthTexture()) {
const ImageRepresentationGL* imgGL = rd->getDepthTexture()->getRepresentation<ImageRepresentationGL>();
if (imgGL)
{
if (imgGL) {
imgGL->downloadTexture();
_textures.push_back(imgGL->getTexture());
}
......@@ -666,7 +632,6 @@ namespace campvis {
/// Render the object on the buffers.
glewExperimental = true;
drawGeomteryData(gd, colorBuffer, nMeshGeometry++);
LGL_ERROR;
geomTexInfo._texture = colorBuffer;
......@@ -676,10 +641,6 @@ namespace campvis {
/// Store the rendered texture in textures.
_textures.push_back(colorBuffer);
/// Store the object index in the array in the geometry texture indices array.
// _geomTextureIndices.push_back(_textures.size() - 1);
}
}
......
......@@ -63,6 +63,10 @@ namespace campvis {
class FaceGeometry;
class DataContainerInspectorWidget;
/**
* Stores information about the textures which store the rendered geomtery.
* Note: The object's destroy() function should be called before deleting or releasing the object's memory.
*/
struct GeometryTextureInfo {
campvis::QtDataHandle _geomData;
tgt::Texture* _texture;
......@@ -70,9 +74,9 @@ namespace campvis {
GeometryTextureInfo(): _geomData(0), _texture(0){
}
void destroy() {
// _texture->destroy();
void destroy()
{
delete _texture;
}
......@@ -276,12 +280,9 @@ namespace campvis {
int _currentSlice; ///< current slice if rendering a 3D image fullscreen, render MIP if negative
tgt::Shader* _geometryRenderingShader; ///< GLSL shader for rendering the mesh geomteries
//std::vector<tgt::Texture*> _geometryRendering_ColorBuffers; ///< Color Buffer used to render the geometry for the debugging mode
//std::vector<tgt::Texture*> _geometryRendering_DepthBuffers; ///< Depth Buffer used to render the geometry for the debugging mode
tgt::FramebufferObject* _frameBuffer;
tgt::Texture* _depthBuffer;
// tgt::ivec2 _renderingWndSize;
std::vector<campvis::CameraProperty*> _trackballCameraProperties; ///< The property of the trackball camera. Used to pass the trackball camera to the shader.
std::vector<TrackballNavigationEventListener*> _trackballEHs; ///< TrackBall Event Handler for the camera rotating around the object in the canvas
std::vector<GeometryTextureInfo> _geomTextureInfos; ///< Array of data regarding the rendered geomteries
......
......@@ -262,11 +262,7 @@ namespace campvis {
std::ostringstream ss;
ss << tester->getWorldBounds();
_lblBounds->setText(tr("World Bounds: ") + QString::fromStdString(ss.str()));
//tester->render();
_lblBounds->setText(tr("World Bounds: ") + QString::fromStdString(ss.str()));
}
else if (const RenderData* tester = dynamic_cast<const RenderData*>(handles.front().second.getData())) {
const ImageData* id = tester->getNumColorTextures() > 0 ? tester->getColorTexture() : tester->getDepthTexture();
......
......@@ -89,8 +89,7 @@ namespace campvis {
*/
void onDataContainerDataAdded(const std::string&, const DataHandle&);
void mousePressEvent(QMouseEvent*)
{
void mousePressEvent(QMouseEvent*) {
updateInfoWidget();
}
......@@ -153,8 +152,7 @@ namespace campvis {
*/
//protected:
public: // Only for Debuggin
protected:
static void saveToFile(DataHandle handle, std::string filename);
/**
......
......@@ -180,7 +180,6 @@ namespace campvis {
CamPropNavigationWrapper _cpnw; ///< The CamPropNavigationWrapper used to adapt to the tgt::Trackball interface
tgt::Trackball* _trackball; ///< The tgt::Trackball for the navigation logic
protected:
tgt::Bounds _sceneBounds; ///< The extent of the scene (in world coordinates)
/// List of processors for which to enable LQ mode during interaction
......
......@@ -286,7 +286,6 @@ class Trackball : public Navigation {
/// last rotation applied to trackball
quat lastOrientationChange_;
public:
/// Stores mouse coordinates to be able to track relative mouse motions.
/// Should be called when mouse buttons get pressed.
void startMouseDrag(MouseEvent* e);
......@@ -294,7 +293,6 @@ public:
/// Should be called when mouse buttons get released.
void endMouseDrag(MouseEvent* e);
protected:
/// scale screen-coodinates of mouse to intervall [-1, 1]x[-1, 1]
vec2 scaleMouse(const ivec2& sc) const;
......
......@@ -40,9 +40,7 @@ uniform LightSource _lightSource;
uniform vec3 _cameraPosition;
void main() {
out_Color = ex_Position;
//out_Color = vec4(1, 1, 0, 1);
//out_Color = _color;
out_Color = _color;
#ifdef ENABLE_SHADING
// compute gradient (needed for shading and normals)
......
......@@ -88,8 +88,8 @@ namespace campvis {
_camera.addSharedProperty(&_dvrNormal.p_camera);
_camera.addSharedProperty(&_dvrVM.p_camera);
//_imageReader.p_url.setValue("e:\\Medical Data\\Dentalscan\\dental.mhd");
_imageReader.p_url.setValue("e:\\Medical Data\\smallHeart.mhd");
//_imageReader.p_url.setValue("D:\\Medical Data\\Dentalscan\\dental.mhd");
_imageReader.p_url.setValue("D:\\Medical Data\\smallHeart.mhd");
_imageReader.p_targetImageID.setValue("reader.output");
_imageReader.p_targetImageID.addSharedProperty(&_eepGenerator.p_sourceImageID);
_imageReader.p_targetImageID.addSharedProperty(&_vmEepGenerator.p_sourceImageID);
......
......@@ -67,7 +67,7 @@ namespace campvis {
_vr.p_outputImage.setValue("combine");
_renderTargetID.setValue("combine");
_imageReader.p_url.setValue("e:\\Medical Data\\smallHeart.mhd");
_imageReader.p_url.setValue("D:\\Medical Data\\smallHeart.mhd");
_imageReader.p_targetImageID.setValue("reader.output");
_imageReader.p_targetImageID.addSharedProperty(&_vr.p_inputVolume);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment