Skip to content

Commit

Permalink
merged master into remote (light update)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasrau committed Jan 27, 2021
2 parents 9f13c45 + 0f09c3f commit 591430d
Show file tree
Hide file tree
Showing 53 changed files with 937 additions and 727 deletions.
2 changes: 2 additions & 0 deletions core/include/mmcore/CallGeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ template <typename DataType, typename MetaDataType> class GenericVersionedCall :

MetaDataType const& getMetaData() { return m_meta_data; }

//TODO move setters?

uint32_t version() { return m_set_version; }

bool hasUpdate() { return (m_set_version > m_get_version); }
Expand Down
5 changes: 4 additions & 1 deletion core/include/mmcore/DeferredShading.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ class DeferredShading : public megamol::core::view::Renderer3DModule_2 {
*/
std::unique_ptr<glowl::BufferObject> m_lights_buffer;

/** The call for light sources */
core::CallerSlot getLightsSlot;

/** The btf file name */
core::param::ParamSlot m_btf_filename_slot;
};

} // namespace core
} // namespace megamol

#endif
#endif
13 changes: 0 additions & 13 deletions core/include/mmcore/view/Renderer3DModule_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,13 @@ class MEGAMOLCORE_API Renderer3DModule_2 : public view::RendererModule<CallRende
*/
virtual bool Render(CallRender3D_2& call) = 0;

/**
* Receives the current lights from the light call and writes them to the lightMap
*
* @return True if any light has changed, false otherwise.
*/
bool GetLights(void);

/**
* Method that gets called before the rendering is started for all changed modules
*
* @param call The rendering call that contains the camera
*/
virtual void PreRender(CallRender3D_2& call);

/** map to store the called lights */
core::view::light::LightMap lightMap;

