Merge branch 'develop' into solarsystem2

Conflicts:
	include/openspace/util/powerscaledsphere.h
	src/rendering/renderablefov.cpp
	src/rendering/renderablesphericalgrid.cpp
	src/rendering/renderabletrail.cpp
	src/util/powerscaledsphere.cpp
	src/util/spicemanager.cpp
This commit is contained in:
Michal Marcinkowski
2015-01-22 10:31:40 -05:00
47 changed files with 1207 additions and 428 deletions

View File

@@ -29,7 +29,7 @@
#include <openspace/interaction/luaconsole.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/gui.h>
#include <openspace/gui/gui.h>
#include <ghoul/cmdparser/commandlineparser.h>
namespace openspace {

View File

@@ -91,6 +91,7 @@ private:
std::set<properties::Property*> _floatProperties;
std::set<properties::Property*> _vec2Properties;
std::set<properties::Property*> _vec3Properties;
std::set<properties::Property*> _vec4Properties;
std::set<properties::Property*> _stringProperties;
std::set<properties::Property*> _optionProperty;
std::set<properties::Property*> _selectionProperty;

View File

@@ -35,8 +35,10 @@ class NumericalProperty : public TemplateProperty<T> {
public:
NumericalProperty(std::string identifier, std::string guiName);
NumericalProperty(std::string identifier, std::string guiName, T value);
NumericalProperty(std::string identifier, std::string guiName, T value,
T minimumValue, T maximumValue);
NumericalProperty(std::string identifier, std::string guiName, T value,
T minimumValue, T maximumValue);
T minimumValue, T maximumValue, T steppingValue);
bool getLua(lua_State* state) const override;
bool setLua(lua_State* state) override;
@@ -50,8 +52,15 @@ public:
using TemplateProperty<T>::operator=;
protected:
static const std::string MinimumValueKey;
static const std::string MaximumValueKey;
static const std::string SteppingValueKey;
std::string generateAdditionalDescription() const;
T _minimumValue;
T _maximumValue;
T _stepping;
};
} // namespace properties

View File

@@ -42,6 +42,9 @@ namespace properties {
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>(); \
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>(); \
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue(lua_State* state, \
@@ -71,43 +74,43 @@ namespace properties {
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
{ \
return #CLASS_NAME; \
\
} \
} \
template <> \
std::string PropertyDelegate<NumericalProperty<TYPE>>::className() \
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::className(); \
\
} \
} \
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>() \
{ \
return DEFAULT_VALUE; \
\
} \
} \
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>() \
{ \
return DEFAULT_MIN_VALUE; \
\
} \
} \
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>() \
{ \
return DEFAULT_MAX_VALUE; \
\
} \
} \
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>() \
{ \
return DEFAULT_STEPPING; \
} \
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(lua_State * state, \
bool& success) \
{ \
return FROM_LUA_LAMBDA_EXPRESSION(state, success); \
\
} \
} \
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromLuaValue<TYPE>( \
@@ -115,8 +118,7 @@ namespace properties {
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(state, \
success); \
\
} \
} \
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(lua_State * state, \
@@ -142,36 +144,62 @@ namespace properties {
return PropertyDelegate<TemplateProperty<TYPE>>::typeLua(); \
}
template <typename T>
const std::string NumericalProperty<T>::MinimumValueKey = "MinimumValue";
template <typename T>
const std::string NumericalProperty<T>::MaximumValueKey = "MaximumValue";
template <typename T>
const std::string NumericalProperty<T>::SteppingValueKey = "SteppingValue";
// Delegating constructors are necessary; automatic template deduction cannot
// deduce template argument for 'U' if 'default' methods are used as default values in
// a single constructor
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier, std::string guiName)
: NumericalProperty<T>(std::move(identifier), std::move(guiName),
PropertyDelegate<NumericalProperty<T>>::template defaultValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>())
: NumericalProperty<T>(
std::move(identifier), std::move(guiName),
PropertyDelegate<NumericalProperty<T>>::template defaultValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier,
std::string guiName, T value)
: NumericalProperty<T>(std::move(identifier), std::move(guiName), std::move(value),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>())
: NumericalProperty<T>(
std::move(identifier), std::move(guiName), std::move(value),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier, std::string guiName,
T value, T minimumValue, T maximumValue)
: NumericalProperty<T>(
std::move(identifier) , std::move(guiName), std::move(value),
std::move(minimumValue), std::move(maximumValue),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier,
std::string guiName, T value,
T minimumValue, T maximumValue)
T minimumValue, T maximumValue, T steppingValue)
: TemplateProperty<T>(std::move(identifier), std::move(guiName), std::move(value))
, _minimumValue(std::move(minimumValue))
, _maximumValue(std::move(maximumValue))
, _stepping(std::move(steppingValue))
{}
template <typename T>
std::string NumericalProperty<T>::className() const {
return PropertyDelegate<NumericalProperty<T>>::className();
@@ -199,7 +227,6 @@ int NumericalProperty<T>::typeLua() const {
return PropertyDelegate<NumericalProperty<T>>::typeLua();
}
template <typename T>
T NumericalProperty<T>::minValue() const {
return _minimumValue;
@@ -210,5 +237,14 @@ T NumericalProperty<T>::maxValue() const {
return _maximumValue;
}
template <typename T>
std::string NumericalProperty<T>::generateAdditionalDescription() const {
std::string result;
result += MinimumValueKey + " = " + std::to_string(_minimumValue) + ",";
result += MaximumValueKey + " = " + std::to_string(_maximumValue) + ",";
result += SteppingValueKey + " = " + std::to_string(_stepping);
return result;
}
} // namespace properties
} // namespace openspace

View File

@@ -87,6 +87,9 @@ public:
void setValue(int value) override;
private:
static const std::string OptionsKey;
std::string generateAdditionalDescription() const;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
};

View File

