Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

Commit 3048e738 authored by Jakob Weiss's avatar Jakob Weiss

Bugfix: ProxyGeometry generation for arbitrary poses

The ProxyGeometryGenerator now correctly generates oriented geometry for
volumes with arbitrary poses by directly using the TextureToWorld matrix
to transform the bounding box instead of just transforming the bounds.
parent af621107
......@@ -90,7 +90,7 @@ namespace campvis {
}
std::unique_ptr<MeshGeometry> GeometryDataFactory::createCube(const cgt::Bounds& bounds, const cgt::Bounds& texBounds) {
std::unique_ptr<MeshGeometry> GeometryDataFactory::createCube(const cgt::Bounds& bounds, const cgt::Bounds& texBounds, const cgt::mat4& trans/* = cgt::mat4::identit*/) {
const cgt::vec3& llf = bounds.getLLF();
const cgt::vec3& urb = bounds.getURB();
const cgt::vec3& tLlf = texBounds.getLLF();
......@@ -102,78 +102,78 @@ namespace campvis {
// front
texCoords.push_back(cgt::vec3(tLlf.x, tUrb.y, tLlf.z));
vertices.push_back(cgt::vec3(llf.x, urb.y, llf.z));
vertices.push_back(trans*cgt::vec3(llf.x, urb.y, llf.z));
texCoords.push_back(cgt::vec3(tUrb.x, tUrb.y, tLlf.z));
vertices.push_back(cgt::vec3(urb.x, urb.y, llf.z));
vertices.push_back(trans*cgt::vec3(urb.x, urb.y, llf.z));
texCoords.push_back(cgt::vec3(tUrb.x, tLlf.y, tLlf.z));
vertices.push_back(cgt::vec3(urb.x, llf.y, llf.z));
vertices.push_back(trans*cgt::vec3(urb.x, llf.y, llf.z));
texCoords.push_back(cgt::vec3(tLlf.x, tLlf.y, tLlf.z));
vertices.push_back(cgt::vec3(llf.x, llf.y, llf.z));
vertices.push_back(trans*cgt::vec3(llf.x, llf.y, llf.z));
faces.push_back(FaceGeometry(vertices, texCoords, std::vector<cgt::vec4>(), std::vector<cgt::vec3>(4, cgt::vec3(0.f, 0.f, -1.f))));
vertices.clear();
texCoords.clear();
// right
texCoords.push_back(cgt::vec3(tUrb.x, tUrb.y, tLlf.z));
vertices.push_back(cgt::vec3(urb.x, urb.y, llf.z));
vertices.push_back(trans*cgt::vec3(urb.x, urb.y, llf.z));
texCoords.push_back(cgt::vec3(tUrb.x, tUrb.y, tUrb.z));
vertices.push_back(cgt::vec3(urb.x, urb.y, urb.z));
vertices.push_back(trans*cgt::vec3(urb.x, urb.y, urb.z));
texCoords.push_back(cgt::vec3(tUrb.x, tLlf.y, tUrb.z));
vertices.push_back(cgt::vec3(urb.x, llf.y, urb.z));
vertices.push_back(trans*cgt::vec3(urb.x, llf.y, urb.z));
texCoords.push_back(cgt::vec3(tUrb.x, tLlf.y, tLlf.z));
vertices.push_back(cgt::vec3(urb.x, llf.y, llf.z));
vertices.push_back(trans*cgt::vec3(urb.x, llf.y, llf.z));
faces.push_back(FaceGeometry(vertices, texCoords, std::vector<cgt::vec4>(), std::vector<cgt::vec3>(4, cgt::vec3(1.f, 0.f, 0.f))));
vertices.clear();
texCoords.clear();
// top
texCoords.push_back(cgt::vec3(tLlf.x, tUrb.y, tUrb.z));
vertices.push_back(cgt::vec3(llf.x, urb.y, urb.z));
vertices.push_back(trans*cgt::vec3(llf.x, urb.y, urb.z));
texCoords.push_back(cgt::vec3(tUrb.x, tUrb.y, tUrb.z));
vertices.push_back(cgt::vec3(urb.x, urb.y, urb.z));
vertices.push_back(trans*cgt::vec3(urb.x, urb.y, urb.z));
texCoords.push_back(cgt::vec3(tUrb.x, tUrb.y, tLlf.z));
vertices.push_back(cgt::vec3(urb.x, urb.y, llf.z));
vertices.push_back(trans*cgt::vec3(urb.x, urb.y, llf.z));
texCoords.push_back(cgt::vec3(tLlf.x, tUrb.y, tLlf.z));
vertices.push_back(cgt::vec3(llf.x, urb.y, llf.z));
vertices.push_back(trans*cgt::vec3(llf.x, urb.y, llf.z));
faces.push_back(FaceGeometry(vertices, texCoords, std::vector<cgt::vec4>(), std::vector<cgt::vec3>(4, cgt::vec3(0.f, 1.f, 0.f))));
vertices.clear();
texCoords.clear();
// left
texCoords.push_back(cgt::vec3(tLlf.x, tUrb.y, tUrb.z));
vertices.push_back(cgt::vec3(llf.x, urb.y, urb.z));
vertices.push_back(trans*cgt::vec3(llf.x, urb.y, urb.z));
texCoords.push_back(cgt::vec3(tLlf.x, tUrb.y, tLlf.z));
vertices.push_back(cgt::vec3(llf.x, urb.y, llf.z));
vertices.push_back(trans*cgt::vec3(llf.x, urb.y, llf.z));
texCoords.push_back(cgt::vec3(tLlf.x, tLlf.y, tLlf.z));
vertices.push_back(cgt::vec3(llf.x, llf.y, llf.z));
vertices.push_back(trans*cgt::vec3(llf.x, llf.y, llf.z));
texCoords.push_back(cgt::vec3(tLlf.x, tLlf.y, tUrb.z));
vertices.push_back(cgt::vec3(llf.x, llf.y, urb.z));
vertices.push_back(trans*cgt::vec3(llf.x, llf.y, urb.z));
faces.push_back(FaceGeometry(vertices, texCoords, std::vector<cgt::vec4>(), std::vector<cgt::vec3>(4, cgt::vec3(-1.f, 0.f, 0.f))));
vertices.clear();
texCoords.clear();
// bottom
texCoords.push_back(cgt::vec3(tLlf.x, tLlf.y, tLlf.z));
vertices.push_back(cgt::vec3(llf.x, llf.y, llf.z));
vertices.push_back(trans*cgt::vec3(llf.x, llf.y, llf.z));
texCoords.push_back(cgt::vec3(tUrb.x, tLlf.y, tLlf.z));
vertices.push_back(cgt::vec3(urb.x, llf.y, llf.z));
vertices.push_back(trans*cgt::vec3(urb.x, llf.y, llf.z));
texCoords.push_back(cgt::vec3(tUrb.x, tLlf.y, tUrb.z));
vertices.push_back(cgt::vec3(urb.x, llf.y, urb.z));
vertices.push_back(trans*cgt::vec3(urb.x, llf.y, urb.z));
texCoords.push_back(cgt::vec3(tLlf.x, tLlf.y, tUrb.z));
vertices.push_back(cgt::vec3(llf.x, llf.y, urb.z));
vertices.push_back(trans*cgt::vec3(llf.x, llf.y, urb.z));
faces.push_back(FaceGeometry(vertices, texCoords, std::vector<cgt::vec4>(), std::vector<cgt::vec3>(4, cgt::vec3(0.f, -1.f, 0.f))));
vertices.clear();
texCoords.clear();
// back
texCoords.push_back(cgt::vec3(tUrb.x, tUrb.y, tUrb.z));
vertices.push_back(cgt::vec3(urb.x, urb.y, urb.z));
vertices.push_back(trans*cgt::vec3(urb.x, urb.y, urb.z));
texCoords.push_back(cgt::vec3(tLlf.x, tUrb.y, tUrb.z));
vertices.push_back(cgt::vec3(llf.x, urb.y, urb.z));
vertices.push_back(trans*cgt::vec3(llf.x, urb.y, urb.z));
texCoords.push_back(cgt::vec3(tLlf.x, tLlf.y, tUrb.z));
vertices.push_back(cgt::vec3(llf.x, llf.y, urb.z));
vertices.push_back(trans*cgt::vec3(llf.x, llf.y, urb.z));
texCoords.push_back(cgt::vec3(tUrb.x, tLlf.y, tUrb.z));
vertices.push_back(cgt::vec3(urb.x, llf.y, urb.z));
vertices.push_back(trans*cgt::vec3(urb.x, llf.y, urb.z));
faces.push_back(FaceGeometry(vertices, texCoords, std::vector<cgt::vec4>(), std::vector<cgt::vec3>(4, cgt::vec3(0.f, 0.f, 1.f))));
vertices.clear();
texCoords.clear();
......
......@@ -71,7 +71,7 @@ namespace campvis {
* \param texBounds texture coordinates at the cube bounds
* \return A MeshGeometry building a cube with the given bounds and texture coordinates.
*/
static std::unique_ptr<MeshGeometry> createCube(const cgt::Bounds& bounds, const cgt::Bounds& texBounds);
static std::unique_ptr<MeshGeometry> createCube(const cgt::Bounds& bounds, const cgt::Bounds& texBounds, const cgt::mat4& trans = cgt::mat4::identity);
/**
* Creates an MultiIndexedGeometry storing the famous Utah teapot.
......
......@@ -62,16 +62,8 @@ namespace campvis {
if (img != 0) {
if (img->getDimensionality() == 3) {
cgt::Bounds volumeExtent = img->getWorldBounds(cgt::svec3(p_clipX.getValue().x, p_clipY.getValue().x, p_clipZ.getValue().x), cgt::svec3(p_clipX.getValue().y, p_clipY.getValue().y, p_clipZ.getValue().y));
cgt::vec3 numSlices = cgt::vec3(img->getSize());
cgt::vec3 texLLF(static_cast<float>(p_clipX.getValue().x), static_cast<float>(p_clipY.getValue().x), static_cast<float>(p_clipZ.getValue().x));
texLLF /= numSlices;
cgt::vec3 texURB(static_cast<float>(p_clipX.getValue().y), static_cast<float>(p_clipY.getValue().y), static_cast<float>(p_clipZ.getValue().y));
texURB /= numSlices;
std::unique_ptr<MeshGeometry> cube = GeometryDataFactory::createCube(volumeExtent, cgt::Bounds(texLLF, texURB));
std::unique_ptr<MeshGeometry> cube = GeometryDataFactory::createCube(cgt::Bounds(cgt::vec3(0.f), cgt::vec3(1.f)), cgt::Bounds(cgt::vec3(0.f), cgt::vec3(1.f))
, img->getMappingInformation().getTextureToWorldMatrix());
data.addData(p_geometryID.getValue(), cube.release());
}
else {
......
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