Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit 253cb13f authored by schultezub's avatar schultezub
Browse files

added VirtualMirrorGeometryGenerator processor

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@282 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent a04b65e6
// ================================================================================================
//
// This file is part of the TUMVis Visualization 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 Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// 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.
//
// ================================================================================================
#include "virtualmirrorgeometrygenerator.h"
#include "tgt/glmath.h"
#include "tgt/logmanager.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
#include "core/datastructures/imagedatagl.h"
#include "core/datastructures/meshgeometry.h"
namespace TUMVis {
const std::string VirtualMirrorGeometryGenerator::loggerCat_ = "TUMVis.modules.vis.VirtualMirrorGeometryGenerator";
VirtualMirrorGeometryGenerator::VirtualMirrorGeometryGenerator()
: AbstractProcessor()
, _mirrorID("geometryID", "Output Geometry ID", "mirror")
, _mirrorCenter("mirrorCenter", "Mirror Center", tgt::vec3(1.f), tgt::vec3(-100.f), tgt::vec3(100.f))
, _mirrorNormal("mirrorNormal", "Mirror Normal", tgt::vec3(0.f, 1.f, 0.f), tgt::vec3(-1.f), tgt::vec3(1.f), InvalidationLevel::VALID)
, _size("mirrorSize", "Mirror Size", 4.0f, 0.1f, 1000.0f)
, _numVertices("Roundness", "Roundness", 16, 4, 128)
, _poi("poi", "Point of Interest", tgt::vec3::zero, tgt::vec3(-100.f), tgt::vec3(1000.f))
, _camera("camera", "Camera")
{
addProperty(&_mirrorID);
addProperty(&_mirrorCenter);
addProperty(&_mirrorNormal);
addProperty(&_size);
addProperty(&_numVertices);
addProperty(&_poi);
addProperty(&_camera);
}
VirtualMirrorGeometryGenerator::~VirtualMirrorGeometryGenerator() {
}
void VirtualMirrorGeometryGenerator::process(DataContainer& data) {
// mirror normal is given by halfway vector between Camera-Mirror and POI-Mirror:
const tgt::Camera& cam = _camera.getValue();
tgt::vec3 v1 = tgt::normalize(_poi.getValue() - _mirrorCenter.getValue());
tgt::vec3 v2 = tgt::normalize(cam.getPosition() - _mirrorCenter.getValue());
tgt::vec3 n = tgt::normalize(v1 + v2);
// assure that mirror is faced to camera
if (tgt::sign(tgt::dot(cam.getLook(), n)) == 1)
n *= -1.f;
_mirrorNormal.setValue(n);
std::vector<tgt::vec3> vertices;
tgt::vec3 temp = cam.getUpVector();
if(abs(tgt::dot(temp, n) > 0.9f))
temp = tgt::vec3(0.f, 1.f, 0.f);
tgt::vec3 inPlaneA = tgt::normalize(tgt::cross(n, temp)) * 0.5f * _size.getValue();
tgt::vec3 inPlaneB = tgt::normalize(tgt::cross(n, inPlaneA)) * 0.5f * _size.getValue();
const tgt::vec3& base = _mirrorCenter.getValue();
float angle = 2.f * tgt::PIf / static_cast<float>(_numVertices.getValue());
for (int i = 0; i < _numVertices.getValue(); ++i) {
tgt::vec3 dir = tgt::quat::rotate(inPlaneA, angle * static_cast<float>(i), n);
vertices.push_back(tgt::vec3(base + dir));
}
FaceGeometry* mirror = new FaceGeometry(vertices);
data.addData(_mirrorID.getValue(), mirror);
_invalidationLevel.setValid();
}
}
// ================================================================================================
//
// This file is part of the TUMVis Visualization 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
//
// 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.
//
// ================================================================================================
#ifndef VIRTUALMIRRORGEOMETRYGENERATOR_H__
#define VIRTUALMIRRORGEOMETRYGENERATOR_H__
#include <string>
#include "core/classification/abstracttransferfunction.h"
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/cameraproperty.h"
namespace TUMVis {
/**
* Genereates entry-/exit point textures for the given image and camera.
*/
class VirtualMirrorGeometryGenerator : public AbstractProcessor {
public:
/**
* Constructs a new VirtualMirrorGeometryGenerator Processor
**/
VirtualMirrorGeometryGenerator();
/**
* Destructor
**/
virtual ~VirtualMirrorGeometryGenerator();
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "VirtualMirrorGeometryGenerator"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Genereates entry-/exit point textures for the given image and camera."; };
virtual void process(DataContainer& data);
StringProperty _mirrorID; ///< ID for output geometry
Vec3Property _mirrorCenter; ///< position of mirror center
Vec3Property _mirrorNormal; ///< normal of mirror
FloatProperty _size; ///< Mirror size
IntProperty _numVertices; ///< Number of vertices of mirror
Vec3Property _poi; ///< Point of intereset
CameraProperty _camera;
protected:
void updateClipProperties();
clock_t _sourceTimestamp;
static const std::string loggerCat_;
};
}
#endif // VIRTUALMIRRORGEOMETRYGENERATOR_H__
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