@@ -92,6 +92,19 @@ public:
template <typename U>
static U defaultMaximumValue();
/**
* The method returns the default stepping value for the class <code>T</code> used in
* GUI elements. The default implementation will lead to a compile-time error if the
* class method is not specialized. This method is not used in TemplateProperty, but
* only NumericalProperty, so the TemplateProperty does not require this method to be
* specialized.
* \return The default stepping that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
*/
template <typename U>
static U defaultSteppingValue();
/**
* This method converts the top value from the Lua stack into a value of type
* <code>U</code> and reports the <code>success</code> back to the caller. The default

View File

@@ -54,6 +54,13 @@ U PropertyDelegate<T>::defaultMaximumValue() {
"Unimplemented PropertyDelegate::defaultMaximumValue specialization");
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::defaultSteppingValue() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultSteppingValue specialization");
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::fromLuaValue(lua_State* state, bool& success) {

View File

@@ -32,8 +32,6 @@
namespace openspace {
namespace properties {
//REGISTER_TEMPLATEPROPERTY_HEADER(SelectionProperty, std::vector<int>);
class SelectionProperty : public TemplateProperty<std::vector<int>> {
public:
struct Option {
@@ -46,9 +44,10 @@ public:
void addOption(Option option);
const std::vector<Option>& options() const;
//void setValue(std::vector<int> value) override;
private:
static const std::string OptionsKey;
std::string generateAdditionalDescription() const;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
std::vector<int> _values;

View File

@@ -75,7 +75,7 @@ protected:
private:
properties::BoolProperty _enabled;
PowerScaledScalar boundingSphere_;
std::string _relativePath;
};

View File

@@ -22,14 +22,24 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef RENDERABLEFIELDLINES_H_
#define RENDERABLEFIELDLINES_H_
#ifndef __RENDERABLEFIELDLINES_H__
#define __RENDERABLEFIELDLINES_H__
// open space includes
#include <openspace/rendering/renderable.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalarproperty.h>
#include <openspace/properties/vectorproperty.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/opengl/ghoul_gl.h>
namespace ghoul {
namespace opengl {
class ProgramObject;
}
}
namespace openspace {
struct LinePoint;
@@ -37,23 +47,46 @@ namespace openspace {
class RenderableFieldlines : public Renderable {
public:
RenderableFieldlines(const ghoul::Dictionary& dictionary);
~RenderableFieldlines();
bool initialize();
bool deinitialize();
bool initialize() override;
bool deinitialize() override;
bool isReady() const override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
std::vector<std::vector<LinePoint> > getFieldlinesData(std::string filename, ghoul::Dictionary hintsDictionary);
typedef std::vector<LinePoint> Line;
void initializeDefaultPropertyValues();
//std::vector<std::vector<LinePoint> > getFieldlinesData(std::string filename, ghoul::Dictionary hintsDictionary);
std::vector<Line> getFieldlinesData();
void loadSeedPoints();
void loadSeedPointsFromFile();
void loadSeedPointsFromTable();
std::vector<Line> generateFieldlines();
std::vector<Line> generateFieldlinesVolumeKameleon();
properties::FloatProperty _stepSize;
properties::BoolProperty _classification;
properties::Vec4Property _fieldlineColor;
properties::OptionProperty _seedPointSource;
properties::StringProperty _seedPointSourceFile;
ghoul::opengl::ProgramObject* _program;
bool _programIsDirty;
ghoul::Dictionary _vectorFieldInfo;
ghoul::Dictionary _fieldlineInfo;
ghoul::Dictionary _seedPointsInfo;
bool _seedPointsAreDirty;
bool _fieldLinesAreDirty;
std::vector<ghoul::Dictionary> _hintsDictionaries;
std::vector<std::string> _filenames;
std::vector<glm::vec3> _seedPoints;
ghoul::opengl::ProgramObject* _shader;
GLuint _fieldlineVAO;
GLuint _vertexPositionBuffer;
@@ -62,4 +95,5 @@ private:
};
} // namespace openspace
#endif // RENDERABLEFIELDLINES_H_
#endif // __RENDERABLEFIELDLINES_H__

View File

@@ -72,7 +72,7 @@ private:
GLuint _boxArray;
GLuint _vertexPositionBuffer;
ghoul::opengl::ProgramObject *_boxProgram;
ghoul::opengl::ProgramObject* _boxProgram;
glm::vec3 _boxScaling;
psc _pscOffset;
float _w;

View File

@@ -85,7 +85,7 @@ public:
Renderable* renderable();
private:
bool sphereInsideFrustum(const psc s_pos, const PowerScaledScalar& s_rad, const Camera* camera);
bool sphereInsideFrustum(const psc& s_pos, const PowerScaledScalar& s_rad, const Camera* camera);
std::vector<SceneGraphNode*> _children;
SceneGraphNode* _parent;

View File

@@ -61,6 +61,7 @@ namespace scenegraph {
const std::string keyCamera = "Camera";
const std::string keyFocusObject = "Focus";
const std::string keyPositionObject = "Position";
const std::string keyViewOffset = "Offset";
const std::string keyPathModule = "ModulePath";
} // namespace scenegraph

View File

@@ -13,7 +13,10 @@ openspace.bindKey("f2", "openspace.setPerformanceMeasurement(true)")
openspace.bindKey("f3", "openspace.setPerformanceMeasurement(false)")
openspace.bindKey("f5", "loadKeyBindings()")
openspace.bindKey("T", "openspace.distance(-interaction_speed * openspace.dt(), 6.0)")
openspace.bindKey("G", "openspace.distance(interaction_speed * openspace.dt(), 6.0)")
openspace.bindKey("Y", "openspace.distance(-interaction_speed * openspace.dt(), 10.0)")
openspace.bindKey("H", "openspace.distance(interaction_speed * openspace.dt(), 10.0)")
openspace.bindKey("U", "openspace.distance(-interaction_speed * openspace.dt(), 13.0)")
openspace.bindKey("J", "openspace.distance(interaction_speed * openspace.dt(), 13.0)")

View File

@@ -28,13 +28,20 @@ in vec4 gs_color;
in vec4 gs_position;
in vec3 gs_normal;
uniform bool classification;
uniform vec4 fieldLineColor;
#include "ABuffer/abufferStruct.hglsl"
#include "ABuffer/abufferAddToBuffer.hglsl"
#include "PowerScaling/powerScaling_fs.hglsl"
void main() {
float alpha = 1-length(gs_normal)*length(gs_normal);
vec4 fragColor = vec4(gs_color.rgb, alpha);
vec4 fragColor;
if (classification)
fragColor = vec4(gs_color.rgb, alpha);
else
fragColor = vec4(fieldLineColor.rgb, fieldLineColor.a * alpha);
float depth = pscDepth(gs_position);
ABufferStruct_t frag = createGeometryFragment(fragColor, gs_position, depth);

View File

@@ -46,6 +46,12 @@ file(GLOB ENGINE_HEADER ${HEADER_ROOT_DIR}/openspace/engine/*.h)
set(OPENSPACE_HEADER ${OPENSPACE_HEADER} ${ENGINE_HEADER})
source_group(Engine FILES ${ENGINE_SOURCE} ${ENGINE_HEADER})
file(GLOB GUI_SOURCE ${SOURCE_ROOT_DIR}/gui/*.cpp)
set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${GUI_SOURCE})
file(GLOB GUI_HEADER ${HEADER_ROOT_DIR}/openspace/gui/*.h)
set(OPENSPACE_HEADER ${OPENSPACE_HEADER} ${GUI_HEADER})
source_group(GUI FILES ${GUI_SOURCE} ${GUI_HEADER})
file(GLOB INTERACTION_SOURCE ${SOURCE_ROOT_DIR}/interaction/*.cpp)
set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${INTERACTION_SOURCE})
file(GLOB INTERACTION_HEADER ${HEADER_ROOT_DIR}/openspace/interaction/*.h)

View File

@@ -518,7 +518,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
bool buttons[2] = { button0 != 0, button1 != 0 };
double dt = std::max(sgct::Engine::instance()->getDt(), 1.0/60.0);
_gui.startFrame(dt, glm::vec2(glm::ivec2(x,y)), glm::vec2(posX, posY), buttons);
_gui.startFrame(static_cast<float>(dt), glm::vec2(glm::ivec2(x,y)), glm::vec2(posX, posY), buttons);
}
}

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/engine/gui.h>
#include <openspace/gui/gui.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/properties/property.h>
@@ -213,7 +213,6 @@ void renderVec2Property(Property* prop, const std::string& ownerName) {
p->set(value);
}
void renderVec3Property(Property* prop, const std::string& ownerName) {
Vec3Property* p = static_cast<Vec3Property*>(prop);
std::string name = p->guiName();
@@ -224,6 +223,16 @@ void renderVec3Property(Property* prop, const std::string& ownerName) {
p->set(value);
}
void renderVec4Property(Property* prop, const std::string& ownerName) {
Vec4Property* p = static_cast<Vec4Property*>(prop);
std::string name = p->guiName();
Vec4Property::ValueType value = *p;
ImGui::SliderFloat4((ownerName + "." + name).c_str(), &value.x, p->minValue().x, p->maxValue().x);
p->set(value);
}
void renderTriggerProperty(Property* prop, const std::string& ownerName) {
std::string name = prop->guiName();
bool pressed = ImGui::Button((ownerName + "." + name).c_str());
@@ -238,6 +247,7 @@ namespace openspace {
GUI::GUI()
: _isEnabled(false)
, _showPropertyWindow(false)
, _showPerformanceWindow(false)
, _showHelp(false)
, _performanceMemory(nullptr)
{
@@ -301,6 +311,10 @@ void GUI::initialize() {
void GUI::initializeGL() {
_program = ghoul::opengl::ProgramObject::Build("GUI",
"${SHADERS}/gui_vs.glsl", "${SHADERS}/gui_fs.glsl");
if (!_program) {
LERROR("Could not load program object for GUI");
return;
}
positionLocation = glGetAttribLocation(*_program, "in_position");
uvLocation = glGetAttribLocation(*_program, "in_uv");
@@ -426,6 +440,8 @@ void GUI::registerProperty(properties::Property* prop) {
_vec2Properties.insert(prop);
else if (className == "Vec3Property")
_vec3Properties.insert(prop);
else if (className == "Vec4Property")
_vec4Properties.insert(prop);
else if (className == "OptionProperty")
_optionProperty.insert(prop);
else if (className == "TriggerProperty")
@@ -501,6 +517,11 @@ void GUI::renderPropertyWindow() {
continue;
}
if (_vec4Properties.find(prop) != _vec4Properties.end()) {
renderVec4Property(prop, p.first);
continue;
}
if (_optionProperty.find(prop) != _optionProperty.end()) {
renderOptionProperty(prop, p.first);
continue;

View File

@@ -313,7 +313,7 @@ int distance(lua_State* L) {
double d1 = luaL_checknumber(L, -2);
double d2 = luaL_checknumber(L, -1);
PowerScaledScalar dist(d1, d2);
PowerScaledScalar dist(static_cast<float>(d1), static_cast<float>(d2));
OsEng.interactionHandler().distanceDelta(dist);
return 0;
}
@@ -515,7 +515,7 @@ void InteractionHandler::mousePositionCallback(int x, int y) {
void InteractionHandler::mouseScrollWheelCallback(int pos) {
if (_mouseController)
_mouseController->scrollWheel(float(pos));
_mouseController->scrollWheel(pos);
}
void InteractionHandler::orbitDelta(const glm::quat& rotation)

View File

@@ -32,13 +32,17 @@
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/misc/highresclock.h>
namespace {
const std::string _loggerCat = "KeyboardController";
}
namespace openspace {
namespace interaction {
void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier modifier) {
// TODO package in script
const double speed = 2.75;
const double dt = _handler->deltaTime();
const float speed = 2.75;
const float dt = static_cast<float>( _handler->deltaTime());
if(action == KeyAction::Press|| action == KeyAction::Repeat) {
if (key == Key::S) {
glm::vec3 euler(speed * dt, 0.0, 0.0);
@@ -92,7 +96,7 @@ void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier
_handler->distanceDelta(dist);
}
if (key == Key::T) {
PowerScaledScalar dist(-speed * pow(10, 11) * dt, 0.0);
PowerScaledScalar dist(-speed * pow(10.0f, 11.0f) * dt, 0.0f);
_handler->distanceDelta(dist);
}
//if (key == Keys::G) {
@@ -101,11 +105,11 @@ void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier
// distanceDelta(dist);
//}
if (key == Key::Y) {
PowerScaledScalar dist(-speed * 100.0 * dt, 6.0);
PowerScaledScalar dist(-speed * 100.0f * dt, 6.0f);
_handler->distanceDelta(dist);
}
if (key == Key::H) {
PowerScaledScalar dist(speed * 100.0 * dt, 6.0);
PowerScaledScalar dist(speed * 100.0f * dt, 6.0f);
_handler->distanceDelta(dist);
}
@@ -149,8 +153,6 @@ void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier
}
void KeyboardControllerLua::keyPressed(KeyAction action, Key key, KeyModifier modifier) {
std::string _loggerCat = "KeyboardControllerLua";
lua_State* s = luaL_newstate();
luaL_openlibs(s);

View File

@@ -328,10 +328,10 @@ void LuaConsole::keyboardCallback(int key, int action) {
if (_commands.at(_activeCommand) != "") {
OsEng.scriptEngine().runScript(_commands.at(_activeCommand));
if (_commandsHistory.size() > 0 &&
if (!_commandsHistory.empty() &&
_commands.at(_activeCommand) != _commandsHistory.at(_commandsHistory.size() - 1))
_commandsHistory.push_back(_commands.at(_activeCommand));
else if (_commandsHistory.size() == 0)
else if (_commandsHistory.empty())
_commandsHistory.push_back(_commands.at(_activeCommand));
_commands = _commandsHistory;

View File

@@ -43,10 +43,10 @@ glm::vec3 MouseController::mapToTrackball(glm::vec2 mousePos) {
if (out.x*out.x + out.y*out.y <= RADIUS*RADIUS / 2.0) {
//Spherical Region
out.z = RADIUS*RADIUS - (out.x*out.x + out.y*out.y);
out.z = out.z > 0.0 ? sqrtf(out.z) : 0.0;
out.z = out.z > 0.0f ? sqrtf(out.z) : 0.0f;
}
else { //Hyperbolic Region - for smooth z values
out.z = (RADIUS*RADIUS) / (2.0*sqrt(out.x*out.x + out.y*out.y));
out.z = (RADIUS*RADIUS) / (2.0f*sqrt(out.x*out.x + out.y*out.y));
}
return glm::normalize(out);
@@ -70,8 +70,8 @@ glm::vec3 MouseController::mapToCamera(glm::vec3 trackballPos) {
void MouseController::trackballRotate(int x, int y) {
// Normalize mouse coordinates to [0,1]
float width = sgct::Engine::instance()->getActiveXResolution();
float height = sgct::Engine::instance()->getActiveYResolution();
float width = static_cast<float>(sgct::Engine::instance()->getActiveXResolution());
float height = static_cast<float>(sgct::Engine::instance()->getActiveYResolution());
glm::vec2 mousePos = glm::vec2((float)x / width, (float)y / height);
mousePos = glm::clamp(mousePos, -0.5, 1.5); // Ugly fix #1: Camera position becomes NaN on mouse values outside [-0.5, 1.5]
@@ -89,7 +89,7 @@ void MouseController::trackballRotate(int x, int y) {
if (curTrackballPos != _lastTrackballPos) {
// calculate rotation angle (in radians)
float rotationAngle = glm::angle(curTrackballPos, _lastTrackballPos);
rotationAngle *= _handler->deltaTime() * 100.0f;
rotationAngle *= static_cast<float>(_handler->deltaTime()) * 100.0f;
// Map trackballpos to camera
// glm::vec3 trackballMappedToCamera = mapToCamera(_lastTrackballPos - curTrackballPos);
@@ -125,18 +125,18 @@ void TrackballMouseController::button(MouseAction action, MouseButton button) {
void TrackballMouseController::move(float x, float y) {
if (_leftMouseButtonDown)
trackballRotate(x, y);
trackballRotate(static_cast<int>(x), static_cast<int>(y));
}
void TrackballMouseController::scrollWheel(int pos) {
const double speed = 4.75;
const double dt = _handler->deltaTime();
const float speed = 4.75f;
const float dt = static_cast<float>(_handler->deltaTime());
if (pos < 0) {
PowerScaledScalar dist(speed * dt, 0.0);
PowerScaledScalar dist(speed * dt, 0.0f);
_handler->distanceDelta(dist);
}
else if (pos > 0) {
PowerScaledScalar dist(-speed * dt, 0.0);
PowerScaledScalar dist(-speed * dt, 0.0f);
_handler->distanceDelta(dist);
}
}

View File

@@ -68,128 +68,552 @@ namespace properties {
}
REGISTER_NUMERICALPROPERTY_SOURCE(Mat2Property, glm::mat2x2, glm::mat2x2(0),
glm::mat2x2(numeric_limits<float>::lowest()),
glm::mat2x2(numeric_limits<float>::max()),
glm::mat2x2(0.01f),
glm::mat2x2(
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest()
),
glm::mat2x2(
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max()
),
glm::mat2x2(
0.01f, 0.01f,
0.01f, 0.01f
),
DEFAULT_FROM_LUA_LAMBDA(glm::mat2x2),
DEFAULT_TO_LUA_LAMBDA(glm::mat2x2), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x3Property, glm::mat2x3, glm::mat2x3(0),
glm::mat2x3(numeric_limits<float>::lowest()),
glm::mat2x3(numeric_limits<float>::max()),
glm::mat2x3(0.01f),
glm::mat2x3(
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest()
),
glm::mat2x3(
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max()
),
glm::mat2x3(
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f
),
DEFAULT_FROM_LUA_LAMBDA(glm::mat2x3),
DEFAULT_TO_LUA_LAMBDA(glm::mat2x3), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x4Property, glm::mat2x4, glm::mat2x4(0),
glm::mat2x4(numeric_limits<float>::lowest()),
glm::mat2x4(numeric_limits<float>::max()),
glm::mat2x4(0.01f),
glm::mat2x4(
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest()
),
glm::mat2x4(
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max()
),
glm::mat2x4(
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f
),
DEFAULT_FROM_LUA_LAMBDA(glm::mat2x4),
DEFAULT_TO_LUA_LAMBDA(glm::mat2x4), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x2Property, glm::mat3x2, glm::mat3x2(0),
glm::mat3x2(numeric_limits<float>::lowest()),
glm::mat3x2(numeric_limits<float>::max()),
glm::mat3x2(0.01f),
glm::mat3x2(
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest()
),
glm::mat3x2(
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max()
),
glm::mat3x2(
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f
),
DEFAULT_FROM_LUA_LAMBDA(glm::mat3x2),
DEFAULT_TO_LUA_LAMBDA(glm::mat3x2), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(Mat3Property, glm::mat3x3, glm::mat3x3(0),
glm::mat3x3(numeric_limits<float>::lowest()),
glm::mat3x3(numeric_limits<float>::max()),
glm::mat3x3(0.01f),
glm::mat3x3(
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest()
),
glm::mat3x3(
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max()
),
glm::mat3x3(
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f
),
DEFAULT_FROM_LUA_LAMBDA(glm::mat3x3),
DEFAULT_TO_LUA_LAMBDA(glm::mat3x3), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x4Property, glm::mat3x4, glm::mat3x4(0),
glm::mat3x4(numeric_limits<float>::lowest()),
glm::mat3x4(numeric_limits<float>::max()),
glm::mat3x4(0.01f),
glm::mat3x4(
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest()
),
glm::mat3x4(
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max()
),
glm::mat3x4(
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f
),
DEFAULT_FROM_LUA_LAMBDA(glm::mat3x4),
DEFAULT_TO_LUA_LAMBDA(glm::mat3x4), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x2Property, glm::mat4x2, glm::mat4x2(0),
glm::mat4x2(numeric_limits<float>::lowest()),
glm::mat4x2(numeric_limits<float>::max()),
glm::mat4x2(0.01f),
glm::mat4x2(
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest()
),
glm::mat4x2(
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max()
),
glm::mat4x2(
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f
),
DEFAULT_FROM_LUA_LAMBDA(glm::mat4x2),
DEFAULT_TO_LUA_LAMBDA(glm::mat4x2), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x3Property, glm::mat4x3, glm::mat4x3(0),
glm::mat4x3(numeric_limits<float>::lowest()),
glm::mat4x3(numeric_limits<float>::max()),
glm::mat4x3(0.01f),
glm::mat4x3(
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest()
),
glm::mat4x3(
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max()
),
glm::mat4x3(
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f
),
DEFAULT_FROM_LUA_LAMBDA(glm::mat4x3),
DEFAULT_TO_LUA_LAMBDA(glm::mat4x3), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(Mat4Property, glm::mat4x4, glm::mat4x4(0),
glm::mat4x4(numeric_limits<float>::lowest()),
glm::mat4x4(numeric_limits<float>::max()),
glm::mat4x4(0.01f),
glm::mat4x4(
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest(),
numeric_limits<float>::lowest()
),
glm::mat4x4(
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max(),
numeric_limits<float>::max()
),
glm::mat4x4(
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f
),
DEFAULT_FROM_LUA_LAMBDA(glm::mat4x4),
DEFAULT_TO_LUA_LAMBDA(glm::mat4x4), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(DMat2Property, glm::dmat2x2, glm::dmat2x2(0),
glm::dmat2x2(numeric_limits<double>::lowest()),
glm::dmat2x2(numeric_limits<double>::max()),
glm::dmat2x2(0.01),
glm::dmat2x2(
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest()
),
glm::dmat2x2(
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max()
),
glm::dmat2x2(
0.01, 0.01,
0.01, 0.01
),
DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x2),
DEFAULT_TO_LUA_LAMBDA(glm::dmat2x2), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x3Property, glm::dmat2x3, glm::dmat2x3(0),
glm::dmat2x3(numeric_limits<double>::lowest()),
glm::dmat2x3(numeric_limits<double>::max()),
glm::dmat2x3(0.01),
glm::dmat2x3(
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest()
),
glm::dmat2x3(
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max()
),
glm::dmat2x3(
0.01, 0.01, 0.01,
0.01, 0.01, 0.01
),
DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x3),
DEFAULT_TO_LUA_LAMBDA(glm::dmat2x3), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x4Property, glm::dmat2x4, glm::dmat2x4(0),
glm::dmat2x4(numeric_limits<double>::lowest()),
glm::dmat2x4(numeric_limits<double>::max()),
glm::dmat2x4(0.01),
glm::dmat2x4(
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest()
),
glm::dmat2x4(
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max()
),
glm::dmat2x4(
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01
),
DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x4),
DEFAULT_TO_LUA_LAMBDA(glm::dmat2x4), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x2Property, glm::dmat3x2, glm::dmat3x2(0),
glm::dmat3x2(numeric_limits<double>::lowest()),
glm::dmat3x2(numeric_limits<double>::max()),
glm::dmat3x2(0.01),
glm::dmat3x2(
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest()
),
glm::dmat3x2(
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max()
),
glm::dmat3x2(
0.01, 0.01, 0.01,
0.01, 0.01, 0.01
),
DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x2),
DEFAULT_TO_LUA_LAMBDA(glm::dmat3x2), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(DMat3Property, glm::dmat3x3, glm::dmat3x3(0),
glm::dmat3x3(numeric_limits<double>::lowest()),
glm::dmat3x3(numeric_limits<double>::max()),
glm::dmat3x3(0.01),
glm::dmat3x3(
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest()
),
glm::dmat3x3(
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max()
),
glm::dmat3x3(
0.01, 0.01, 0.01,
0.01, 0.01, 0.01,
0.01, 0.01, 0.01
),
DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x3),
DEFAULT_TO_LUA_LAMBDA(glm::dmat3x3), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x4Property, glm::dmat3x4, glm::dmat3x4(0),
glm::dmat3x4(numeric_limits<double>::lowest()),
glm::dmat3x4(numeric_limits<double>::max()),
glm::dmat3x4(0.01),
glm::dmat3x4(
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest()
),
glm::dmat3x4(
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max()
),
glm::dmat3x4(
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01
),
DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x4),
DEFAULT_TO_LUA_LAMBDA(glm::dmat3x4), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x2Property, glm::dmat4x2, glm::dmat4x2(0),
glm::dmat4x2(numeric_limits<double>::lowest()),
glm::dmat4x2(numeric_limits<double>::max()),
glm::dmat4x2(0.01),
glm::dmat4x2(
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest()
),
glm::dmat4x2(
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max()
),
glm::dmat4x2(
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01
),
DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x2),
DEFAULT_TO_LUA_LAMBDA(glm::dmat4x2), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x3Property, glm::dmat4x3, glm::dmat4x3(0),
glm::dmat4x3(numeric_limits<double>::lowest()),
glm::dmat4x3(numeric_limits<double>::max()),
glm::dmat4x3(0.01),
glm::dmat4x3(
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest()
),
glm::dmat4x3(
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max()
),
glm::dmat4x3(
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01
),
DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x3),
DEFAULT_TO_LUA_LAMBDA(glm::dmat4x3), LUA_TTABLE);
REGISTER_NUMERICALPROPERTY_SOURCE(DMat4Property, glm::dmat4x4, glm::dmat4x4(0),
glm::dmat4x4(numeric_limits<double>::lowest()),
glm::dmat4x4(numeric_limits<double>::max()),
glm::dmat4x4(0.01),
glm::dmat4x4(
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest(),
numeric_limits<double>::lowest()
),
glm::dmat4x4(
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max(),
numeric_limits<double>::max()
),
glm::dmat4x4(
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01
),
DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x4),
DEFAULT_TO_LUA_LAMBDA(glm::dmat4x4), LUA_TTABLE);

View File

@@ -30,6 +30,8 @@ namespace {
namespace openspace {
namespace properties {
const std::string OptionProperty::OptionsKey = "Options";
OptionProperty::OptionProperty(std::string identifier, std::string guiName)
: IntProperty(std::move(identifier), std::move(guiName))
@@ -73,5 +75,20 @@ void OptionProperty::setValue(int value) {
LERROR("Could not find an option for value '" << value << "' in OptionProperty");
}
std::string OptionProperty::generateAdditionalDescription() const {
// @REFACTOR from selectionproperty.cpp, possible refactoring? ---abock
std::string result;
result += OptionsKey + " = {";
for (size_t i = 0; i < _options.size(); ++i) {
const Option& o = _options[i];
result += "[\"" + std::to_string(o.value) + "\"] = \"" + o.description + "\"";
if (i != _options.size() - 1)
result += ",";
}
result += "}";
return result;
}
} // namespace properties
} // namespace openspace

View File

@@ -52,7 +52,8 @@ const std::string Property::TypeKey = "Type";
const std::string Property::MetaDataKey = "MetaData";
Property::Property(std::string identifier, std::string guiName)
: _identifier(std::move(identifier))
: _owner(nullptr)
, _identifier(std::move(identifier))
{
if (_identifier.empty())
LWARNING("Property identifier is empty");

View File

@@ -31,12 +31,14 @@ namespace {
namespace openspace {
namespace properties {
const std::string SelectionProperty::OptionsKey = "Options";
SelectionProperty::SelectionProperty(std::string identifier, std::string guiName)
: TemplateProperty(std::move(identifier), std::move(guiName), std::vector<int>())
{}
void SelectionProperty::addOption(Option option) {
// @COPY-N-PASTE from optionproperty.cpp, possible refactoring? ---abock
// @REFACTOR from optionproperty.cpp, possible refactoring? ---abock
for (const Option& o : _options) {
if (o.value == option.value) {
LWARNING("The value of option {" << o.value << " -> " << o.description <<
@@ -51,10 +53,6 @@ void SelectionProperty::addOption(Option option) {
const std::vector<SelectionProperty::Option>& SelectionProperty::options() const {
return _options;
}
//
//void SelectionProperty::setValue(std::vector<int> value) {
// _values = std::move(value);
//}
template <>
std::string PropertyDelegate<TemplateProperty<std::vector<int>>>::className() {
@@ -113,49 +111,19 @@ int PropertyDelegate<TemplateProperty<std::vector<int>>>::typeLua() {
return LUA_TTABLE;
}
//REGISTER_TEMPLATEPROPERTY_SOURCE(SelectionProperty, std::vector<int>, std::vector<int>(),
// [](lua_State* state, bool& success) -> std::vector<int> {
// static const int KEY = -2;
// static const int VAL = -1;
//
// std::vector<int> result;
//
// if (!lua_istable(state, -1)) {
// LERROR("Parameter passed to the property is not a table");
// success = false;
// return result;
// }
//
// lua_pushnil(state);
// while (lua_next(state, -2) != 0) {
// int valueType = lua_type(state, VAL);
//
// if (lua_isnumber(state, VAL)) {
// int number = static_cast<int>(lua_tonumber(state, VAL));
// result.push_back(number);
// }
// else {
// success = false;
// return std::vector<int>();
// }
//
// lua_pop(state, 1);
// }
//
// success = true;
// return result;
// },
// [](lua_State* state, const std::vector<int>& value) -> bool {
// //@NOTE Untested ---abock
// lua_newtable(state);
// for (int i = 0; i < value.size(); ++i) {
// int v = value[i];
// lua_pushinteger(state, v);
// lua_setfield(state, -2, std::to_string(i).c_str());
// }
// return true;
// }, LUA_TTABLE
//);
std::string SelectionProperty::generateAdditionalDescription() const {
std::string result;
result += OptionsKey + " = {";
for (size_t i = 0; i < _options.size(); ++i) {
const Option& o = _options[i];
result += "[\"" + std::to_string(o.value) + "\"] = \"" + o.description + "\"";
if (i != _options.size() - 1)
result += ",";
}
result += "}";
return result;
}
} // namespace properties
} // namespace openspace

View File

@@ -86,7 +86,6 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
RenderableModel::~RenderableModel(){
deinitialize();
}
bool RenderableModel::isReady() const {
@@ -136,7 +135,7 @@ void RenderableModel::render(const RenderData& data)
glm::mat4 tmp = glm::mat4(1);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
tmp[i][j] = _stateMatrix[i][j];
tmp[i][j] = static_cast<float>(_stateMatrix[i][j]);
}
}

View File

@@ -87,7 +87,6 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
}
RenderablePlanet::~RenderablePlanet() {
deinitialize();
}
bool RenderablePlanet::initialize() {
@@ -134,7 +133,7 @@ void RenderablePlanet::render(const RenderData& data)
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
transform[i][j] = _stateMatrix[i][j];
transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
}
}
transform = transform* rot;

View File

@@ -204,13 +204,12 @@ bool RenderablePlanetProjection::auxiliaryRendertarget(){
}
bool RenderablePlanetProjection::deinitialize(){
_geometry->deinitialize();
delete _geometry;
_geometry = nullptr;
delete _texture;
_texture = nullptr;
delete _textureProj;
_textureProj = nullptr;
delete _geometry;
_geometry = nullptr;
return true;
}
bool RenderablePlanetProjection::isReady() const {

View File

@@ -89,8 +89,7 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary)
addProperty(_enabled);
}
Renderable::~Renderable()
{
Renderable::~Renderable() {
}
void Renderable::setBoundingSphere(const PowerScaledScalar& boundingSphere)

View File

@@ -28,123 +28,195 @@
#include <openspace/util/kameleonwrapper.h>
#include <openspace/util/constants.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/file.h>
#include <ghoul/misc/assert.h>
#include <fstream>
namespace {
const std::string _loggerCat = "RenderableFieldlines";
std::string _loggerCat = "RenderableFieldlines";
const float defaultFieldlineStepSize = 0.5f;;
const glm::vec4 defaultFieldlineColor = glm::vec4(1.f, 0.f, 0.f, 1.f);
const std::string keyVectorField = "VectorField";
const std::string keyVectorFieldType = "Type";
const std::string keyVectorFieldFile = "File";
const std::string keyVectorFieldVolumeModel = "Model";
const std::string keyVectorFieldVolumeVariable = "Variables";
const std::string keyFieldlines = "Fieldlines";
const std::string keyFilename = "File";
const std::string keyHints = "Hints";
const std::string keyFieldlinesStepSize = "Stepsize";
const std::string keyFieldlinesClassification = "Classification";
const std::string keyFieldlinesColor = "Color";
const std::string keySeedPoints = "SeedPoints";
const std::string keySeedPointsType = "Type";
const std::string keySeedPointsFile = "File";
const std::string keySeedPointsTable = "SeedPoints";
const std::string seedPointsSourceFile = "File";
const std::string seedPointsSourceTable = "Table";
const std::string vectorFieldTypeVolumeKameleon = "VolumeKameleon";
const std::string vectorFieldKameleonModelBATSRUS = "BATSRUS";
const std::string vectorFieldKameleonVariableLorentz = "Lorentz";
const int SeedPointSourceFile = 0;
const int SeedPointSourceTable = 1;
}
namespace openspace {
RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _stepSize("stepSize", "Fieldline Step Size", defaultFieldlineStepSize, 0.f, 10.f)
, _classification("classification", "Fieldline Classification", true)
, _fieldlineColor(
"fieldlineColor",
"Fieldline Color",
defaultFieldlineColor,
glm::vec4(0.f),
glm::vec4(1.f)
)
, _seedPointSource("source", "SeedPoint Source")
, _seedPointSourceFile("sourceFile", "SeedPoint File")
, _seedPointsAreDirty(true)
, _fieldLinesAreDirty(true)
, _fieldlineVAO(0)
, _vertexPositionBuffer(0)
, _shader(nullptr)
, _program(nullptr)
, _programIsDirty(false)
{
ghoul_assert(
dictionary.hasKeyAndValue<std::string>(constants::scenegraphnode::keyName),
"Renderable does not have a name"
);
std::string name;
dictionary.getValue(constants::scenegraphnode::keyName, name);
// Read fieldlines module into dictionary
ghoul::Dictionary fieldlines;
bool success = dictionary.getValue(keyFieldlines, fieldlines);
_loggerCat = "RenderableFieldlines [" + name + "]";
bool success = dictionary.getValue(keyVectorField, _vectorFieldInfo);
if (!success) {
LERROR("RenderableFieldlines '" << name << "' did not contain a '" <<
keyFieldlines << "' key");
return;
}
for (const std::string& key : fieldlines.keys()) {
ghoul::Dictionary fieldline;
success = fieldlines.getValue(key, fieldline);
if (!success) {
LERROR("Key '" << key << "' in '" << keyFieldlines <<
"' of the RenderableFieldlines '" << name <<
"' does not have a table as value");
continue;
}
std::string fileName;
fieldline.getValue(keyFilename, fileName);
fileName = findPath(fileName);
if (fileName.empty())
LERROR("File not found!");
else {
ghoul::Dictionary hintsDictionary;
fieldline.getValue(keyHints, hintsDictionary);
_filenames.push_back(fileName);
_hintsDictionaries.push_back(hintsDictionary);
}
LERROR("Renderable does not contain a key for '" <<
keyVectorField << "'");
}
setBoundingSphere(PowerScaledScalar::CreatePSS(250.f*6371000.f)); // FIXME a non-magic number perhaps
success = dictionary.getValue(keyFieldlines, _fieldlineInfo);
if (!success) {
LERROR("Renderable does not contain a key for '" <<
keyFieldlines << "'");
}
success = dictionary.getValue(keySeedPoints, _seedPointsInfo);
if (!success) {
LERROR("Renderable does not contain a key for '" <<
keySeedPoints << "'");
}
// @TODO a non-magic number perhaps ---abock
setBoundingSphere(PowerScaledScalar::CreatePSS(250.f*6371000.f));
_seedPointSource.addOption(SeedPointSourceFile, "File");
_seedPointSource.addOption(SeedPointSourceTable, "Lua Table");
initializeDefaultPropertyValues();
// @TODO hook up visibility changes ---abock
auto dirtyFieldlines = [this]() { this->_fieldLinesAreDirty = true; };
auto dirtySeedpoints = [this]() { this->_seedPointsAreDirty = true; };
_stepSize.onChange(dirtyFieldlines);
addProperty(_stepSize);
addProperty(_classification);
_fieldlineColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_fieldlineColor);
_seedPointSource.onChange(dirtySeedpoints);
addProperty(_seedPointSource);
_seedPointSourceFile.onChange(dirtySeedpoints);
addProperty(_seedPointSourceFile);
}
RenderableFieldlines::~RenderableFieldlines() {
deinitialize();
void RenderableFieldlines::initializeDefaultPropertyValues() {
bool success;
// Step size
float stepSize;
success = _fieldlineInfo.getValue(keyFieldlinesStepSize, stepSize);
if (success)
_stepSize = stepSize;
// Classification
bool classification;
success = _fieldlineInfo.getValue(keyFieldlinesClassification, classification);
if (success)
_classification = classification;
// Fieldline Color
glm::vec4 color;
success = _fieldlineInfo.getValue(keyFieldlinesColor, color);
if (success)
_fieldlineColor = color;
// Seedpoints Type
std::string sourceType;
success = _seedPointsInfo.getValue(keySeedPointsType, sourceType);
if (success) {
if (sourceType == seedPointsSourceFile) {
_seedPointSource = SeedPointSourceFile;
std::string seedPointSourceFile;
success = _seedPointsInfo.getValue(keySeedPointsFile, seedPointSourceFile);
if (success)
_seedPointSourceFile = absPath(seedPointSourceFile);
}
else if (sourceType == seedPointsSourceTable)
_seedPointSource = SeedPointSourceTable;
}
}
bool RenderableFieldlines::isReady() const {
return _shader != nullptr;
bool programReady = _program != nullptr;
bool vectorFieldReady = !_vectorFieldInfo.empty();
bool fieldlineReady = !_fieldlineInfo.empty();
bool seedPointsReady = !_seedPointsInfo.empty();
return programReady && vectorFieldReady && fieldlineReady && seedPointsReady;
}
bool RenderableFieldlines::initialize() {
if(_filenames.size() == 0) {
LWARNING("No proper filenames provided, cannot initialize!");
if (_vectorFieldInfo.empty() ||
_fieldlineInfo.empty() ||
_seedPointsInfo.empty())
{
return false;
}
ghoul_assert(_hintsDictionaries.size() != _filenames.size(),
"The dictionary sizes should match, "
<< _hintsDictionaries.size() << " != " << _filenames.size());
_program = ghoul::opengl::ProgramObject::Build(
"Fieldline",
"${SHADERS}/modules/fieldlines/fieldline_vs.glsl",
"${SHADERS}/modules/fieldlines/fieldline_fs.glsl",
"${SHADERS}/modules/fieldlines/fieldline_gs.glsl"
);
if (!_program)
return false;
int prevEnd = 0;
std::vector<LinePoint> vertexData;
std::vector<std::vector<LinePoint> > fieldlinesData;
// Read data from fieldlines dictionary
for (int i = 0; i < _filenames.size(); ++i) {
fieldlinesData = getFieldlinesData(_filenames[i], _hintsDictionaries[i]);
// Arrange data for glMultiDrawArrays
for (int j = 0; j < fieldlinesData.size(); ++j) {
_lineStart.push_back(prevEnd);
_lineCount.push_back(fieldlinesData[j].size());
prevEnd = prevEnd + fieldlinesData[j].size();
vertexData.insert( vertexData.end(), fieldlinesData[j].begin(), fieldlinesData[j].end());
_program->setProgramObjectCallback(
[&](ghoul::opengl::ProgramObject*) {
this->_programIsDirty = true;
}
}
LDEBUG("Number of vertices : " << vertexData.size());
);
// ------ FIELDLINES -----------------
glGenVertexArrays(1, &_fieldlineVAO); // generate array
glBindVertexArray(_fieldlineVAO); // bind array
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
glBufferData(GL_ARRAY_BUFFER, vertexData.size()*sizeof(LinePoint), &vertexData.front(), GL_STATIC_DRAW);
// Vertex positions
GLuint vertexLocation = 0;
glEnableVertexAttribArray(vertexLocation);
glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, sizeof(LinePoint), reinterpret_cast<void*>(0));
// Vertex colors
GLuint colorLocation = 1;
glEnableVertexAttribArray(colorLocation);
glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, sizeof(LinePoint), (void*)(sizeof(glm::vec3)));
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind buffer
glBindVertexArray(0); //unbind array
OsEng.ref().configurationManager().getValue("FieldlineProgram", _shader);
return isReady();
return true;
}
bool RenderableFieldlines::deinitialize() {
@@ -156,97 +228,207 @@ bool RenderableFieldlines::deinitialize() {
}
void RenderableFieldlines::render(const RenderData& data) {
_shader->activate();
_shader->setUniform("modelViewProjection", data.camera.viewProjectionMatrix());
_shader->setUniform("modelTransform", glm::mat4(1.0));
_shader->setUniform("cameraViewDir", data.camera.viewDirection());
setPscUniforms(_shader, &data.camera, data.position);
_program->activate();
_program->setUniform("modelViewProjection", data.camera.viewProjectionMatrix());
_program->setUniform("modelTransform", glm::mat4(1.0));
_program->setUniform("cameraViewDir", data.camera.viewDirection());
setPscUniforms(_program, &data.camera, data.position);
_program->setUniform("classification", _classification);
if (!_classification)
_program->setUniform("fieldLineColor", _fieldlineColor);
// ------ DRAW FIELDLINES -----------------
glBindVertexArray(_fieldlineVAO);
glMultiDrawArrays(GL_LINE_STRIP_ADJACENCY, &_lineStart[0], &_lineCount[0], _lineStart.size());
glMultiDrawArrays(
GL_LINE_STRIP_ADJACENCY,
&_lineStart[0],
&_lineCount[0],
static_cast<GLsizei>(_lineStart.size())
);
glBindVertexArray(0);
_shader->deactivate();
_program->deactivate();
}
std::vector<std::vector<LinePoint> > RenderableFieldlines::getFieldlinesData(std::string filename, ghoul::Dictionary hintsDictionary) {
std::string modelString, xVariable, yVariable, zVariable;
KameleonWrapper::Model model;
std::vector<std::vector<LinePoint> > fieldlinesData;
bool classification = false, lorentz = false;
glm::vec4 fieldlineColor = glm::vec4(1.0, 1.0, 1.0, 1.0); // default color if no color or classification is specified
float stepSize = 0.5; // default if no stepsize is specified in hints
if (hintsDictionary.hasKey("Model") && hintsDictionary.getValue("Model", modelString)) {
// ------ MODEL -----------------
if (modelString == "BATSRUS") {
model = KameleonWrapper::Model::BATSRUS;
} else if (modelString == "ENLIL") {
LWARNING("ENLIL model not supported for fieldlines");
return fieldlinesData;
} else {
LWARNING("Hints does not specify a valid 'Model'");
return fieldlinesData;
}
// ------ VARIBLES / LORENTZ -----------------
if (hintsDictionary.hasKey("Variables")) {
bool xVar, yVar, zVar;
xVar = hintsDictionary.getValue("Variables.1", xVariable);
if (xVar && xVariable == "Lorentz") {
lorentz = true;
} else {
yVar = hintsDictionary.getValue("Variables.2", yVariable);
zVar = hintsDictionary.getValue("Variables.3", zVariable);
if (!xVar || !yVar || !zVar) {
LWARNING("Error reading variables! Must be 3 and must exist in CDF data");
return fieldlinesData;
}
}
} else {
LWARNING("Hints does not specify valid 'Variables'");
return fieldlinesData;
}
// ------ STEPSIZE -----------------
if (!hintsDictionary.hasKey("Stepsize") || !hintsDictionary.getValue("Stepsize", stepSize)) {
LDEBUG("No stepsize set for fieldlines. Setting to default value (" << stepSize << ")");
}
// ------ SEEDPOINTS ---------------
ghoul::Dictionary seedpointsDictionary;
_seedPoints.clear();
if (hintsDictionary.hasKey("Seedpoints") && hintsDictionary.getValue("Seedpoints", seedpointsDictionary)) {
glm::vec3 seedPos;
for (const std::string& index : seedpointsDictionary.keys()) {
hintsDictionary.getValue("Seedpoints."+index, seedPos);
_seedPoints.push_back(seedPos);
}
}
// ------ CLASSIFICATION & COLOR -----------
hintsDictionary.getValue("Color", fieldlineColor);
hintsDictionary.getValue("Classification", classification);
} else {
// model unitialized!
assert(false);
}
KameleonWrapper kw(filename);
if (lorentz) {
fieldlinesData = kw.getLorentzTrajectories(_seedPoints, fieldlineColor, stepSize);
} else {
if (classification)
fieldlinesData = kw.getClassifiedFieldLines(xVariable, yVariable, zVariable, _seedPoints, stepSize);
else
fieldlinesData = kw.getFieldLines(xVariable, yVariable, zVariable, _seedPoints, stepSize, fieldlineColor);
void RenderableFieldlines::update(const UpdateData&) {
if (_programIsDirty) {
_program->rebuildFromFile();
_programIsDirty = false;
}
return fieldlinesData;
if (_seedPointsAreDirty) {
loadSeedPoints();
_seedPointsAreDirty = false;
_fieldLinesAreDirty = true;
}
if (_fieldLinesAreDirty) {
std::vector<Line> fieldlines = generateFieldlines();
if (fieldlines.empty())
return ;
int prevEnd = 0;
std::vector<LinePoint> vertexData;
// Arrange data for glMultiDrawArrays
for (int j = 0; j < fieldlines.size(); ++j) {
_lineStart.push_back(prevEnd);
_lineCount.push_back(static_cast<int>(fieldlines[j].size()));
prevEnd = prevEnd + static_cast<int>(fieldlines[j].size());
vertexData.insert(vertexData.end(), fieldlines[j].begin(), fieldlines[j].end());
}
LDEBUG("Number of vertices : " << vertexData.size());
if (_fieldlineVAO == 0)
glGenVertexArrays(1, &_fieldlineVAO);
glBindVertexArray(_fieldlineVAO);
if (_vertexPositionBuffer == 0)
glGenBuffers(1, &_vertexPositionBuffer);
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer);
glBufferData(GL_ARRAY_BUFFER, vertexData.size()*sizeof(LinePoint), &vertexData.front(), GL_STATIC_DRAW);
GLuint vertexLocation = 0;
glEnableVertexAttribArray(vertexLocation);
glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, sizeof(LinePoint), reinterpret_cast<void*>(0));
GLuint colorLocation = 1;
glEnableVertexAttribArray(colorLocation);
glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, sizeof(LinePoint), (void*)(sizeof(glm::vec3)));
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
_fieldLinesAreDirty = false;
}
}
void RenderableFieldlines::loadSeedPoints() {
_seedPoints.clear();
switch (_seedPointSource) {
case SeedPointSourceFile:
loadSeedPointsFromFile();
break;
case SeedPointSourceTable:
loadSeedPointsFromTable();
break;
default:
ghoul_assert(false, "Missing case label");
}
}
void RenderableFieldlines::loadSeedPointsFromFile() {
LINFO("Reading seed points from file '" << _seedPointSourceFile.value() << "'");
std::ifstream seedFile(_seedPointSourceFile);
if (!seedFile.good())
LERROR("Could not open seed points file '" << _seedPointSourceFile.value() << "'");
else {
std::string line;
glm::vec3 point;
while (std::getline(seedFile, line)) {
std::stringstream s(line);
s >> point.x;
s >> point.y;
s >> point.z;
_seedPoints.push_back(std::move(point));
}
}
}
void RenderableFieldlines::loadSeedPointsFromTable() {
// @TODO needs testing ---abock
LINFO("Loading provided list of seed points");
ghoul::Dictionary seedpointsDictionary;
_seedPointsInfo.getValue(keySeedPointsTable, seedpointsDictionary);
glm::vec3 seedPos;
for (const std::string& index : seedpointsDictionary.keys()) {
_fieldlineInfo.getValue(keySeedPointsTable + "." + index, seedPos);
_seedPoints.push_back(seedPos);
}
}
std::vector<RenderableFieldlines::Line> RenderableFieldlines::generateFieldlines() {
std::string type;
bool success = _vectorFieldInfo.getValue(keyVectorFieldType, type);
if (!success) {
LERROR(keyVectorField << " does not contain a '" <<
keyVectorFieldType << "' key");
return {};
}
if (type == vectorFieldTypeVolumeKameleon)
return generateFieldlinesVolumeKameleon();
else {
LERROR(keyVectorField << "." << keyVectorFieldType <<
" does not name a valid type");
return {};
}
}
std::vector<RenderableFieldlines::Line>
RenderableFieldlines::generateFieldlinesVolumeKameleon()
{
std::string model;
bool success = _vectorFieldInfo.getValue(keyVectorFieldVolumeModel, model);
if (!success) {
LERROR(keyVectorField << " does not name a model");
return {};
}
std::string fileName;
success = _vectorFieldInfo.getValue(keyVectorFieldFile, fileName);
if (!success) {
LERROR(keyVectorField << " does not name a file");
return {};
}
fileName = absPath(fileName);
KameleonWrapper::Model modelType;
if (model == vectorFieldKameleonModelBATSRUS)
modelType = KameleonWrapper::Model::BATSRUS;
else {
LERROR(keyVectorField << "." << keyVectorFieldVolumeModel << " model '" <<
model << "' not supported");
return {};
}
std::string v1 = keyVectorFieldVolumeVariable + ".1";
std::string v2 = keyVectorFieldVolumeVariable + ".2";
std::string v3 = keyVectorFieldVolumeVariable + ".3";
bool threeVariables =
_vectorFieldInfo.hasKeyAndValue<std::string>(v1) &&
_vectorFieldInfo.hasKeyAndValue<std::string>(v2) &&
_vectorFieldInfo.hasKeyAndValue<std::string>(v3);
bool lorentzForce =
_vectorFieldInfo.hasKeyAndValue<std::string>(v1) &&
(_vectorFieldInfo.value<std::string>(v1) == vectorFieldKameleonVariableLorentz);
if (!threeVariables && !lorentzForce) {
LERROR(keyVectorField << " does not name variables");
return {};
}
if (threeVariables) {
std::string xVariable, yVariable, zVariable;
_vectorFieldInfo.getValue(v1, xVariable);
_vectorFieldInfo.getValue(v2, yVariable);
_vectorFieldInfo.getValue(v3, zVariable);
KameleonWrapper kw(fileName);
return kw.getClassifiedFieldLines(xVariable, yVariable, zVariable, _seedPoints, _stepSize);
}
if (lorentzForce) {
KameleonWrapper kw(fileName);
return kw.getLorentzTrajectories(_seedPoints, _fieldlineColor, _stepSize);
}
ghoul_assert(false, "Should not reach this");
return {};
}
} // namespace openspace

View File

@@ -136,13 +136,12 @@ bool RenderablePath::fullYearSweep(){
et += _increment;
}
_stride = 8;
_vsize = _varray.size();
_vsize = static_cast<unsigned int>(_varray.size());
_vtotal = static_cast<int>(_vsize / _stride);
return true;
}
RenderablePath::~RenderablePath(){
deinitialize();
}
bool RenderablePath::isReady() const {
@@ -244,7 +243,7 @@ void RenderablePath::update(const UpdateData& data){
double lightTime;
_time = data.time;
_delta = data.delta;
_delta = static_cast<int>(data.delta);
SpiceManager::ref().getTargetState(_target, _observer, _frame, "LT+S", data.time, _pscpos, _pscvel, lightTime);
}

View File

@@ -95,7 +95,6 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
}
RenderablePlane::~RenderablePlane() {
deinitialize();
}
bool RenderablePlane::isReady() const {

View File

@@ -152,12 +152,12 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume(
float* data = new float[length];
#ifdef VOLUME_LOAD_PROGRESSBAR
LINFO("Loading cache: " << cachepath);
ProgressBar pb(dimensions[2]);
ProgressBar pb(static_cast<int>(dimensions[2]));
for (size_t i = 0; i < dimensions[2]; ++i) {
size_t offset = length / dimensions[2];
std::streamsize offsetsize = sizeof(float)*offset;
file.read(reinterpret_cast<char*>(data + offset * i), offsetsize);
pb.print(i);
pb.print(static_cast<int>(i));
}
#else
file.read(reinterpret_cast<char*>(data), sizeof(float)*length);
@@ -195,10 +195,11 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume(
float* data = kw.getUniformSampledVectorValues(xVariable, yVariable, zVariable, dimensions);
if(cache) {
FILE* file = fopen (cachepath.c_str(), "wb");
//FILE* file = fopen (cachepath.c_str(), "wb");
std::ofstream file(cachepath, std::ios::in | std::ios::binary);
size_t length = dimensions[0] * dimensions[1] * dimensions[2];
fwrite(data, sizeof(float), length, file);
fclose(file);
file.write(reinterpret_cast<char*>(data), sizeof(float)*length);
file.close();
}
return new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::RGBA, GL_RGBA, GL_FLOAT, filtermode, wrappingmode);
@@ -329,7 +330,6 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string
std::string line;
while (std::getline(in, line)) {
float intensity = 1.0f;
glm::vec4 rgba = glm::vec4(0.0f);
// tokenize the line
std::istringstream iss(line);
@@ -345,6 +345,7 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string
} else if(key == "upper" && tokenSize == 2) {
upper = stringToNumber<float>(tokens.at(1),upperLowerValidator);
} else if(key == "mappingkey" && tokenSize == 6) {
float intensity = 1.0f;
intensity = stringToNumber<float>(tokens.at(1), intensityValidator);
for(int i = 0; i < 4; ++i)
rgba[i] = stringToNumber<float>(tokens.at(i+2));

View File

@@ -52,6 +52,9 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
, _volumeName("")
, _boxArray(0)
, _vertexPositionBuffer(0)
, _volume(nullptr)
, _transferFunction(nullptr)
, _boxProgram(nullptr)
, _boxScaling(1.0, 1.0, 1.0)
, _w(0.f)
, _updateTransferfunction(false)
@@ -126,9 +129,9 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
_boxScaling = kw.getModelScale();
if (std::get<0>(t) == "R" && std::get<1>(t) == "R" && std::get<2>(t) == "R") {
// Earth radius
_boxScaling.x *= 6.371;
_boxScaling.y *= 6.371;
_boxScaling.z *= 6.371;
_boxScaling.x *= 6.371f;
_boxScaling.y *= 6.371f;
_boxScaling.z *= 6.371f;
_w = 6;
}
else if (std::get<0>(t) == "m" && std::get<1>(t) == "radian" && std::get<2>(t) == "radian") {
@@ -143,9 +146,9 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
_pscOffset = kw.getModelBarycenterOffset();
if (std::get<0>(t) == "R" && std::get<1>(t) == "R" && std::get<2>(t) == "R") {
// Earth radius
_pscOffset[0] *= 6.371;
_pscOffset[1] *= 6.371;
_pscOffset[2] *= 6.371;
_pscOffset[0] *= 6.371f;
_pscOffset[1] *= 6.371f;
_pscOffset[2] *= 6.371f;
_pscOffset[3] = 6;
}
else {
@@ -160,7 +163,6 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
}
RenderableVolumeGL::~RenderableVolumeGL() {
deinitialize();
}
bool RenderableVolumeGL::isReady() const {

View File

@@ -688,7 +688,7 @@ void RenderEngine::storePerformanceMeasurements() {
PerformanceLayoutEntry entries[maxValues];
};
const int nNodes = sceneGraph()->allSceneGraphNodes().size();
const int nNodes = static_cast<int>(sceneGraph()->allSceneGraphNodes().size());
if (!_performanceMemory) {
// Compute the total size

View File

@@ -88,7 +88,6 @@ RenderableConstellationBounds::RenderableConstellationBounds(
}
RenderableConstellationBounds::~RenderableConstellationBounds() {
deinitialize();
}
bool RenderableConstellationBounds::initialize() {
@@ -327,7 +326,6 @@ void RenderableConstellationBounds::fillSelectionProperty() {
for (int i = 0 ; i < _constellationBounds.size(); ++i) {
const ConstellationBound& bound = _constellationBounds[i];
_constellationSelection.addOption( { i, bound.constellationFullName } );
}
}

View File

@@ -123,11 +123,10 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
}
RenderableStars::~RenderableStars() {
deinitialize();
}
bool RenderableStars::isReady() const {
return (_program != nullptr) && (_fullData.size() > 0);
return (_program != nullptr) && (!_fullData.empty());
}
bool RenderableStars::initialize() {

View File

@@ -31,7 +31,7 @@
#include <openspace/query/query.h>
#include <openspace/util/time.h>
#include <openspace/abuffer/abuffer.h>
#include <openspace/engine/gui.h>
#include <openspace/gui/gui.h>
#include "ghoul/logging/logmanager.h"
#include "ghoul/opengl/programobject.h"
@@ -228,16 +228,6 @@ bool SceneGraph::initialize()
_programs.push_back(tmpProgram);
OsEng.ref().configurationManager().setValue("PlaneProgram", tmpProgram);
// Fieldline program
tmpProgram = ProgramObject::Build("Fieldline",
"${SHADERS}/fieldline_vs.glsl",
"${SHADERS}/fieldline_fs.glsl",
"${SHADERS}/fieldline_gs.glsl");
if (!tmpProgram) return false;
tmpProgram->setProgramObjectCallback(cb);
_programs.push_back(tmpProgram);
OsEng.ref().configurationManager().setValue("FieldlineProgram", tmpProgram);
// Done building shaders
double elapsed = std::chrono::duration_cast<second_>(clock_::now()-beginning).count();
LINFO("Time to load scene graph shaders: " << elapsed << " seconds");
@@ -309,8 +299,11 @@ void SceneGraph::scheduleLoadSceneFile(const std::string& sceneDescriptionFilePa
void SceneGraph::clearSceneGraph() {
// deallocate the scene graph. Recursive deallocation will occur
delete _root;
_root = nullptr;
if (_root) {
_root->deinitialize();
delete _root;
_root = nullptr;
}
_nodes.erase(_nodes.begin(), _nodes.end());
_allNodes.erase(_allNodes.begin(), _allNodes.end());
@@ -457,6 +450,13 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
glm::mat4 la = glm::lookAt(c->position().vec3(), fn->worldPosition().vec3(), c->lookUpVector());
c->setRotation(la);
glm::vec3 viewOffset;
if (cameraDictionary.hasKey(constants::scenegraph::keyViewOffset)
&& cameraDictionary.getValue(constants::scenegraph::keyViewOffset, viewOffset)) {
glm::quat rot = glm::quat(viewOffset);
c->rotate(rot);
}
for (SceneGraphNode* node : _nodes) {
std::vector<properties::Property*> properties = node->propertiesRecursive();

View File

@@ -140,10 +140,10 @@ SceneGraphNode::~SceneGraphNode()
bool SceneGraphNode::initialize()
{
if (_renderable != nullptr)
if (_renderable)
_renderable->initialize();
if (_ephemeris != nullptr)
if (_ephemeris)
_ephemeris->initialize();
return true;
@@ -153,16 +153,21 @@ bool SceneGraphNode::deinitialize()
{
LDEBUG("Deinitialize: " << name());
if(_renderable)
if (_renderable) {
_renderable->deinitialize();
delete _renderable;
_renderable = nullptr;
if(_ephemeris)
delete _ephemeris;
_ephemeris = nullptr;
_renderable = nullptr;
}
// deallocate the child nodes and delete them, iterate c++11 style
for (SceneGraphNode* child : _children)
delete child;
if (_ephemeris) {
delete _ephemeris;
_ephemeris = nullptr;
}
for (SceneGraphNode* child : _children) {
child->deinitialize();
delete child;
}
_children.clear();
// reset variables
@@ -251,7 +256,7 @@ void SceneGraphNode::render(const RenderData& data) {
RenderData newData = {data.camera, thisPosition, data.doPerformanceMeasurement};
_performanceRecord.renderTime = 0.f;
_performanceRecord.renderTime = 0;
if (_renderableVisible && _renderable->isVisible() && _renderable->isReady() && _renderable->isEnabled()) {
if (data.doPerformanceMeasurement) {
glFinish();
@@ -314,7 +319,7 @@ PowerScaledScalar SceneGraphNode::calculateBoundingSphere(){
// set the bounding sphere to 0.0
_boundingSphere = 0.0;
if (_children.size() > 0) { // node
if (!_children.empty()) { // node
PowerScaledScalar maxChild;
// loop though all children and find the one furthest away/with the largest
@@ -362,7 +367,7 @@ Renderable* SceneGraphNode::renderable() {
}
// private helper methods
bool SceneGraphNode::sphereInsideFrustum(const psc s_pos, const PowerScaledScalar& s_rad,
bool SceneGraphNode::sphereInsideFrustum(const psc& s_pos, const PowerScaledScalar& s_rad,
const Camera* camera)
{
// direction the camera is looking at in power scale

View File

@@ -512,7 +512,6 @@ bool ScriptEngine::registerLuaLibrary(lua_State* state, const LuaLibrary& librar
bool ScriptEngine::writeDocumentation(const std::string& filename, const std::string& type) const {
if (type == "text") {
// The additional space between the longest function name and the descriptions
const size_t AdditionalSpace = 5;
LDEBUG("Writing Lua documentation of type '" << type <<
"' to file '" << filename << "'");
std::ofstream file(filename);

View File

@@ -35,7 +35,15 @@ namespace openspace {
Camera::Camera()
: _cameraDirection(0.f, 0.f, 0.f)
: _maxFov(0.f)
, _sinMaxFov(0.f)
, _position()
, _viewProjectionMatrix()
, _modelMatrix()
, _viewMatrix()
, _projectionMatrix()
, _viewDirection()
, _cameraDirection(0.f, 0.f, 0.f)
, _scaling(1.f, 0.f)
//, _viewRotation(glm::quat(glm::vec3(0.f, 0.f, 0.f)))
, _viewRotationMatrix(1.f)

View File

@@ -53,6 +53,21 @@ KameleonWrapper::KameleonWrapper()
, _model(nullptr)
, _type(Model::Unknown)
, _interpolator(nullptr)
, _xMin(0.f)
, _xMax(0.f)
, _yMin(0.f)
, _yMax(0.f)
, _zMin(0.f)
, _zMax(0.f)
, _xValidMin(0.f)
, _xValidMax(0.f)
, _yValidMin(0.f)
, _yValidMax(0.f)
, _zValidMin(0.f)
, _zValidMax(0.f)
, _xCoordVar("")
, _yCoordVar("")
, _zCoordVar("")
, _gridType(GridType::Unknown)
{}
@@ -61,6 +76,21 @@ KameleonWrapper::KameleonWrapper(const std::string& filename)
, _model(nullptr)
, _type(Model::Unknown)
, _interpolator(nullptr)
, _xMin(0.f)
, _xMax(0.f)
, _yMin(0.f)
, _yMax(0.f)
, _zMin(0.f)
, _zMax(0.f)
, _xValidMin(0.f)
, _xValidMax(0.f)
, _yValidMin(0.f)
, _yValidMax(0.f)
, _zValidMin(0.f)
, _zValidMax(0.f)
, _xCoordVar("")
, _yCoordVar("")
, _zCoordVar("")
, _gridType(GridType::Unknown)
{
open(filename);
@@ -152,7 +182,7 @@ float* KameleonWrapper::getUniformSampledValues(
assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0);
LINFO("Loading variable " << var << " from CDF data with a uniform sampling");
int size = outDimensions.x*outDimensions.y*outDimensions.z;
unsigned int size = static_cast<unsigned int>(outDimensions.x*outDimensions.y*outDimensions.z);
float* data = new float[size];
double* doubleData = new double[size];
@@ -168,7 +198,7 @@ float* KameleonWrapper::getUniformSampledValues(
// HISTOGRAM
const int bins = 200;
const float truncLim = 0.9;
const float truncLim = 0.9f;
std::vector<int> histogram (bins,0);
auto mapToHistogram = [varMin, varMax, bins](double val) {
double zeroToOne = (val-varMin)/(varMax-varMin);
@@ -178,14 +208,14 @@ float* KameleonWrapper::getUniformSampledValues(
return glm::clamp(izerotoone, 0, bins-1);
};
ProgressBar pb(outDimensions.x);
ProgressBar pb(static_cast<int>(outDimensions.x));
for (int x = 0; x < outDimensions.x; ++x) {
pb.print(x);
for (int y = 0; y < outDimensions.y; ++y) {
for (int z = 0; z < outDimensions.z; ++z) {
int index = x + y*outDimensions.x + z*outDimensions.x*outDimensions.y;
unsigned int index = static_cast<unsigned int>(x + y*outDimensions.x + z*outDimensions.x*outDimensions.y);
if (_gridType == GridType::Spherical) {
// Put r in the [0..sqrt(3)] range
@@ -223,7 +253,11 @@ float* KameleonWrapper::getUniformSampledValues(
// Convert from [0, 2pi] rad to [0, 360] degrees
phiPh = phiPh*180.f/M_PI;
// Sample
value = _interpolator->interpolate(var, rPh, thetaPh, phiPh);
value = _interpolator->interpolate(
var,
static_cast<float>(rPh),
static_cast<float>(thetaPh),
static_cast<float>(phiPh));
// value = _interpolator->interpolate(var, rPh, phiPh, thetaPh);
}
@@ -246,7 +280,11 @@ float* KameleonWrapper::getUniformSampledValues(
// get interpolated data value for (xPos, yPos, zPos)
// swap yPos and zPos because model has Z as up
double value = _interpolator->interpolate(var, xPos, zPos, yPos);
double value = _interpolator->interpolate(
var,
static_cast<float>(xPos),
static_cast<float>(zPos),
static_cast<float>(yPos));
doubleData[index] = value;
histogram[mapToHistogram(value)]++;
}
@@ -275,7 +313,7 @@ float* KameleonWrapper::getUniformSampledValues(
int sum = 0;
int stop = 0;
const int sumuntil = size * truncLim;
const int sumuntil = static_cast<int>(static_cast<float>(size) * truncLim);
for(int i = 0; i < bins; ++i) {
sum += histogram[i];
if(sum > sumuntil) {
@@ -292,7 +330,7 @@ float* KameleonWrapper::getUniformSampledValues(
varMax = varMin + dist;
//LDEBUG(var << "Min: " << varMin);
//LDEBUG(var << "Max: " << varMax);
for(int i = 0; i < size; ++i) {
for(size_t i = 0; i < size; ++i) {
double normalizedVal = (doubleData[i]-varMin)/(varMax-varMin);
data[i] = static_cast<float>(glm::clamp(normalizedVal, 0.0, 1.0));
@@ -325,7 +363,7 @@ float* KameleonWrapper::getUniformSampledVectorValues(
LINFO("Loading variables " << xVar << " " << yVar << " " << zVar << " from CDF data with a uniform sampling");
int channels = 4;
int size = channels*outDimensions.x*outDimensions.y*outDimensions.z;
unsigned int size = static_cast<unsigned int>(channels*outDimensions.x*outDimensions.y*outDimensions.z);
float* data = new float[size];
float varXMin = _model->getVariableAttribute(xVar, "actual_min").getAttributeFloat();
@@ -346,14 +384,14 @@ float* KameleonWrapper::getUniformSampledVectorValues(
//LDEBUG(zVar << "Min: " << varZMin);
//LDEBUG(zVar << "Max: " << varZMax);
ProgressBar pb(outDimensions.x);
ProgressBar pb(static_cast<int>(outDimensions.x));
for (int x = 0; x < outDimensions.x; ++x) {
pb.print(x);
for (int y = 0; y < outDimensions.y; ++y) {
for (int z = 0; z < outDimensions.z; ++z) {
int index = x*channels + y*channels*outDimensions.x + z*channels*outDimensions.x*outDimensions.y;
unsigned int index = static_cast<unsigned int>(x*channels + y*channels*outDimensions.x + z*channels*outDimensions.x*outDimensions.y);
if(_gridType == GridType::Cartesian) {
float xPos = _xMin + stepX*x;
@@ -475,7 +513,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getLorentzTrajectories(
minusTraj = traceLorentzTrajectory(seedPoint, stepsize, -1.0);
//minusTraj.erase(minusTraj.begin());
int plusNum = plusTraj.size();
size_t plusNum = plusTraj.size();
minusTraj.insert(minusTraj.begin(), plusTraj.rbegin(), plusTraj.rend());
// write colors and convert positions to meter
@@ -581,21 +619,21 @@ KameleonWrapper::TraceLine KameleonWrapper::traceCartesianFieldline(
k1.z = _interpolator->interpolate(zID, pos.x, pos.y, pos.z);
k1 = (float)direction*glm::normalize(k1);
stepX=stepX*stepSize, stepY=stepY*stepSize, stepZ=stepZ*stepSize;
k2.x = _interpolator->interpolate(xID, pos.x+(stepX/2.0)*k1.x, pos.y+(stepY/2.0)*k1.y, pos.z+(stepZ/2.0)*k1.z);
k2.y = _interpolator->interpolate(yID, pos.x+(stepX/2.0)*k1.x, pos.y+(stepY/2.0)*k1.y, pos.z+(stepZ/2.0)*k1.z);
k2.z = _interpolator->interpolate(zID, pos.x+(stepX/2.0)*k1.x, pos.y+(stepY/2.0)*k1.y, pos.z+(stepZ/2.0)*k1.z);
k2.x = _interpolator->interpolate(xID, pos.x+(stepX/2.0f)*k1.x, pos.y+(stepY/2.0f)*k1.y, pos.z+(stepZ/2.0f)*k1.z);
k2.y = _interpolator->interpolate(yID, pos.x+(stepX/2.0f)*k1.x, pos.y+(stepY/2.0f)*k1.y, pos.z+(stepZ/2.0f)*k1.z);
k2.z = _interpolator->interpolate(zID, pos.x+(stepX/2.0f)*k1.x, pos.y+(stepY/2.0f)*k1.y, pos.z+(stepZ/2.0f)*k1.z);
k2 = (float)direction*glm::normalize(k2);
k3.x = _interpolator->interpolate(xID, pos.x+(stepX/2.0)*k2.x, pos.y+(stepY/2.0)*k2.y, pos.z+(stepZ/2.0)*k2.z);
k3.y = _interpolator->interpolate(yID, pos.x+(stepX/2.0)*k2.x, pos.y+(stepY/2.0)*k2.y, pos.z+(stepZ/2.0)*k2.z);
k3.z = _interpolator->interpolate(zID, pos.x+(stepX/2.0)*k2.x, pos.y+(stepY/2.0)*k2.y, pos.z+(stepZ/2.0)*k2.z);
k3.x = _interpolator->interpolate(xID, pos.x+(stepX/2.0f)*k2.x, pos.y+(stepY/2.0f)*k2.y, pos.z+(stepZ/2.0f)*k2.z);
k3.y = _interpolator->interpolate(yID, pos.x+(stepX/2.0f)*k2.x, pos.y+(stepY/2.0f)*k2.y, pos.z+(stepZ/2.0f)*k2.z);
k3.z = _interpolator->interpolate(zID, pos.x+(stepX/2.0f)*k2.x, pos.y+(stepY/2.0f)*k2.y, pos.z+(stepZ/2.0f)*k2.z);
k3 = (float)direction*glm::normalize(k3);
k4.x = _interpolator->interpolate(xID, pos.x+stepX*k3.x, pos.y+stepY*k3.y, pos.z+stepZ*k3.z);
k4.y = _interpolator->interpolate(yID, pos.x+stepX*k3.x, pos.y+stepY*k3.y, pos.z+stepZ*k3.z);
k4.z = _interpolator->interpolate(zID, pos.x+stepX*k3.x, pos.y+stepY*k3.y, pos.z+stepZ*k3.z);
k4 = (float)direction*glm::normalize(k4);
pos.x = pos.x + (stepX/6.0)*(k1.x + 2.0*k2.x + 2.0*k3.x + k4.x);
pos.y = pos.y + (stepY/6.0)*(k1.y + 2.0*k2.y + 2.0*k3.y + k4.y);
pos.z = pos.z + (stepZ/6.0)*(k1.z + 2.0*k2.z + 2.0*k3.z + k4.z);
pos.x = pos.x + (stepX/6.0f)*(k1.x + 2.0f*k2.x + 2.0f*k3.x + k4.x);
pos.y = pos.y + (stepY/6.0f)*(k1.y + 2.0f*k2.y + 2.0f*k3.y + k4.y);
pos.z = pos.z + (stepZ/6.0f)*(k1.z + 2.0f*k2.z + 2.0f*k3.z + k4.z);
++numSteps;
if (numSteps > maxSteps) {
@@ -692,13 +730,13 @@ KameleonWrapper::TraceLine KameleonWrapper::traceLorentzTrajectory(
k4 = eCharge*(E + glm::cross(tmpV, B));
k4 = glm::normalize(k4);
pos.x = pos.x + stepX*v0.x + (stepX*stepX/6.0)*(k1.x + k2.x + k3.x);
pos.y = pos.y + stepY*v0.y + (stepY*stepY/6.0)*(k1.y + k2.y + k3.y);
pos.z = pos.z + stepZ*v0.z + (stepZ*stepZ/6.0)*(k1.z + k2.z + k3.z);
pos.x = pos.x + stepX*v0.x + (stepX*stepX/6.0f)*(k1.x + k2.x + k3.x);
pos.y = pos.y + stepY*v0.y + (stepY*stepY/6.0f)*(k1.y + k2.y + k3.y);
pos.z = pos.z + stepZ*v0.z + (stepZ*stepZ/6.0f)*(k1.z + k2.z + k3.z);
v0.x = v0.x + (stepX/6.0)*(k1.x + 2.0*k2.x + 2.0*k3.x + k4.z);
v0.y = v0.y + (stepY/6.0)*(k1.y + 2.0*k2.y + 2.0*k3.y + k4.y);
v0.z = v0.z + (stepZ/6.0)*(k1.z + 2.0*k2.z + 2.0*k3.z + k4.z);
v0.x = v0.x + (stepX/6.0f)*(k1.x + 2.0f*k2.x + 2.0f*k3.x + k4.z);
v0.y = v0.y + (stepY/6.0f)*(k1.y + 2.0f*k2.y + 2.0f*k3.y + k4.y);
v0.z = v0.z + (stepZ/6.0f)*(k1.z + 2.0f*k2.z + 2.0f*k3.z + k4.z);
++numSteps;
if (numSteps > maxSteps) {

View File

@@ -33,6 +33,7 @@ ProgressBar::ProgressBar(int end, int width)
ProgressBar::ProgressBar(int end, int width, std::ostream& stream)
: _width(width)
, _previous(-1)
, _end(end)
, _stream(stream)
{
@@ -47,7 +48,7 @@ void ProgressBar::print(int current) {
float progress = static_cast<float>(current) / static_cast<float>(_end - 1);
int iprogress = static_cast<int>(progress*100.0f);
if (iprogress != _previous) {
int pos = _width * progress;
int pos = static_cast<int>(static_cast<float>(_width)* progress);
int eqWidth = pos + 1;
int spWidth = _width - pos + 2;
_stream << "[" << std::setfill('=') << std::setw(eqWidth)