Skip to content
Permalink
Browse files

Merge branch 'master' into resurrect_ellipsoids

  • Loading branch information...
tobiasrau committed Nov 8, 2019
2 parents 45d7a42 + 0c12d80 commit aca0ff28482097ae1dc611a55570d532ff3af5b3
Showing with 1,539 additions and 1,564 deletions.
  1. +3 −0 core/Shaders/lightdirectional.glsl
  2. +6 −1 core/include/mmcore/CallGeneric.h
  3. +5 −83 core/include/mmcore/thecam/arcball_manipulator.h
  4. +9 −91 core/include/mmcore/thecam/arcball_manipulator.inl
  5. +109 −0 core/include/mmcore/thecam/orbit_altitude_manipulator.h
  6. +11 −0 core/include/mmcore/thecam/rotate_manipulator.h
  7. +40 −0 core/include/mmcore/thecam/translate_manipulator.h
  8. +16 −71 core/include/mmcore/thecam/{orbital_manipulator.h → turntable_manipulator.h}
  9. +4 −2 core/include/mmcore/view/Camera_2.h
  10. +11 −8 core/include/mmcore/view/View3D_2.h
  11. +2 −2 core/src/view/BoundingBoxRenderer.cpp
  12. +126 −109 core/src/view/View3D_2.cpp
  13. +4 −2 plugins/archvis/src/FEMMaterialDataSource.cpp
  14. +2 −22 plugins/archvis/src/FEMMeshDataSource.cpp
  15. +2 −1 plugins/archvis/src/FEMMeshDataSource.h
  16. +13 −9 plugins/archvis/src/FEMRenderTaskDataSource.cpp
  17. +2 −8 plugins/archvis/src/MSMConvexHullMeshDataSource.cpp
  18. +2 −1 plugins/archvis/src/MSMConvexHullMeshDataSource.h
  19. +3 −3 plugins/archvis/src/MSMRenderTaskDataSource.cpp
  20. +1 −1 plugins/archvis/src/MSMRenderTaskDataSource.h
  21. +133 −48 plugins/gui/src/GUIView.cpp
  22. +15 −0 plugins/gui/src/GUIView.h
  23. +1 −1 plugins/mesh/CMakeLists.txt
  24. +17 −0 plugins/mesh/Shaders/dfr_MeshDebug.btf
  25. +12 −0 plugins/mesh/Shaders/mesh/dfr_mesh_debug_fragment.glsl
  26. +1 −1 plugins/mesh/Shaders/mesh/gltf_example_vertex.glsl
  27. +4 −1 plugins/mesh/Shaders/mesh/mesh_debug_fragment.glsl
  28. +11 −5 plugins/mesh/Shaders/mesh/mesh_debug_vertex.glsl
  29. +5 −9 plugins/mesh/include/mesh/AbstractGPUMeshDataSource.h
  30. +9 −5 plugins/mesh/include/mesh/AbstractGPURenderTaskDataSource.h
  31. +23 −13 plugins/mesh/include/mesh/GPUMaterialCollection.h
  32. +59 −20 plugins/mesh/include/mesh/MeshDataAccessCollection.h
  33. +3 −3 plugins/mesh/src/3DUIRenderTaskDataSource.cpp
  34. +11 −23 plugins/mesh/src/AbstractGPUMeshDataSource.cpp
  35. +77 −31 plugins/mesh/src/AbstractGPURenderTaskDataSource.cpp
  36. +0 −62 plugins/mesh/src/DebugGPUMaterialDataSource.cpp
  37. +0 −73 plugins/mesh/src/DebugGPUMaterialDataSource.h
  38. +0 −46 plugins/mesh/src/DebugGPUMeshDataSource.cpp
  39. +0 −70 plugins/mesh/src/DebugGPUMeshDataSource.h
  40. +0 −101 plugins/mesh/src/DebugGPURenderTaskDataSource.cpp
  41. +0 −68 plugins/mesh/src/DebugGPURenderTaskDataSource.h
  42. +41 −38 plugins/mesh/src/GPUMaterialCollection.cpp
  43. +96 −39 plugins/mesh/src/GPUMeshes.cpp
  44. +2 −2 plugins/mesh/src/GPUMeshes.h
  45. +84 −0 plugins/mesh/src/MeshViewerRenderTasks.cpp
  46. +52 −0 plugins/mesh/src/MeshViewerRenderTasks.h
  47. +9 −5 plugins/mesh/src/RenderMDIMesh.cpp
  48. +72 −63 plugins/mesh/src/WavefrontObjLoader.cpp
  49. +18 −16 plugins/mesh/src/WavefrontObjLoader.h
  50. +168 −27 plugins/mesh/src/gltf/glTFFileLoader.cpp
  51. +87 −86 plugins/mesh/src/gltf/glTFFileLoader.h
  52. +0 −137 plugins/mesh/src/gltf/glTFMeshesDataSource.cpp
  53. +0 −62 plugins/mesh/src/gltf/glTFMeshesDataSource.h
  54. +14 −3 plugins/mesh/src/gltf/glTFRenderTasksDataSource.cpp
  55. +2 −0 plugins/mesh/src/gltf/glTFRenderTasksDataSource.h
  56. +2 −8 plugins/mesh/src/mesh.cpp
  57. +31 −17 plugins/mmstd_moldyn/Shaders/arrow.btf
  58. +4 −4 plugins/mmstd_moldyn/Shaders/sphere/geometry_geometry_mainend.glsl
  59. +6 −0 plugins/mmstd_moldyn/Shaders/sphere/vertex_clipping.glsl
  60. +1 −1 plugins/mmstd_moldyn/Shaders/sphere/vertex_posout.glsl
  61. +85 −52 plugins/mmstd_moldyn/src/rendering/ArrowRenderer.cpp
  62. +5 −5 plugins/mmstd_moldyn/src/rendering/ArrowRenderer.h
  63. +7 −5 plugins/mmstd_moldyn/src/rendering/SphereRenderer.cpp
  64. +1 −0 plugins/mmstd_moldyn/src/rendering/SphereRenderer.h