private:
/**
* The chained get extents callback. The module should set the members of
Expand All @@ -96,9 +86,6 @@ class MEGAMOLCORE_API Renderer3DModule_2 : public view::RendererModule<CallRende
virtual bool RenderChain(CallRender3D_2& call) override final;

// TODO events

/** Slot to retrieve the light information */
CallerSlot lightSlot;
};

} // namespace view
Expand Down
8 changes: 7 additions & 1 deletion core/include/mmcore/view/light/AbstractLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,23 @@ class MEGAMOLCORE_API AbstractLight : public core::Module {
virtual bool create();
virtual void release();
bool getLightCallback(core::Call& call);
bool getMetaDataCallback(core::Call& call);
virtual bool InterfaceIsDirty() { return false; };
virtual void readParams(){};
virtual void addLight(LightCollection& light_collection) = 0;
bool AbstractIsDirty();

LightContainer lightContainer;
uint32_t version;

std::shared_ptr<BaseLightType> lightsource;

// Interface variables
core::param::ParamSlot lightIntensity;
core::param::ParamSlot lightColor;

private:
bool rhs_connected;

core::CallerSlot getLightSlot;
core::CalleeSlot deployLightSlot;
};
Expand Down
7 changes: 7 additions & 0 deletions core/include/mmcore/view/light/AmbientLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace core {
namespace view {
namespace light {

struct AmbientLightType : public BaseLightType {};

class MEGAMOLCORE_API AmbientLight : public AbstractLight {
public:
/**
Expand All @@ -35,6 +37,11 @@ class MEGAMOLCORE_API AmbientLight : public AbstractLight {
*/
static bool IsAvailable(void) { return true; }

/**
* Add the lightsource of this module to a given collection
*/
void addLight(LightCollection& light_collection);

/** Ctor. */
AmbientLight(void);

Expand Down
117 changes: 16 additions & 101 deletions core/include/mmcore/view/light/CallLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,122 +5,37 @@
* Alle Rechte vorbehalten.
*/

#pragma once
#ifndef CALL_LIGHTS_H_INCLUDED
#define CALL_LIGHTS_H_INCLUDED

#include <map>
#include <vector>
#include <array>
#include "mmcore/Call.h"
#include "mmcore/api/MegaMolCore.std.h"
#include "mmcore/CallGeneric.h"
#include "mmcore/factories/CallAutoDescription.h"
#include "vislib/String.h"

#include "LightCollection.h"

namespace megamol {
namespace core {
namespace view {
namespace light {

enum MEGAMOLCORE_API lightenum { NONE, DISTANTLIGHT, POINTLIGHT, SPOTLIGHT, QUADLIGHT, AMBIENTLIGHT, HDRILIGHT };

struct MEGAMOLCORE_API LightContainer {
// General light parameters
std::array<float,4> lightColor;
float lightIntensity;
lightenum lightType = lightenum::NONE;
// Distant light parameters
std::array<float,3> dl_direction;
float dl_angularDiameter;
bool dl_eye_direction;
// point light paramenters
std::array<float,3> pl_position;
float pl_radius;
// spot light parameters
std::array<float,3> sl_position;
std::array<float,3> sl_direction;
float sl_openingAngle;
float sl_penumbraAngle;
float sl_radius;
// quad light parameters
std::array<float,3> ql_position;
std::array<float,3> ql_edgeOne;
std::array<float,3> ql_edgeTwo;
// hdri light parameters
std::array<float,3> hdri_up;
std::array<float,3> hdri_direction;
vislib::TString hdri_evnfile;
bool isValid = false;
bool dataChanged = true;
};

class CallLight;
typedef std::map<CallLight*, LightContainer> LightMap;

class MEGAMOLCORE_API CallLight : public core::Call {
class MEGAMOLCORE_API CallLight : public core::GenericVersionedCall<LightCollection, core::EmptyMetaData> {
public:
/**
* Answer the name of the objects of this description.
*
* @return The name of the objects of this description.
*/
static const char* ClassName(void) { return "CallLight"; }
CallLight() = default;
~CallLight() = default;

/**
* Gets a human readable description of the module.
*
* @return A human readable description of the module.
*/
static const char* Description(void) { return "Call for an light array"; }

/**
* Answer the number of functions used for this call.
*
* @return The number of functions used for this call.
*/
static unsigned int FunctionCount(void) { return 1; }

/**
* Answer the name of the function used for this call.
*
* @param idx The index of the function to return it's name.
*
* @return The name of the requested function.
*/
static const char* FunctionName(unsigned int idx) {
switch (idx) {
case 0:
return "GetCall";
default:
return NULL;
}
static const char* ClassName(void) {
return "CallLight";
}
static const char* Description(void) {
return "Call that transports a collection of lights";
}

/** Ctor. */
CallLight();

/** Dtor. */
virtual ~CallLight(void);

void setLightMap(LightMap* lm);

void addLight(LightContainer& lc);

void fillLightMap();

/**
* Assignment operator
*
* @param rhs The right hand side operand
*
* @return A reference to this
*/
CallLight& operator=(const CallLight& rhs);

private:
LightMap* lightMap;
};

typedef core::factories::CallAutoDescription<CallLight> CallLightDescription;

} // namespace light
} // namespace view
} // namespace core
} // namespace megamol

#endif //!CALL_LIGHTS_H_INCLUDED
17 changes: 14 additions & 3 deletions core/include/mmcore/view/light/DistantLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ namespace core {
namespace view {
namespace light {

struct DistantLightType : public BaseLightType {
std::array<float, 3> direction;
float angularDiameter;
bool eye_direction;
};

class MEGAMOLCORE_API DistantLight : public AbstractLight {
public:
/**
Expand All @@ -35,16 +41,21 @@ class MEGAMOLCORE_API DistantLight : public AbstractLight {
*/
static bool IsAvailable(void) { return true; }

/**
* Add the lightsource of this module to a given collection
*/
void addLight(LightCollection& light_collection);

/** Ctor. */
DistantLight(void);

/** Dtor. */
virtual ~DistantLight(void);

private:
core::param::ParamSlot dl_angularDiameter;
core::param::ParamSlot dl_direction;
core::param::ParamSlot dl_eye_direction;
core::param::ParamSlot angularDiameter;
core::param::ParamSlot direction;
core::param::ParamSlot eye_direction;

virtual bool InterfaceIsDirty();
virtual void readParams();
Expand Down
18 changes: 15 additions & 3 deletions core/include/mmcore/view/light/HDRILight.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ namespace core {
namespace view {
namespace light {

struct HDRILightType : public BaseLightType {
std::array<float, 3> up;
std::array<float, 3> direction;
vislib::TString evnfile;
};


class MEGAMOLCORE_API HDRILight : public AbstractLight {
public:
/**
Expand All @@ -35,16 +42,21 @@ class MEGAMOLCORE_API HDRILight : public AbstractLight {
*/
static bool IsAvailable(void) { return true; }

/**
* Add the lightsource of this module to a given collection
*/
void addLight(LightCollection& light_collection);

/** Ctor. */
HDRILight(void);

/** Dtor. */
virtual ~HDRILight(void);

private:
core::param::ParamSlot hdri_up;
core::param::ParamSlot hdri_direction;
core::param::ParamSlot hdri_evnfile;
core::param::ParamSlot up;
core::param::ParamSlot direction;
core::param::ParamSlot evnfile;

virtual bool InterfaceIsDirty();
virtual void readParams();
Expand Down
Loading

0 comments on commit 591430d

Please sign in to comment.