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

Features for the new Camera #347

Merged
merged 15 commits into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Empty file.
2 changes: 1 addition & 1 deletion core/include/mmcore/thecam/minimal_camera_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ template <class M> struct minimal_camera_state {
/** The distance of the far clipping plane. */
world_type far_clipping_plane;

/** With and height of the film gate. */
/** Width and height of the film gate. */
std::array<world_type, 2> film_gate;

/** The gate scaling method. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
#include "mmcore/BoundingBoxes_2.h"
#include "mmcore/api/MegaMolCore.std.h"
#include "mmcore/factories/CallAutoDescription.h"
#include "mmcore/nextgen/Camera_2.h"
#include "mmcore/view/AbstractCallRender.h"
#include "mmcore/view/Camera_2.h"
#include "vislib/SmartPtr.h"
#include "vislib/assert.h"
#include "vislib/types.h"

namespace megamol {
namespace core {
namespace nextgen {
namespace view {

/**
* New and improved base class of rendering graph calls
Expand Down Expand Up @@ -137,7 +137,7 @@ class MEGAMOLCORE_API AbstractCallRender3D_2 : public view::AbstractCallRender {
double lastFrameTime;
};

} // namespace nextgen
} // namespace view
} /* end namespace core */
} /* end namespace megamol */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#include "mmcore/CalleeSlot.h"
#include "mmcore/CallerSlot.h"
#include "mmcore/api/MegaMolCore.std.h"
#include "mmcore/nextgen/CallRender3D_2.h"
#include "mmcore/view/CallRender3D_2.h"
#include "mmcore/param/ParamSlot.h"
#include "mmcore/view/RendererModule.h"
#include "vislib/graphics/gl/GLSLShader.h"

namespace megamol {
namespace core {
namespace nextgen {
namespace view {

/**
* Renderer responsible for the rendering of the currently active bounding box as well as the view cube etc.
Expand Down Expand Up @@ -74,15 +74,15 @@ class MEGAMOLCORE_API BoundingBoxRenderer : public view::RendererModule<CallRend
* @param call The call containing all relevant parameters
* @return True on success, false otherwise
*/
virtual bool GetExtents(core::nextgen::CallRender3D_2& call) override;
virtual bool GetExtents(core::view::CallRender3D_2& call) override;

/*
* Renders the bounding box and the viewcube on top of the other rendered things
*
* @param call The call containing the camera and other parameters
* @return True on success, false otherwise
*/
virtual bool Render(core::nextgen::CallRender3D_2& call) override final;
virtual bool Render(core::view::CallRender3D_2& call) override final;

/**
* Render function for the bounding box front
Expand Down Expand Up @@ -110,7 +110,7 @@ class MEGAMOLCORE_API BoundingBoxRenderer : public view::RendererModule<CallRend
* @param call The incoming render call
* @return True on success, false otherwise.
*/
bool RenderViewCube(core::nextgen::CallRender3D_2& call);
bool RenderViewCube(core::view::CallRender3D_2& call);

/** Parameter that enables or disables the bounding box rendering */
param::ParamSlot enableBoundingBoxSlot;
Expand All @@ -136,7 +136,7 @@ class MEGAMOLCORE_API BoundingBoxRenderer : public view::RendererModule<CallRend
/** Shader program for lines */
vislib::graphics::gl::GLSLShader lineShader;
};
} // namespace nextgen
} // namespace view
} // namespace core
} // namespace megamol

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
#include <glm/glm.hpp>
#include "mmcore/api/MegaMolCore.std.h"
#include "mmcore/factories/CallAutoDescription.h"
#include "mmcore/nextgen/AbstractCallRender3D_2.h"
#include "mmcore/view/AbstractCallRender3D_2.h"
#include "mmcore/view/MouseFlags.h"
#include "mmcore/view/RenderOutputOpenGL.h"