@@ -1,8 +1,11 @@

// TODO: Implementation is wrong! Does positional Lighting instead of directional lighting!

// ray: the eye to fragment ray vector
// normal: the normal of this fragment
// lightPos: the position of the light source
// color: the base material color

vec3 LocalLighting(const in vec3 ray, const in vec3 normal, const in vec3 lightdir, const in vec3 color) {

vec4 lightparams = vec4(0.2, 0.8, 0.9, 10.0);
@@ -9,6 +9,7 @@
#define CALL_GENERIC_H_INCLUDED

#include "mmcore/AbstractGetDataCall.h"
#include "mmcore/BoundingBoxes_2.h"

namespace megamol {
namespace core {
@@ -29,12 +30,16 @@ struct Spatial3DMetaData {
size_t m_data_hash = 0;
unsigned int m_frame_cnt = 0;
unsigned int m_frame_ID = 0;
megamol::core::BoundingBoxes m_bboxs;
megamol::core::BoundingBoxes_2 m_bboxs;
};

template <typename DataType, typename MetaDataType> class CallGeneric : public Call
{
public:

using data_type = DataType;
using meta_data_type = MetaDataType;

CallGeneric() = default;
~CallGeneric() = default;

@@ -67,7 +67,7 @@ template <class T> class arcball_manipulator : public manipulator_base<T> {
typedef typename maths_type::vector_type vector_type;
typedef typename maths_type::world_type world_type;

arcball_manipulator(const point_type& rotCentre = point_type(), const world_type radius = 1);
arcball_manipulator() = default;

/**
* Finalises the instance.
@@ -81,16 +81,7 @@ template <class T> class arcball_manipulator : public manipulator_base<T> {
* @param x
* @param y
*/
void on_drag(const screen_type x, const screen_type y);

/**
* Report that the mouse pointer has been dragged (moved while the
* designated button was down) to the specified screen coordinates.
*
* @param x
* @param y
*/
void on_drag_change_radius(const screen_type x, const screen_type y);
void on_drag(const screen_type x, const screen_type y, const point_type& rotCentre);

/**
* Report that dragging begun (mouse for dragging button is down)
@@ -99,84 +90,15 @@ template <class T> class arcball_manipulator : public manipulator_base<T> {
* @param x
* @param y
*/
void on_drag_start(const screen_type x, const screen_type y);
void setActive(const screen_type x, const screen_type y);

/**
* Report that dragging ended (mouse button was released).
*/
inline void on_drag_stop(void) { this->end_manipulation(); }

/**
* Answer the radius of the arcball.
*
* @return The radius of the arcball.
*/
inline world_type radius(void) const { return this->ballRadius; }

/**
* Gets the centre of rotation (usually the centre of the object to
* rotate the camera around).
*
* @returns The centre of rotation.
*/
inline const point_type& rotation_centre(void) const { return this->rotCentre; }

/**
* Changes the radius of the arcball.
*
* This method must not be called while the arcball is begin dragged.
*
* @param radius The new radius of the arcball.
*/
inline void set_radius(const world_type radius) {
THE_ASSERT(!this->manipulating());
this->ballRadius = radius;
}

/**
* Changes the centre of rotation.
*
* This method must not be called while the arcball is begin dragged.
*
* @param rotCentre The new centre of rotation.
*/
inline void set_rotation_centre(const point_type& rotCentre) {
THE_ASSERT(!this->manipulating());
this->rotCentre = rotCentre;
}
inline void setInactive(void) { this->end_manipulation(); }

private:
/**
* Convert screen point to a point on the arcball.
*
* @param sx The absicssa of the current mouse position.
* @param sy The ordinate of the current mouse position.
*
* @return The normalised vector from the centre of the arcball to the
* point on the arcball represented by the given screen
* coordinates.
*/
vector_type mapToSphere(const screen_type sx, const screen_type sy) const;

/** The radius of the arcball .*/
world_type ballRadius;

/** The latest point on the arcball. */
vector_type currentVector;

/** The centre of rotation (target point of the camera). */
point_type rotCentre;

vector_type startPos;

/** The camera rotation quaterion when the drag interaction started. */
quaternion_type invStartRot;

quaternion_type startRot;

/** The point on the arcball when the drag interaction started. */
vector_type startVector;


/** The x-coordinate of the last clicked screen position */
screen_type lastSx;

@@ -29,13 +29,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/*
* megamol::core::thecam::arcball_manipulator<T>::arcball_manipulator
*/
template <class T>
megamol::core::thecam::arcball_manipulator<T>::arcball_manipulator(const point_type& rotCentre, const world_type radius)
: ballRadius(radius), rotCentre(rotCentre) {}


/*
* megamol::core::thecam::arcball_manipulator<T>::~arcball_manipulator
@@ -47,24 +40,13 @@ template <class T> megamol::core::thecam::arcball_manipulator<T>::~arcball_manip
* megamol::core::thecam::arcball_manipulator<T>::on_drag
*/
template <class T>
void megamol::core::thecam::arcball_manipulator<T>::on_drag(const screen_type x, const screen_type y) {
void megamol::core::thecam::arcball_manipulator<T>::on_drag(
const screen_type x, const screen_type y, const point_type& rotCentre) {
if (this->manipulating() && this->enabled()) {
auto cam = this->camera();
THE_ASSERT(cam != nullptr);

if (this->lastSx != x || this->lastSy != y) {
// this->currentVector = this->mapToSphere(x, y);
//
// // Compute angle and rotation quaternion.
// quaternion_type quat;
// thecam::math::set_from_vectors(quat, startVector, currentVector);
//
// auto const qstar = this->startRot * quat;
// auto pos =
// thecam::math::rotate(this->startPos - this->rotCentre, qstar * this->invStartRot) + this->rotCentre;
// cam->position(pos);
// cam->orientation(qstar);

screen_type dx = x - lastSx;
screen_type dy = y - lastSy;

@@ -74,7 +56,7 @@ void megamol::core::thecam::arcball_manipulator<T>::on_drag(const screen_type x,

// rotate horizontally
thecam::math::set_from_angle_axis(rot_pitch, dx * (3.14159265f / 180.0f), cam->up_vector());
cam->orientation(rot_pitch * this->startRot);
cam->orientation(rot_pitch * this->camera()->orientation());
auto updated_orientation = cam->orientation();

// get cam right vector after horizontal rotation to rotate vertically
@@ -83,7 +65,7 @@ void megamol::core::thecam::arcball_manipulator<T>::on_drag(const screen_type x,
cam->orientation(rot_yaw * updated_orientation);

// transform s.t. rotation center is origin
auto shifted_pos = this->startPos - this->rotCentre;
auto shifted_pos = this->camera()->eye_position() - rotCentre;
quaternion_type pos_quat(shifted_pos.x(), shifted_pos.y(), shifted_pos.z(), 0.0f);
// move camera based on applied rotation
auto rot_pitch_conj = thecam::math::conjugate(rot_pitch);
@@ -93,92 +75,28 @@ void megamol::core::thecam::arcball_manipulator<T>::on_drag(const screen_type x,

// transform back
cam->position(point_type(
pos_quat.x() + this->rotCentre.x(),
pos_quat.y() + this->rotCentre.y(),
pos_quat.z() + this->rotCentre.z(),
pos_quat.x() + rotCentre.x(),
pos_quat.y() + rotCentre.y(),
pos_quat.z() + rotCentre.z(),
1.0f)
);

// update reference values for next call to on_drag (that happens without drag start event)
this->startPos = this->camera()->eye_position();
this->startRot = this->camera()->orientation();
this->lastSx = x;
this->lastSy = y;
}
}
}

template <class T>
inline void megamol::core::thecam::arcball_manipulator<T>::on_drag_change_radius(
const screen_type x, const screen_type y) {

if (this->manipulating() && this->enabled()) {
auto cam = this->camera();
THE_ASSERT(cam != nullptr);

if (this->lastSy != y) {

screen_type dy = y - lastSy;

auto cam_pos = cam->eye_position();

auto v = thecam::math::normalise(this->rotCentre - cam_pos);

cam->position(cam_pos - (v * dy * (this->ballRadius / 500.0f)));

this->ballRadius = std::abs(thecam::math::length(this->rotCentre - cam->eye_position()));
}

this->lastSx = x;
this->lastSy = y;
}

}


/*
* megamol::core::thecam::arcball_manipulator<T>::on_drag_start
*/
template <class T>
void megamol::core::thecam::arcball_manipulator<T>::on_drag_start(const screen_type x, const screen_type y) {
void megamol::core::thecam::arcball_manipulator<T>::setActive(const screen_type x, const screen_type y) {
if (!this->manipulating() && this->enabled()) {
this->begin_manipulation();
this->startPos = this->camera()->eye_position();
this->invStartRot = math::invert(this->camera()->orientation());
this->startRot = this->camera()->orientation();
this->startVector = this->mapToSphere(x, y);
this->lastSx = x;
this->lastSy = y;
}
}


/*
* megamol::core::thecam::arcball_manipulator<T>::mapToSphere
*/
template <class T>
typename megamol::core::thecam::arcball_manipulator<T>::vector_type
megamol::core::thecam::arcball_manipulator<T>::mapToSphere(const screen_type sx, const screen_type sy) const {
THE_ASSERT(this->camera() != nullptr);
auto wndSize = this->camera()->resolution_gate();
auto halfHeight = wndSize.height() / static_cast<world_type>(2);
auto halfWidth = wndSize.width() / static_cast<world_type>(2);

// Scale to screen
auto bx = (sx - halfWidth) / (this->ballRadius * halfWidth);
auto by = (sy - halfHeight) / (this->ballRadius * halfHeight);
auto bz = static_cast<world_type>(0);

auto mag = bx * bx + by * by;

if (mag > 1) {
// Point is mapped outside of the sphere: project on sphere.
auto scale = 1.0f / std::sqrt(mag);
bx *= scale;
by *= scale;
} else {
// Point is mapped inside the sphere.
bz = std::sqrt(1.0f - mag);
}
return typename maths_type::vector_type(bx, by, bz, static_cast<world_type>(0));
}
}

0 comments on commit aca0ff2

Please sign in to comment.
You can’t perform that action at this time.