Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cinematic fixes for new camera #1

Merged
merged 30 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e9f9c1a
Merge remote-tracking branch 'invor/a_camera_reborn' into a_camera_re…
braunms Aug 9, 2021
c0fede2
Merge remote-tracking branch 'invor/a_camera_reborn' into a_camera_re…
braunms Aug 9, 2021
3cf2580
added new cam params to keyframekeeper, clang formatting
braunms Aug 9, 2021
944d3ee
Merge remote-tracking branch 'invor/a_camera_reborn' into a_camera_re…
braunms Aug 10, 2021
a43ac9f
cinematic fixes for new camera
braunms Aug 10, 2021
b85d619
sorted headers in cineamtic plugin
braunms Aug 10, 2021
a8ff356
further cinematic fixes ...
braunms Aug 10, 2021
68fbe7e
...
braunms Aug 11, 2021
09dcb96
Merge remote-tracking branch 'upstream/master' into a_camera_reborn
braunms Aug 11, 2021
2b9c961
Merge remote-tracking branch 'invor/a_camera_reborn' into a_camera_re…
braunms Aug 11, 2021
1ebb21e
viewport and bbox fix for replacementrenderer and overlayrenderer
braunms Aug 11, 2021
768b7f3
Merge remote-tracking branch 'upstream/master' into a_camera_reborn
braunms Aug 11, 2021
b1c2d59
gui merge
braunms Aug 11, 2021
eb43af9
Merge remote-tracking branch 'invor/a_camera_reborn' into a_camera_re…
braunms Aug 11, 2021
f7875b8
Merge remote-tracking branch 'invor/a_camera_reborn' into a_camera_re…
braunms Aug 11, 2021
b69cd51
...
braunms Aug 11, 2021
c8674f4
cinematic, cont.
braunms Aug 12, 2021
b75dcc7
gui module header and parameter visibility fix
braunms Aug 12, 2021
54e66e5
Merge remote-tracking branch 'upstream/master' into a_camera_reborn
braunms Aug 12, 2021
ba85187
removed second calling of GetExtends in BoundingBoxRenderer and Repla…
braunms Aug 12, 2021
758217d
Merge remote-tracking branch 'invor/a_camera_reborn' into a_camera_re…
braunms Aug 12, 2021
577f7c7
non-throwing string to int conversion in gui, cinematic stuff ...
braunms Aug 12, 2021
594558b
cinematic, cont ...
braunms Aug 12, 2021
ec95951
cinematic: camera requires right, up and view vectors and orientation…
braunms Aug 13, 2021
425a004
...
braunms Aug 13, 2021
1cfc67f
cleanup
braunms Aug 13, 2021
972c265
Merge branch 'a_camera_reborn' into a_camera_reborn
moritz-h Aug 13, 2021
db87fc8
Merge remote-tracking branch 'invor/a_camera_reborn' into a_camera_re…
braunms Aug 13, 2021
98f8b37
Merge remote-tracking branch 'origin/a_camera_reborn' into a_camera_r…
braunms Aug 13, 2021
5eefeef
merge
braunms Aug 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions core/include/mmcore/utility/JSONHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,23 @@ namespace utility {
node_name.c_str(), __FILE__, __FUNCTION__, __LINE__);
return false;
}
}
else if constexpr (std::is_same_v<T, float> || std::is_same_v<T, int>) {
} else if constexpr (std::is_same_v<T, float> || std::is_same_v<T, int>) {
if (json_value[i].is_number()) {
out_value[i] = json_value[i];
}
else {
megamol::core::utility::log::Log::DefaultLog.WriteError(
"JSON ERROR - Couldn't read 'float' or 'int' value from json node '%s'. [%s, %s, line "
"%d]\n",
node_name.c_str(), __FILE__, __FUNCTION__, __LINE__);
return false;
} else {
bool nan_case = false;
if (json_value[i].is_string()) {
if (json_value[i] == "null") {
out_value[i] = std::numeric_limits<T>::quiet_NaN();
nan_case = true;
}
}
if (!nan_case) {
megamol::core::utility::log::Log::DefaultLog.WriteError(
"JSON ERROR - Couldn't read 'float' or 'int' value from json node '%s'. [%s, %s, line %d]\n",
node_name.c_str(), __FILE__, __FUNCTION__, __LINE__);
return false;
}
}
}
else {
Expand Down Expand Up @@ -111,10 +117,20 @@ namespace utility {
json_value.get_to((*out_value));
}
else {
megamol::core::utility::log::Log::DefaultLog.WriteError(
"JSON ERROR - Couldn't read 'float' or 'int' value from json node '%s'. [%s, %s, line %d]\n",
node_name.c_str(), __FILE__, __FUNCTION__, __LINE__);
return false;
bool nan_case = false;
if (json_value.is_string()) {
if (json_value == "null") {
(*out_value) = std::numeric_limits<T>::quiet_NaN();
nan_case = true;
}
}
if (!nan_case) {
megamol::core::utility::log::Log::DefaultLog.WriteError(
"JSON ERROR - Couldn't read 'float' or 'int' value from json node '%s'. [%s, %s, line "
"%d]\n",
node_name.c_str(), __FILE__, __FUNCTION__, __LINE__);
return false;
}
}
}
else {
Expand Down
24 changes: 0 additions & 24 deletions core/include/mmcore/utility/RenderUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "mmcore/misc/PngBitmapCodec.h"
#include "mmcore/utility/SDFFont.h"
#include "mmcore/utility/ShaderSourceFactory.h"
#include "mmcore/view/Camera.h"


namespace megamol::core::utility {
Expand All @@ -50,29 +49,6 @@ static inline glm::vec3 vislib_point_to_glm(vislib::math::Point<float, 3> v) {
}


// #### Utility quaternion functions ################################### //

static inline glm::quat quaternion_from_vectors(glm::vec3 view_vector, glm::vec3 up_vector) {

glm::vec3 view = view_vector * glm::vec3(-1.0f, -1.0f, -1.0f); /// why?
glm::vec3 right = glm::cross(up_vector, view);
glm::vec3 up = glm::cross(view, right);

glm::vec3 norm_right = glm::normalize(right);
glm::vec3 norm_up = glm::normalize(up);
glm::vec3 norm_view = glm::normalize(view);

glm::mat3 matrix_basis;
matrix_basis[0] = norm_right;
matrix_basis[1] = norm_up;
matrix_basis[2] = norm_view;

glm::quat orientation_quat = glm::quat_cast(matrix_basis);

return orientation_quat; // glm::normalize(orientation_quat);
}


// #### Utility transformation functions ################################### //

static inline glm::vec3 worldspace_to_screenspace(
Expand Down
9 changes: 4 additions & 5 deletions core/include/mmcore/utility/SDFFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
#include "mmcore/utility/RenderUtils.h"
#include "vislib/graphics/gl/ShaderSource.h"
#include "vislib/graphics/gl/GLSLShader.h"
#include "glm/glm.hpp"
#define _USE_MATH_DEFINES
#include <math.h>
#include <fstream>

#include <glm/glm.hpp>


namespace megamol {
Expand Down Expand Up @@ -464,8 +462,9 @@ namespace utility {
* @param a The rotation angle in degrees.
* @param v The rotation axis.
*/
/// TODO XXX FIXME Currently not working ...
inline void SetRotation(float a, glm::vec3 v) {
this->rotation = glm::quat((a * (float)M_PI / 180.0f), v.x, v.y, v.z);
this->rotation = glm::quat(glm::radians(a), v.x, v.y, v.z);
}

inline void SetRotation(float a, float x, float y, float z) {
Expand Down
3 changes: 3 additions & 0 deletions core/include/mmcore/view/BoundingBoxRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class MEGAMOLCORE_API BoundingBoxRenderer : public view::RendererModule<CallRend

/** Shader program for a cube */
vislib::graphics::gl::GLSLShader cubeShader;

/** Bounding Boxes */
megamol::core::BoundingBoxes_2 boundingBoxes;
};
} // namespace view
} // namespace core
Expand Down
16 changes: 9 additions & 7 deletions core/src/utility/SDFFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

#include "mmcore/utility/SDFFont.h"
#include "mmcore/utility/ResourceWrapper.h"
#include "glm/gtx/quaternion.hpp"
#include "glm/gtc/type_ptr.hpp"

#include <fstream>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtc/type_ptr.hpp>


using namespace megamol::core::utility;
Expand Down Expand Up @@ -635,11 +637,11 @@ void SDFFont::drawGlyphs(const glm::mat4& mvm, const glm::mat4& pm, const float
glm::vec4 p3(tmpP23x, tmpP03y, gz, 0.0f);

/// Apply rotation
glm::mat4 rotMat = glm::toMat4(this->rotation);
p0 = rotMat * p0;
p1 = rotMat * p1;
p2 = rotMat * p2;
p3 = rotMat * p3;
glm::mat4 rotation_matrix = glm::toMat4(this->rotation);
p0 = rotation_matrix * p0;
p1 = rotation_matrix * p1;
p2 = rotation_matrix * p2;
p3 = rotation_matrix * p3;

// Set position data:
posData[glyphIter * 18 + 0] = p0.x;
Expand Down
30 changes: 15 additions & 15 deletions core/src/view/BoundingBoxRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ BoundingBoxRenderer::BoundingBoxRenderer(void)
, viewCubeSizeSlot("viewCubeSize", "Size of the view cube")
, vbo(0)
, ibo(0)
, va(0) {
, va(0)
, boundingBoxes () {

this->enableBoundingBoxSlot.SetParameter(new param::BoolParam(true));
this->MakeSlotAvailable(&this->enableBoundingBoxSlot);
Expand Down Expand Up @@ -162,16 +163,19 @@ void BoundingBoxRenderer::release(void) {
* BoundingBoxRenderer::GetExtents
*/
bool BoundingBoxRenderer::GetExtents(CallRender3DGL& call) {

CallRender3DGL* chainedCall = this->chainRenderSlot.CallAs<CallRender3DGL>();
if (chainedCall == nullptr) {
megamol::core::utility::log::Log::DefaultLog.WriteError(
"The BoundingBoxRenderer does not work without a renderer attached to its right");
return false;
if (chainedCall != nullptr) {
*chainedCall = call;
if ((*chainedCall)(view::AbstractCallRender::FnGetExtents)) {
call = *chainedCall;
this->boundingBoxes = call.AccessBoundingBoxes();
return true;
}
}
*chainedCall = call;
bool retVal = (*chainedCall)(view::AbstractCallRender::FnGetExtents);
call = *chainedCall;
return retVal;
megamol::core::utility::log::Log::DefaultLog.WriteError(
"The BoundingBoxRenderer does not work without a renderer attached to its right");
return false;
}

/*
Expand All @@ -192,19 +196,15 @@ bool BoundingBoxRenderer::Render(CallRender3DGL& call) {
"The BoundingBoxRenderer does not work without a renderer attached to its right");
return false;
}
*chainedCall = call;
bool retVal = (*chainedCall)(view::AbstractCallRender::FnGetExtents);
call = *chainedCall;

auto boundingBoxes = chainedCall->AccessBoundingBoxes();
auto smoothLines = this->smoothLineSlot.Param<param::BoolParam>()->Value();

lhsFBO->bind();
glViewport(0, 0, lhsFBO->getWidth(), lhsFBO->getHeight());

bool renderRes = true;
if (this->enableBoundingBoxSlot.Param<param::BoolParam>()->Value()) {
renderRes &= this->RenderBoundingBoxBack(mvp, boundingBoxes, smoothLines);
renderRes &= this->RenderBoundingBoxBack(mvp, this->boundingBoxes, smoothLines);
}

//glBindFramebuffer(GL_FRAMEBUFFER, 0);
Expand All @@ -216,7 +216,7 @@ bool BoundingBoxRenderer::Render(CallRender3DGL& call) {
glViewport(0, 0, lhsFBO->getWidth(), lhsFBO->getHeight());

if (this->enableBoundingBoxSlot.Param<param::BoolParam>()->Value()) {
renderRes &= this->RenderBoundingBoxFront(mvp, boundingBoxes, smoothLines);
renderRes &= this->RenderBoundingBoxFront(mvp, this->boundingBoxes, smoothLines);
}
if (this->enableViewCubeSlot.Param<param::BoolParam>()->Value()) {
renderRes &= this->RenderViewCube(call);
Expand Down
4 changes: 3 additions & 1 deletion frontend/main/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "ImagePresentation_Service.hpp"
#include "Remote_Service.hpp"

#include <glad/glad.h> /// XXX see temporary fix below


static void log(std::string const& text) {
const std::string msg = "Main: " + text;
Expand Down Expand Up @@ -218,7 +220,7 @@ int main(const int argc, const char** argv) {

imagepresentation_service.RenderNextFrame(); // executes graph views, those digest input events like keyboard/mouse, then render

// temporary fix to make sure that everything that happens post-draw ends up in default window fbo...
/// XXX temporary fix to make sure that everything that happens post-draw ends up in default window fbo...
glBindFramebuffer(GL_FRAMEBUFFER, 0);
services.postGraphRender(); // render GUI, glfw swap buffers, stop frame timer
}
Expand Down
19 changes: 13 additions & 6 deletions frontend/services/gui/src/GUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,13 @@ bool GUIManager::PostDraw() {

// Draw global parameter widgets -------------------------------------------
if (auto graph_ptr = this->win_configurator_ptr->GetGraphCollection().GetRunningGraph()) {

/// ! Only enabled in second frame if interaction objects are added during first frame !
this->picking_buffer.EnableInteraction(glm::vec2(io.DisplaySize.x, io.DisplaySize.y));

graph_ptr->DrawGlobalParameterWidgets(
this->picking_buffer, this->win_collection.GetWindow<TransferFunctionEditor>());

this->picking_buffer.DisableInteraction();
}

Expand All @@ -411,9 +414,12 @@ bool GUIManager::PostDraw() {
// Render the current ImGui frame ------------------------------------------
glViewport(0, 0, static_cast<GLsizei>(io.DisplaySize.x), static_cast<GLsizei>(io.DisplaySize.y));
ImGui::Render();
draw_data = ImGui::GetDrawData();
DrawUiToScreen();
// ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
this->draw_data = ImGui::GetDrawData();

/// XXX Actual rendering of GUI is done in ImagePresentation_Service
/// XXX Other OpenGL rendering of GUI is currently omitted (e.g. ViewCube)
/// DrawUiToScreen();
/// ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

// Reset all hotkeys ------------------------------------------------------
for (auto& hotkey : this->hotkeys) {
Expand Down Expand Up @@ -1829,9 +1835,10 @@ bool megamol::gui::GUIManager::create_unique_screenshot_filename(std::string& in
auto separator_index = filename.find_last_of(id_separator);
if (separator_index != std::string::npos) {
auto last_id_str = filename.substr(separator_index + 1);
try {
this->gui_state.screenshot_filepath_id = std::stoi(last_id_str);
} catch (...) { new_separator = true; }
std::istringstream(last_id_str) >> this->gui_state.screenshot_filepath_id; // 0 if failed
if (this->gui_state.screenshot_filepath_id = 0) {
new_separator = true;
}
this->gui_state.screenshot_filepath_id++;
if (new_separator) {
ret_filepath =
Expand Down
1 change: 1 addition & 0 deletions frontend/services/gui/src/GUI_Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ namespace frontend {


void GUI_Service::resource_provide_gui_render() {

if (this->m_gui != nullptr) {
this->m_gui->DrawUiToScreen();
}
Expand Down
31 changes: 14 additions & 17 deletions frontend/services/gui/src/graph/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,8 +1817,8 @@ void megamol::gui::Graph::Draw(GraphState_t& state) {
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove;
if (ImGui::BeginPopup(pop_up_id.c_str(), popup_flags)) {
// Draw parameters
selected_mod_ptr->GUIParameterGroups().Draw(selected_mod_ptr->Parameters(), "", false, false,
Parameter::WidgetScope::LOCAL, nullptr, GUI_INVALID_ID, nullptr);
selected_mod_ptr->DrawParameters(
"", false, false, Parameter::WidgetScope::LOCAL, nullptr, GUI_INVALID_ID, nullptr);

ImVec2 popup_pos = ImGui::GetWindowPos();
ImVec2 popup_size = ImGui::GetWindowSize();
Expand Down Expand Up @@ -1874,8 +1874,8 @@ void Graph::DrawGlobalParameterWidgets(
megamol::core::utility::PickingBuffer& picking_buffer, std::shared_ptr<TransferFunctionEditor> win_tfeditor_ptr) {

for (auto& module_ptr : this->Modules()) {
module_ptr->GUIParameterGroups().Draw(module_ptr->Parameters(), "", false, false,
Parameter::WidgetScope::GLOBAL, win_tfeditor_ptr, GUI_INVALID_ID, &picking_buffer);
module_ptr->DrawParameters(
"", false, false, Parameter::WidgetScope::GLOBAL, win_tfeditor_ptr, GUI_INVALID_ID, &picking_buffer);
}
}

Expand Down Expand Up @@ -2357,7 +2357,7 @@ void megamol::gui::Graph::draw_parameters(float graph_width) {

// Draw parameters
if (module_header_open) {
module_ptr->GUIParameterGroups().Draw(module_ptr->Parameters(), search_string,
module_ptr->DrawParameters(search_string,
this->gui_graph_state.interact.parameters_extended_mode, true,
Parameter::WidgetScope::LOCAL, nullptr, GUI_INVALID_ID, nullptr);
}
Expand Down Expand Up @@ -2960,10 +2960,9 @@ std::string megamol::gui::Graph::generate_unique_group_name() const {
for (auto& group : this->groups) {
if (group->Name().find(new_name_prefix) == 0) {
std::string int_postfix = group->Name().substr(new_name_prefix.length());
try {
int last_id = std::stoi(int_postfix);
new_name_id = std::max(new_name_id, last_id);
} catch (...) {}
int last_id = 0;
std::istringstream(int_postfix) >> last_id; // 0 if failed
new_name_id = std::max(new_name_id, last_id);
}
}
return std::string(new_name_prefix + std::to_string(new_name_id + 1));
Expand All @@ -2977,10 +2976,9 @@ std::string megamol::gui::Graph::generate_unique_module_name(const std::string&
for (auto& mod : this->modules) {
if (mod->Name().find(new_name_prefix) == 0) {
std::string int_postfix = mod->Name().substr(new_name_prefix.length());
try {
int last_id = std::stoi(int_postfix);
new_name_id = std::max(new_name_id, last_id);
} catch (...) {}
int last_id = 0;
std::istringstream(int_postfix) >> last_id; // 0 if failed
new_name_id = std::max(new_name_id, last_id);
}
}
return std::string(new_name_prefix + std::to_string(new_name_id + 1));
Expand All @@ -2994,10 +2992,9 @@ std::string megamol::gui::Graph::GenerateUniqueGraphEntryName() {
for (auto& module_ptr : this->modules) {
if (module_ptr->GraphEntryName().find(new_name_prefix) == 0) {
std::string int_postfix = module_ptr->GraphEntryName().substr(new_name_prefix.length());
try {
int last_id = std::stoi(int_postfix);
new_name_id = std::max(new_name_id, last_id);
} catch (...) {}
int last_id = 0;
std::istringstream(int_postfix) >> last_id; // 0 if failed
new_name_id = std::max(new_name_id, last_id);
}
}
return std::string(new_name_prefix + std::to_string(new_name_id + 1));
Expand Down
Loading