namespace megamol {
namespace core {
namespace nextgen {
namespace view {
#ifdef _WIN32
# pragma warning(disable : 4250) // I know what I am doing ...
#endif /* _WIN32 */
Expand Down Expand Up @@ -165,7 +165,7 @@ class MEGAMOLCORE_API CallRender3D_2 : public AbstractCallRender3D_2, public vie
/** Description class typedef */
typedef factories::CallAutoDescription<CallRender3D_2> CallRender3D_2Description;

} // namespace nextgen
} // namespace view
} /* end namespace core */
} /* end namespace megamol */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#define MEGAMOLCORE_CAMERASERIALIZER_H_INCLUDED

#include "json.hpp"
#include "mmcore/nextgen/Camera_2.h"
#include "mmcore/view/Camera_2.h"
#include "vislib/sys/Log.h"

namespace megamol {
namespace core {
namespace nextgen {
namespace view {

/**
* Class for the serialization and deserialization of camera parameters
Expand Down Expand Up @@ -154,10 +154,10 @@ class CameraSerializer {
bool prettyMode;
};

} // namespace nextgen
} // namespace view
} // namespace core
} // namespace megamol

#include "mmcore/nextgen/CameraSerializer.inl"
#include "mmcore/view/CameraSerializer.inl"

#endif /* MEGAMOLCORE_CAMERASERIALIZER_H_INCLUDED */
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

/*
* megamol::core::nextgen::CameraSerializer::serialize
* megamol::core::view::CameraSerializer::serialize
*/
template <size_t N>
std::string megamol::core::nextgen::CameraSerializer::serialize(
const std::array<megamol::core::nextgen::Camera_2::minimal_state_type, N>& camVec,
std::string megamol::core::view::CameraSerializer::serialize(
const std::array<megamol::core::view::Camera_2::minimal_state_type, N>& camVec,
const std::array<bool, N>& validityFlags) const {

nlohmann::json out;
Expand All @@ -28,8 +28,8 @@ std::string megamol::core::nextgen::CameraSerializer::serialize(
}

template <size_t N>
std::string megamol::core::nextgen::CameraSerializer::serialize(
const std::array<std::pair<megamol::core::nextgen::Camera_2::minimal_state_type, bool>, N>& camVec) const {
std::string megamol::core::view::CameraSerializer::serialize(
const std::array<std::pair<megamol::core::view::Camera_2::minimal_state_type, bool>, N>& camVec) const {

nlohmann::json out;
for (const auto& obj : camVec) {
Expand All @@ -45,11 +45,11 @@ std::string megamol::core::nextgen::CameraSerializer::serialize(
}

/*
* megamol::core::nextgen::CameraSerializer::deserialize
* megamol::core::view::CameraSerializer::deserialize
*/
template <size_t N>
bool megamol::core::nextgen::CameraSerializer::deserialize(
std::array<megamol::core::nextgen::Camera_2::minimal_state_type, N>& outCameras, std::array<bool, N>& outValidity,
bool megamol::core::view::CameraSerializer::deserialize(
std::array<megamol::core::view::Camera_2::minimal_state_type, N>& outCameras, std::array<bool, N>& outValidity,
const std::string text) const {
nlohmann::json obj = nlohmann::json::parse(text);
if (!obj.is_array()) {
Expand All @@ -63,7 +63,7 @@ bool megamol::core::nextgen::CameraSerializer::deserialize(
for (nlohmann::json::iterator it = obj.begin(); it != obj.end(); ++it) {
size_t index = static_cast<size_t>(it - obj.begin());
auto cur = *it;
megamol::core::nextgen::Camera_2::minimal_state_type cam;
megamol::core::view::Camera_2::minimal_state_type cam;
bool result = this->getCamFromJsonObject(cam, cur);
if (!result) {
cam = {}; // empty the cam if it is garbage
Expand All @@ -75,11 +75,11 @@ bool megamol::core::nextgen::CameraSerializer::deserialize(
}

/*
* megamol::core::nextgen::CameraSerializer::deserialize
* megamol::core::view::CameraSerializer::deserialize
*/
template <size_t N>
bool megamol::core::nextgen::CameraSerializer::deserialize(
std::array<std::pair<megamol::core::nextgen::Camera_2::minimal_state_type, bool>, N>& outCameras,
bool megamol::core::view::CameraSerializer::deserialize(
std::array<std::pair<megamol::core::view::Camera_2::minimal_state_type, bool>, N>& outCameras,
const std::string text) const {
nlohmann::json obj = nlohmann::json::parse(text);
if (!obj.is_array()) {
Expand All @@ -93,7 +93,7 @@ bool megamol::core::nextgen::CameraSerializer::deserialize(
for (nlohmann::json::iterator it = obj.begin(); it != obj.end(); ++it) {
size_t index = static_cast<size_t>(it - obj.begin());
auto cur = *it;
megamol::core::nextgen::Camera_2::minimal_state_type cam;
megamol::core::view::Camera_2::minimal_state_type cam;
bool result = this->getCamFromJsonObject(cam, cur);
if (!result) {
cam = {}; // empty the cam if it is garbage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef megamol::core::thecam::rotate_manipulator<cam_type> rotate_type;

namespace megamol {
namespace core {
namespace nextgen {
namespace view {
/*
* Wrapper for the template-heavy camera class
*/
Expand Down Expand Up @@ -71,7 +71,7 @@ class MEGAMOLCORE_API Camera_2 : public cam_type {
*/
virtual void CalcClipping(const vislib::math::Cuboid<float>& bbox, float border);
};
} // namespace nextgen
} // namespace view
} // namespace core
} // namespace megamol

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
#include "mmcore/CalleeSlot.h"
#include "mmcore/CallerSlot.h"
#include "mmcore/api/MegaMolCore.std.h"
#include "mmcore/nextgen/CallRender3D_2.h"
#include "mmcore/view/CallRender3D_2.h"
#include "mmcore/view/MouseFlags.h"
#include "mmcore/view/RendererModule.h"
#include "mmcore/view/light/CallLight.h"
#include "vislib/graphics/graphicstypes.h"

namespace megamol {
namespace core {
namespace nextgen {
namespace view {

/**
* New and improved base class of rendering graph 3D renderer modules.
Expand Down Expand Up @@ -94,7 +94,7 @@ class MEGAMOLCORE_API Renderer3DModule_2 : public view::RendererModule<CallRende
CallerSlot lightSlot;
};

} // namespace nextgen
} // namespace view
} /* end namespace core */
} /* end namespace megamol */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#include "mmcore/CalleeSlot.h"
#include "mmcore/CallerSlot.h"
#include "mmcore/api/MegaMolCore.std.h"
#include "mmcore/nextgen/CameraSerializer.h"
#include "mmcore/nextgen/Camera_2.h"
#include "mmcore/param/ParamSlot.h"
#include "mmcore/view/AbstractCallRender.h"
#include "mmcore/view/AbstractCamParamSync.h"
#include "mmcore/view/AbstractRenderingView.h"
#include "mmcore/view/CameraSerializer.h"
#include "mmcore/view/Camera_2.h"
#include "mmcore/view/MouseFlags.h"
#include "mmcore/view/TimeControl.h"
#include "vislib/graphics/CameraLookAtDist.h"
Expand All @@ -44,7 +44,7 @@

namespace megamol {
namespace core {
namespace nextgen {
namespace view {

class MEGAMOLCORE_API View3D_2 : public view::AbstractRenderingView /*, public view::AbstractCamParamSync*/ {

Expand Down Expand Up @@ -172,6 +172,20 @@ class MEGAMOLCORE_API View3D_2 : public view::AbstractRenderingView /*, public v
*/
virtual void unpackMouseCoordinates(float& x, float& y);

/**
* Sets all parameters to the currently used camera values
*
* @param cam Camera containing the values that will be set
*/
void setCameraValues(const core::view::Camera_2& cam);

/**
* Adapts camera values set by the user if necessary
*
* @param cam The camera the newly set parameters will be stored in
*/
void adaptCameraValues(core::view::Camera_2& cam);

/**
* Implementation of 'Create'.
*
Expand Down Expand Up @@ -335,6 +349,20 @@ class MEGAMOLCORE_API View3D_2 : public view::AbstractRenderingView /*, public v
/** whether to reset the view when the object bounding box changes */
param::ParamSlot resetViewOnBBoxChangeSlot;

/** Invisible parameters for lua manipulation */
param::ParamSlot cameraPositionParam;
param::ParamSlot cameraOrientationParam;
param::ParamSlot cameraProjectionTypeParam;
param::ParamSlot cameraNearPlaneParam;
param::ParamSlot cameraFarPlaneParam;
param::ParamSlot cameraConvergencePlaneParam;
param::ParamSlot cameraEyeParam;
param::ParamSlot cameraGateScalingParam;
param::ParamSlot cameraFilmGateParam;
param::ParamSlot cameraCenterOffsetParam;
param::ParamSlot cameraHalfApertureRadiansParam;
param::ParamSlot cameraHalfDisparityParam;

/** The mouse x coordinate */
float mouseX;

Expand Down Expand Up @@ -368,10 +396,10 @@ class MEGAMOLCORE_API View3D_2 : public view::AbstractRenderingView /*, public v
/** */
std::chrono::time_point<std::chrono::high_resolution_clock> lastFrameTime;

std::chrono::microseconds lastFrameDuration;
std::chrono::microseconds lastFrameDuration;
};

} // namespace nextgen
} // namespace view
} /* end namespace core */
} /* end namespace megamol */

Expand Down
4 changes: 2 additions & 2 deletions core/src/factories/CallClassRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "mmcore/view/CallGetTransferFunction.h"
#include "mmcore/view/CallRender2D.h"
#include "mmcore/view/CallRender3D.h"
#include "mmcore/nextgen/CallRender3D_2.h"
#include "mmcore/view/CallRender3D_2.h"
#include "mmcore/view/CallRenderDeferred3D.h"
#include "mmcore/view/CallRenderView.h"
#include "mmcore/view/CallTimeControl.h"
Expand Down Expand Up @@ -64,7 +64,7 @@ void factories::register_call_classes(factories::CallDescriptionManager& instanc
instance.RegisterAutoDescription<view::CallGetTransferFunction>();
instance.RegisterAutoDescription<view::CallRender2D>();
instance.RegisterAutoDescription<view::CallRender3D>();
instance.RegisterAutoDescription<nextgen::CallRender3D_2>();
instance.RegisterAutoDescription<view::CallRender3D_2>();
instance.RegisterAutoDescription<view::CallRenderDeferred3D>();
instance.RegisterAutoDescription<view::CallRenderView>();
instance.RegisterAutoDescription<view::CallTimeControl>();
Expand Down
8 changes: 4 additions & 4 deletions core/src/factories/ModuleClassRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
#include "mmcore/view/TileView.h"
#include "mmcore/view/View2D.h"
#include "mmcore/view/View3D.h"
#include "mmcore/nextgen/View3D_2.h"
#include "mmcore/nextgen/BoundingBoxRenderer.h"
#include "mmcore/view/View3D_2.h"
#include "mmcore/view/BoundingBoxRenderer.h"
#include "mmcore/view/RendererRegistration.h"
#ifdef MEGAMOLCORE_WITH_DIRECT3D11
#include "mmcore/view/ViewDirect3D.h"
Expand Down Expand Up @@ -142,8 +142,8 @@ void factories::register_module_classes(factories::ModuleDescriptionManager& ins
instance.RegisterAutoDescription<view::TileView>();
instance.RegisterAutoDescription<view::View2D>();
instance.RegisterAutoDescription<view::View3D>();
instance.RegisterAutoDescription<nextgen::View3D_2>();
instance.RegisterAutoDescription<nextgen::BoundingBoxRenderer>();
instance.RegisterAutoDescription<view::View3D_2>();
instance.RegisterAutoDescription<view::BoundingBoxRenderer>();
instance.RegisterAutoDescription<view::BlinnPhongRendererDeferred>();
instance.RegisterAutoDescription<view::SplitView>();
instance.RegisterAutoDescription<view::HeadView>();
Expand Down
Loading