untabify to make merge easier

This commit is contained in:
Michael Nilsson
2016-04-20 15:21:30 -04:00
parent 07dfafeddb
commit c72536fbbc
269 changed files with 11414 additions and 11414 deletions

View File

@@ -79,8 +79,8 @@ private:
//class MainWindow : public QWidget {
//Q_OBJECT
//public:
// MainWindow();
// ~MainWindow();
// MainWindow();
// ~MainWindow();
//
// std::string nextTarget() const;
//
@@ -94,7 +94,7 @@ private:
// void onSocketConnected();
// void onSocketDisconnected();
//
// void readTcpData();
// void readTcpData();
// void handleStatusMessage(QByteArray data);
// void handlePlaybook(QByteArray data);
//
@@ -106,7 +106,7 @@ private:
// InformationWidget* _informationWidget;
// TimelineWidget* _timelineWidget;
//
// QTcpSocket* _socket;
// QTcpSocket* _socket;
//
// bool _hasHongKangTimeline = false;
// bool _hasLabelTimeline = false;

View File

@@ -183,7 +183,7 @@ int main(int argc, char** argv) {
}
void mainInitFunc() {
//is this node the master? (must be set after call to _sgctEngine->init())
//is this node the master? (must be set after call to _sgctEngine->init())
OsEng.setMaster(_sgctEngine->isMaster());
bool success = OsEng.initialize();

View File

@@ -32,7 +32,7 @@
class ConfigurationWidget : public QWidget {
Q_OBJECT
public:
ConfigurationWidget(QWidget* parent);
ConfigurationWidget(QWidget* parent);
void socketConnected();
void socketDisconnected();

View File

@@ -35,7 +35,7 @@ class QSlider;
class ControlWidget : public QWidget {
Q_OBJECT
public:
ControlWidget(QWidget* parent);
ControlWidget(QWidget* parent);
void update(QString currentTime, QString currentDelta);

View File

@@ -30,7 +30,7 @@
class InformationWidget : public QTextEdit {
Q_OBJECT
public:
InformationWidget(QWidget* parent);
InformationWidget(QWidget* parent);
void socketConnected();
void socketDisconnected();

View File

@@ -28,15 +28,15 @@
static const QString style = R"style(
QWidget {
background-color: rgb(80, 80, 80);
font-family: Helvetica;
background-color: rgb(80, 80, 80);
font-family: Helvetica;
}
QGroupBox {
background-color: qlineargradient(
x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #858585,
stop: 1 #959595);
x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #858585,
stop: 1 #959595);
border: 2px solid gray;
border-radius: 5px;
margin-top: 4ex;
@@ -44,7 +44,7 @@ QGroupBox {
}
QGroupBox::title {
background-color: #E0E0E0;
background-color: #E0E0E0;
border: 2px solid gray;
border-radius: 5px;
subcontrol-origin: margin;
@@ -60,10 +60,10 @@ QSlider::groove:horizontal {
border: 1px solid #999999;
height: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
background: qlineargradient(
x1:0, y1:0, x2:1, y2:0,
stop:0 #c4c4c4,
stop:0.5 #555555,
stop:1 #c4c4c4
x1:0, y1:0, x2:1, y2:0,
stop:0 #c4c4c4,
stop:0.5 #555555,
stop:1 #c4c4c4
);
margin: 2px 0;
}
@@ -77,7 +77,7 @@ QSlider::handle:horizontal {
}
QPushButton {
background-color: lightgray;
background-color: lightgray;
border-style: outset;
border-width: 0.5px;
border-radius: 5px;
@@ -87,16 +87,16 @@ QPushButton {
}
QPushButton#connection {
background-color: lightgreen;
background-color: lightgreen;
}
QPushButton#connection:pressed {
background-color: green;
background-color: green;
}
QPushButton#pause, QPushButton#play {
padding: 5px;
padding: 5px;
}
QPushButton#pause:pressed, QPushButton#play:pressed, QPushButton:pressed {
@@ -112,7 +112,7 @@ QCombobox {
}
QComboBox:editable {
background: lightgrey;
background: lightgrey;
}
QComboBox QAbstractItemView {
@@ -123,34 +123,34 @@ QComboBox QAbstractItemView {
}
QLabel#label {
font-size: 13px;
background-color: transparent;
font-variant: small-caps;
font-size: 13px;
background-color: transparent;
font-variant: small-caps;
}
QLabel#value {
font-family: monospace;
font-weight: bold;
font-size: 14px;
background-color: transparent;
font-family: monospace;
font-weight: bold;
font-size: 14px;
background-color: transparent;
}
QWidget#background {
background-color: transparent;
background-color: transparent;
}
QTextEdit {
font-family: monospace;
font-family: monospace;
}
)style";
int main(int argc, char** argv) {
QApplication app(argc, argv);
QApplication app(argc, argv);
app.setStyleSheet(style);
MainWindow window;
window.show();
MainWindow window;
window.show();
return app.exec();
return app.exec();
}

View File

@@ -67,9 +67,9 @@ MainWindow::MainWindow()
, _timeControlWidget(nullptr)
, _informationWidget(nullptr)
, _timelineWidget(nullptr)
, _socket(nullptr)
, _socket(nullptr)
{
setWindowTitle("OpenSpace Timeline");
setWindowTitle("OpenSpace Timeline");
_configurationWidget = new ConfigurationWidget(this);
_configurationWidget->setMinimumWidth(350);
@@ -79,7 +79,7 @@ MainWindow::MainWindow()
_informationWidget->setMinimumWidth(350);
_timelineWidget = new TimelineWidget(this);
QGridLayout* layout = new QGridLayout;
QGridLayout* layout = new QGridLayout;
layout->addWidget(_configurationWidget, 0, 0);
layout->addWidget(_timeControlWidget, 1, 0);
layout->addWidget(_informationWidget, 2, 0);
@@ -102,7 +102,7 @@ MainWindow::MainWindow()
this, SLOT(sendScript(QString))
);
setLayout(layout);
setLayout(layout);
_configurationWidget->socketDisconnected();
_timeControlWidget->socketDisconnected();
@@ -111,7 +111,7 @@ MainWindow::MainWindow()
}
MainWindow::~MainWindow() {
delete _socket;
delete _socket;
}
void MainWindow::onConnect(QString host, QString port) {

View File

@@ -38,8 +38,8 @@ class TimelineWidget;
class MainWindow : public QWidget {
Q_OBJECT
public:
MainWindow();
~MainWindow();
MainWindow();
~MainWindow();
std::string nextTarget() const;
@@ -53,7 +53,7 @@ private slots:
void onSocketConnected();
void onSocketDisconnected();
void readTcpData();
void readTcpData();
void handleStatusMessage(QByteArray data);
QByteArray handlePlaybook(QByteArray data);
void printMapping(QByteArray data);
@@ -66,7 +66,7 @@ private:
InformationWidget* _informationWidget;
TimelineWidget* _timelineWidget;
QTcpSocket* _socket;
QTcpSocket* _socket;
bool _isConnected = false;
};

View File

@@ -38,7 +38,7 @@ class QPaintEvent;
class TimelineWidget : public QWidget {
Q_OBJECT
public:
TimelineWidget(QWidget* parent);
TimelineWidget(QWidget* parent);
void setData(std::vector<Image> images, std::map<uint8_t, std::string> targetMap, std::map<uint16_t, std::string> instrumentMap);
void setCurrentTime(std::string currentTime, double et);

View File

@@ -66,8 +66,8 @@ public:
static bool isInitialized();
static OpenSpaceEngine& ref();
bool isMaster();
void setMaster(bool master);
bool isMaster();
void setMaster(bool master);
double runTime();
void setRunTime(double t);
@@ -75,29 +75,29 @@ public:
ConfigurationManager& configurationManager();
interaction::InteractionHandler& interactionHandler();
RenderEngine& renderEngine();
scripting::ScriptEngine& scriptEngine();
scripting::ScriptEngine& scriptEngine();
NetworkEngine& networkEngine();
LuaConsole& console();
LuaConsole& console();
ModuleEngine& moduleEngine();
network::ParallelConnection& parallelConnection();
properties::PropertyOwner& globalPropertyOwner();
WindowWrapper& windowWrapper();
ghoul::fontrendering::FontManager& fontManager();
gui::GUI& gui();
gui::GUI& gui();
// SGCT callbacks
bool initialize();
bool initializeGL();
void preSynchronization();
void postSynchronizationPreDraw();
void render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix);
void postDraw();
void render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix);
void postDraw();
void keyboardCallback(Key key, KeyModifier mod, KeyAction action);
void charCallback(unsigned int codepoint, KeyModifier mod);
void charCallback(unsigned int codepoint, KeyModifier mod);
void mouseButtonCallback(MouseButton button, MouseAction action);
void mousePositionCallback(double x, double y);
void mouseScrollWheelCallback(double pos);
void externalControlCallback(const char* receivedChars, int size, int clientId);
void externalControlCallback(const char* receivedChars, int size, int clientId);
void encode();
void decode();
@@ -110,22 +110,22 @@ private:
OpenSpaceEngine(std::string programName, std::unique_ptr<WindowWrapper> windowWrapper);
~OpenSpaceEngine();
void clearAllWindows();
bool gatherCommandlineArguments();
bool loadSpiceKernels();
void clearAllWindows();
bool gatherCommandlineArguments();
bool loadSpiceKernels();
void loadFonts();
void runScripts(const ghoul::Dictionary& scripts);
void runStartupScripts();
void configureLogging();
void configureLogging();
// Components
std::unique_ptr<ConfigurationManager> _configurationManager;
std::unique_ptr<interaction::InteractionHandler> _interactionHandler;
std::unique_ptr<RenderEngine> _renderEngine;
std::unique_ptr<scripting::ScriptEngine> _scriptEngine;
std::unique_ptr<scripting::ScriptEngine> _scriptEngine;
std::unique_ptr<NetworkEngine> _networkEngine;
std::unique_ptr<ghoul::cmdparser::CommandlineParser> _commandlineParser;
std::unique_ptr<LuaConsole> _console;
std::unique_ptr<ghoul::cmdparser::CommandlineParser> _commandlineParser;
std::unique_ptr<LuaConsole> _console;
std::unique_ptr<ModuleEngine> _moduleEngine;
std::unique_ptr<gui::GUI> _gui;
std::unique_ptr<network::ParallelConnection> _parallelConnection;
@@ -136,7 +136,7 @@ private:
std::unique_ptr<properties::PropertyOwner> _globalPropertyNamespace;
std::unique_ptr<SyncBuffer> _syncBuffer;
bool _isMaster;
bool _isMaster;
double _runTime;
static OpenSpaceEngine* _engine;

View File

@@ -116,7 +116,7 @@ public:
*/
virtual int currentNumberOfAaSamples() const;
/**
/**
* Returns <code>true</code> if the current rendering method is regular, i.e., it is
* a flat projection without non-linear distortions. Returns <code>false</code> in
* other cases, for example fisheye projections. On default, this method will return

View File

@@ -37,14 +37,14 @@ class InteractionHandler;
class Controller {
public:
Controller() :
_handler(nullptr)
{}
Controller() :
_handler(nullptr)
{}
void setHandler(InteractionHandler* handler);
void setHandler(InteractionHandler* handler);
protected:
InteractionHandler* _handler;
InteractionHandler* _handler;
};
} // namespace interaction

View File

@@ -14,39 +14,39 @@ enum class InputDevice {NONE, UNKNOWN, SPACENAVIGATOR, XBOX};
class DeviceIdentifier {
public:
static DeviceIdentifier& ref();
virtual ~DeviceIdentifier();
static DeviceIdentifier& ref();
virtual ~DeviceIdentifier();
static void init();
static void deinit();
static bool isInitialized();
void scanDevices();
const int numberOfDevices() const;
const InputDevice type(const int device) const;
void update();
void update(const int device);
static void init();
static void deinit();
static bool isInitialized();
void scanDevices();
const int numberOfDevices() const;
const InputDevice type(const int device) const;
void update();
void update(const int device);
const int getButtons(const int device, unsigned char **buttons = nullptr) const;
const int getAxes(const int device, float **axespos = nullptr) const;
void get(const int device, unsigned char **buttons, float **axespos) const;
const int getButtons(const int device, unsigned char **buttons = nullptr) const;
const int getAxes(const int device, float **axespos = nullptr) const;
void get(const int device, unsigned char **buttons, float **axespos) const;
private:
// singleton
static DeviceIdentifier* this_;
// singleton
static DeviceIdentifier* this_;
DeviceIdentifier(void);
DeviceIdentifier(const DeviceIdentifier& src);
DeviceIdentifier& operator=(const DeviceIdentifier& rhs);
// member variables
int devices_;
std::array<InputDevice, MAXDEVICES> inputDevice_;
std::array<int, MAXDEVICES> numberOfAxes_;
std::array<int, MAXDEVICES> numberOfButtons_;
std::array<float *, MAXDEVICES> axesPos_;
std::array<unsigned char *, MAXDEVICES> buttons_;
// member variables
int devices_;
std::array<InputDevice, MAXDEVICES> inputDevice_;
std::array<int, MAXDEVICES> numberOfAxes_;
std::array<int, MAXDEVICES> numberOfButtons_;
std::array<float *, MAXDEVICES> axesPos_;
std::array<unsigned char *, MAXDEVICES> buttons_;
};

View File

@@ -9,14 +9,14 @@ namespace openspace {
class ExternalConnectionController: public ExternalControl {
public:
// constructors & destructor
ExternalConnectionController();
~ExternalConnectionController();
// constructors & destructor
ExternalConnectionController();
~ExternalConnectionController();
private:
std::vector<ExternalControl*> controllers;
std::vector<ExternalControl*> controllers;
};
} // namespace openspace

View File

@@ -10,17 +10,17 @@ namespace openspace {
class ExternalControl {
public:
// constructors & destructor
ExternalControl();
virtual ~ExternalControl();
virtual void update();
void rotate(const glm::quat &rotation);
void orbit(const glm::quat &rotation);
void distance(const PowerScaledScalar &distance);
// constructors & destructor
ExternalControl();
virtual ~ExternalControl();
virtual void update();
void rotate(const glm::quat &rotation);
void orbit(const glm::quat &rotation);
void distance(const PowerScaledScalar &distance);
protected:
};

View File

@@ -8,19 +8,19 @@
//class JoystickExternalControl: public PythonExternalControl {
//public:
//
// // constructors & destructor
// JoystickExternalControl(const char *filename);
// ~JoystickExternalControl();
//
// void setInputDevice(const int device);
// void update();
// // constructors & destructor
// JoystickExternalControl(const char *filename);
// ~JoystickExternalControl();
//
// void setInputDevice(const int device);
// void update();
//
//private:
//
// // joystick
// int inputDevice_;
// int numberOfButtons_;
// int numberOfAxes_;
// // joystick
// int inputDevice_;
// int numberOfButtons_;
// int numberOfAxes_;
//};
//
//} // namespace openspace

View File

@@ -8,15 +8,15 @@
//class KeyboardExternalControl: public PythonExternalControl {
//public:
//
// // constructors & destructor
// KeyboardExternalControl(const char *filename);
// ~KeyboardExternalControl();
// // constructors & destructor
// KeyboardExternalControl(const char *filename);
// ~KeyboardExternalControl();
//
// void update();
//
// void keyboardCallback(int key, int action);
// void update();
//
// void keyboardCallback(int key, int action);
//private:
// int *keys_;
// int *keys_;
//
//};
//

View File

@@ -8,18 +8,18 @@
//class MouseExternalControl: public PythonExternalControl {
//public:
//
// // constructors & destructor
// MouseExternalControl(const char *filename);
// ~MouseExternalControl();
// // constructors & destructor
// MouseExternalControl(const char *filename);
// ~MouseExternalControl();
//
// void update();
//
// void mouseButtonCallback(int key, int action);
// void mousePosCallback(int x, int y);
// void mouseScrollCallback(int pos);
// void update();
//
// void mouseButtonCallback(int key, int action);
// void mousePosCallback(int x, int y);
// void mouseScrollCallback(int pos);
//private:
//
// int x_, y_, pos_, button1_, button2_, button3_;
// int x_, y_, pos_, button1_, button2_, button3_;
//
//};
//

View File

@@ -12,22 +12,22 @@
//class PythonExternalControl: public ExternalControl {
//public:
//
// // constructors & destructor
// PythonExternalControl(const char *filename);
// ~PythonExternalControl();
// // constructors & destructor
// PythonExternalControl(const char *filename);
// ~PythonExternalControl();
//
// static PyMethodDef* getMethodDef();
//
// void message(const char *text);
// virtual void update();
// void clear();
// static PyMethodDef* getMethodDef();
//
// void message(const char *text);
// virtual void update();
// void clear();
//private:
// PythonScript ps_;
// PythonScript ps_;
//
//protected:
// void run();
// int pyarrSize_;
// PyObject **pyarr_;
// void run();
// int pyarrSize_;
// PyObject **pyarr_;
//};
//
//} // namespace openspace

View File

@@ -11,14 +11,14 @@ namespace openspace {
class RandomExternalControl: public ExternalControl {
public:
// constructors & destructor
RandomExternalControl();
~RandomExternalControl();
// constructors & destructor
RandomExternalControl();
~RandomExternalControl();
private:
std::mutex inputGuard;
bool *keepGoing_;
// std::thread *backgroundThread;
std::mutex inputGuard;
bool *keepGoing_;
// std::thread *backgroundThread;
};
} // namespace openspace

View File

@@ -35,20 +35,20 @@ namespace interaction {
class KeyboardController : public Controller {
public:
virtual ~KeyboardController() {};
virtual void keyPressed(KeyAction action, Key key, KeyModifier modifier) = 0;
virtual void keyPressed(KeyAction action, Key key, KeyModifier modifier) = 0;
};
class KeyboardControllerFixed : public KeyboardController {
public:
void keyPressed(KeyAction action, Key key, KeyModifier modifier);
void keyPressed(KeyAction action, Key key, KeyModifier modifier);
};
class KeyboardControllerLua : public KeyboardController {
public:
void keyPressed(KeyAction action, Key key, KeyModifier modifier);
void keyPressed(KeyAction action, Key key, KeyModifier modifier);
protected:
std::string keyToString(Key key, KeyModifier mod) const;
std::string keyToString(Key key, KeyModifier mod) const;
};
} // namespace interaction

View File

@@ -36,35 +36,35 @@ namespace openspace {
class LuaConsole {
public:
LuaConsole();
LuaConsole();
void initialize();
void deinitialize();
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
void charCallback(unsigned int codepoint, KeyModifier modifier);
void render();
void render();
Key commandInputButton();
bool isVisible() const;
void setVisible(bool visible);
void toggleVisibility();
static scripting::ScriptEngine::LuaLibrary luaLibrary();
bool isVisible() const;
void setVisible(bool visible);
void toggleVisibility();
static scripting::ScriptEngine::LuaLibrary luaLibrary();
private:
void addToCommand(std::string c);
std::string UnicodeToUTF8(unsigned int codepoint);
std::string UnicodeToUTF8(unsigned int codepoint);
size_t _inputPosition;
std::vector<std::string> _commandsHistory;
size_t _activeCommand;
std::vector<std::string> _commands;
size_t _inputPosition;
std::vector<std::string> _commandsHistory;
size_t _activeCommand;
std::vector<std::string> _commands;
std::string _filename;
std::string _filename;
struct {
int lastIndex;
@@ -72,7 +72,7 @@ private:
std::string initialValue;
} _autoCompleteInfo;
bool _isVisible;
bool _isVisible;
};
} // namespace openspace

View File

@@ -36,66 +36,66 @@ namespace interaction {
class MouseController : public Controller {
public:
MouseController();
MouseController();
virtual ~MouseController() {}
virtual void button(MouseButton button, MouseAction action) = 0;
virtual void move(float x, float y) = 0;
virtual void scrollWheel(int pos) = 0;
virtual void update(const double& dt) = 0;
virtual void button(MouseButton button, MouseAction action) = 0;
virtual void move(float x, float y) = 0;
virtual void scrollWheel(int pos) = 0;
virtual void update(const double& dt) = 0;
protected:
glm::vec3 _lastTrackballPos;
bool _isMouseBeingPressedAndHeld;
glm::vec3 _lastTrackballPos;
bool _isMouseBeingPressedAndHeld;
glm::vec3 mapToTrackball(glm::vec2 mousePos);
glm::vec3 mapToTrackball(glm::vec2 mousePos);
glm::vec3 mapToCamera(glm::vec3 trackballPos);
glm::vec3 mapToCamera(glm::vec3 trackballPos);
void trackballRotate(int x, int y);
void trackballRotate(int x, int y);
};
class TrackballMouseController : public MouseController {
public:
TrackballMouseController();
TrackballMouseController();
void button(MouseButton button, MouseAction action) override;
void button(MouseButton button, MouseAction action) override;
void move(float x, float y) override;
void move(float x, float y) override;
void scrollWheel(int pos) override;
void scrollWheel(int pos) override;
void update(const double& dt) override;
void update(const double& dt) override;
protected:
bool _leftMouseButtonDown;
glm::vec3 _previousTrackballPos;
bool _leftMouseButtonDown;
glm::vec3 _previousTrackballPos;
};
class OrbitalMouseController : public MouseController {
public:
OrbitalMouseController();
OrbitalMouseController();
void button(MouseButton button, MouseAction action) override;
void button(MouseButton button, MouseAction action) override;
void move(float x, float y) override;
void move(float x, float y) override;
void scrollWheel(int pos) override;
void scrollWheel(int pos) override;
void update(const double& dt) override;
void update(const double& dt) override;
protected:
bool _leftMouseButtonDown;
bool _rightMouseButtonDown;
bool _middleMouseButtonDown;
glm::vec2 _previousCursorPos[3];
glm::vec2 _currentCursorPos;
glm::vec2 _currentCursorDiff[3];
float _rotationSpeed;
float _navigationSpeed;
bool _leftMouseButtonDown;
bool _rightMouseButtonDown;
bool _middleMouseButtonDown;
glm::vec2 _previousCursorPos[3];
glm::vec2 _currentCursorPos;
glm::vec2 _currentCursorDiff[3];
float _rotationSpeed;
float _navigationSpeed;
private:
enum MouseButtons{ ButtonLeft = 0, ButtonRight, ButtonMiddle };
enum MouseButtons{ ButtonLeft = 0, ButtonRight, ButtonMiddle };
};
} // namespace interaction

View File

@@ -82,7 +82,7 @@ namespace openspace{
void requestHostship(const std::string &password);
void setPassword(const std::string &password);
void setPassword(const std::string &password);
void signalDisconnect();
@@ -113,23 +113,23 @@ namespace openspace{
protected:
private:
//@TODO change this into the ghoul hasher for client AND server
uint32_t hash(const std::string &val){
uint32_t hashVal = 0, i;
size_t len = val.length();
//@TODO change this into the ghoul hasher for client AND server
uint32_t hash(const std::string &val){
uint32_t hashVal = 0, i;
size_t len = val.length();
for (hashVal = i = 0; i < len; ++i){
hashVal += val.c_str()[i];
hashVal += (hashVal << 10);
hashVal ^= (hashVal >> 6);
}
for (hashVal = i = 0; i < len; ++i){
hashVal += val.c_str()[i];
hashVal += (hashVal << 10);
hashVal ^= (hashVal >> 6);
}
hashVal += (hashVal << 3);
hashVal ^= (hashVal >> 11);
hashVal += (hashVal << 15);
hashVal += (hashVal << 3);
hashVal ^= (hashVal >> 11);
hashVal += (hashVal << 15);
return hashVal;
};
return hashVal;
};
void queueMessage(std::vector<char> message);
@@ -137,27 +137,27 @@ namespace openspace{
void writeHeader(std::vector<char> &buffer, uint32_t messageType);
void closeSocket();
void closeSocket();
bool initNetworkAPI();
bool initNetworkAPI();
void establishConnection(addrinfo *info);
void establishConnection(addrinfo *info);
void sendAuthentication();
void sendAuthentication();
void listenCommunication();
void listenCommunication();
void delegateDecoding(uint32_t type);
void delegateDecoding(uint32_t type);
void initializationMessageReceived();
void initializationMessageReceived();
void dataMessageReceived();
void dataMessageReceived();
void hostInfoMessageReceived();
void initializationRequestMessageReceived();
void hostInfoMessageReceived();
void initializationRequestMessageReceived();
void broadcast();
void broadcast();
int headerSize();
@@ -171,15 +171,15 @@ namespace openspace{
std::string scriptFromPropertyAndValue(const std::string property, const std::string value);
uint32_t _passCode;
uint32_t _passCode;
std::string _port;
std::string _address;
std::string _name;
_SOCKET _clientSocket;
std::thread *_connectionThread;
std::thread *_broadcastThread;
std::thread *_broadcastThread;
std::thread *_sendThread;
std::thread *_listenThread;
std::thread *_listenThread;
std::thread *_handlerThread;
std::atomic<bool> _isHost;
std::atomic<bool> _isConnected;

View File

@@ -35,35 +35,35 @@ 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);
NumericalProperty(std::string identifier, std::string guiName, T value,
T minimumValue, T maximumValue, T steppingValue);
bool getLuaValue(lua_State* state) const override;
bool setLuaValue(lua_State* state) override;
int typeLua() const override;
bool getLuaValue(lua_State* state) const override;
bool setLuaValue(lua_State* state) override;
int typeLua() const override;
bool getStringValue(std::string& value) const override;
bool setStringValue(std::string value) override;
T minValue() const;
T maxValue() const;
T minValue() const;
T maxValue() const;
virtual std::string className() const override;
using TemplateProperty<T>::operator=;
protected:
static const std::string MinimumValueKey;
static const std::string MaximumValueKey;
static const std::string SteppingValueKey;
static const std::string MinimumValueKey;
static const std::string MaximumValueKey;
static const std::string SteppingValueKey;
std::string generateAdditionalDescription() const;
std::string generateAdditionalDescription() const;
T _minimumValue;
T _maximumValue;
T _stepping;
T _stepping;
};
} // namespace properties

View File

@@ -48,9 +48,9 @@ namespace properties {
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>(); \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>(); \
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>(); \
\
template <> \
template <> \
@@ -104,41 +104,41 @@ 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<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>() \
{ \
return DEFAULT_STEPPING; \
} \
\
template <> \
template <> \
@@ -146,7 +146,7 @@ namespace properties {
bool& success) \
{ \
return FROM_LUA_LAMBDA_EXPRESSION(state, success); \
} \
} \
\
template <> \
template <> \
@@ -155,7 +155,7 @@ namespace properties {
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(state, \
success); \
} \
} \
\
template <> \
template <> \
@@ -235,33 +235,33 @@ const std::string NumericalProperty<T>::SteppingValueKey = "SteppingValue";
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>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<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>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<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>()
)
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>
@@ -271,7 +271,7 @@ NumericalProperty<T>::NumericalProperty(std::string identifier,
: TemplateProperty<T>(std::move(identifier), std::move(guiName), std::move(value))
, _minimumValue(std::move(minimumValue))
, _maximumValue(std::move(maximumValue))
, _stepping(std::move(steppingValue))
, _stepping(std::move(steppingValue))
{}
template <typename T>
@@ -282,23 +282,23 @@ std::string NumericalProperty<T>::className() const {
template <typename T>
bool NumericalProperty<T>::setLuaValue(lua_State* state)
{
bool success = false;
T value = PropertyDelegate<NumericalProperty<T>>::template fromLuaValue<T>(state, success);
if (success)
TemplateProperty<T>::setValue(value);
return success;
bool success = false;
T value = PropertyDelegate<NumericalProperty<T>>::template fromLuaValue<T>(state, success);
if (success)
TemplateProperty<T>::setValue(value);
return success;
}
template <typename T>
bool NumericalProperty<T>::getLuaValue(lua_State* state) const
{
bool success = PropertyDelegate<NumericalProperty<T>>::template toLuaValue<T>(state, TemplateProperty<T>::_value);
return success;
bool success = PropertyDelegate<NumericalProperty<T>>::template toLuaValue<T>(state, TemplateProperty<T>::_value);
return success;
}
template <typename T>
int NumericalProperty<T>::typeLua() const {
return PropertyDelegate<NumericalProperty<T>>::typeLua();
return PropertyDelegate<NumericalProperty<T>>::typeLua();
}
template <typename T>
@@ -318,21 +318,21 @@ bool NumericalProperty<T>::setStringValue(std::string value) {
template <typename T>
T NumericalProperty<T>::minValue() const {
return _minimumValue;
return _minimumValue;
}
template <typename T>
T NumericalProperty<T>::maxValue() const {
return _maximumValue;
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;
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

View File

@@ -41,58 +41,58 @@ namespace properties {
*/
class OptionProperty : public IntProperty {
public:
/**
* The struct storing a single option consisting of an integer <code>value</code> and
* a <code>string</code> description.
*/
struct Option {
int value;
std::string description;
};
/**
* The struct storing a single option consisting of an integer <code>value</code> and
* a <code>string</code> description.
*/
struct Option {
int value;
std::string description;
};
/**
* The constructor delegating the <code>identifier</code> and the <code>guiName</code>
* to its super class.
* \param identifier A unique identifier for this property
* \param guiName The GUI name that should be used to represent this property
*/
OptionProperty(std::string identifier, std::string guiName);
/**
* The constructor delegating the <code>identifier</code> and the <code>guiName</code>
* to its super class.
* \param identifier A unique identifier for this property
* \param guiName The GUI name that should be used to represent this property
*/
OptionProperty(std::string identifier, std::string guiName);
/**
* Returns the name of the class for reflection purposes.
* \return The name of this class for reflection purposes
*/
std::string className() const override;
using IntProperty::operator=;
/**
* Returns the name of the class for reflection purposes.
* \return The name of this class for reflection purposes
*/
std::string className() const override;
using IntProperty::operator=;
/**
* Adds the passed option to the list of available options. The <code>value</code> of
* the <code>option</code> must not have been registered previously, or a warning will
* be logged.
* \param value The option that will be added to the list of available options
/**
* Adds the passed option to the list of available options. The <code>value</code> of
* the <code>option</code> must not have been registered previously, or a warning will
* be logged.
* \param value The option that will be added to the list of available options
* \param desc The description of the value that will be added
*/
void addOption(int value, std::string desc);
*/
void addOption(int value, std::string desc);
/**
* Returns the list of available options.
* /return The list of available options
*/
const std::vector<Option>& options() const;
/**
* Returns the list of available options.
* /return The list of available options
*/
const std::vector<Option>& options() const;
/**
* The overritten TemplateProperty::setValue method that checks if the provided value
* represents a valid Option
* \param value The value of the Option that should be set
*/
void setValue(int value) override;
/**
* The overritten TemplateProperty::setValue method that checks if the provided value
* represents a valid Option
* \param value The value of the Option that should be set
*/
void setValue(int value) override;
private:
static const std::string OptionsKey;
std::string generateAdditionalDescription() const;
static const std::string OptionsKey;
std::string generateAdditionalDescription() const;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
};
} // namespace properties

View File

@@ -62,239 +62,239 @@ class PropertyOwner;
*/
class Property {
public:
/**
* The constructor for the property. The <code>identifier</code> needs to be unique
* for each PropertyOwner. The <code>guiName</code> will be stored in the metaData
* to be accessed by the GUI elements using the <code>guiName</code> key. The default
* visibility settings is <code>true</code>, whereas the default read-only state is
* <code>false</code>.
* \param identifier A unique identifier for this property. It has to be unique to the
* PropertyOwner and cannot contain any <code>.</code>s
* \param guiName The human-readable GUI name for this Property
*/
/**
* The constructor for the property. The <code>identifier</code> needs to be unique
* for each PropertyOwner. The <code>guiName</code> will be stored in the metaData
* to be accessed by the GUI elements using the <code>guiName</code> key. The default
* visibility settings is <code>true</code>, whereas the default read-only state is
* <code>false</code>.
* \param identifier A unique identifier for this property. It has to be unique to the
* PropertyOwner and cannot contain any <code>.</code>s
* \param guiName The human-readable GUI name for this Property
*/
Property(std::string identifier, std::string guiName);
/**
* The destructor taking care of deallocating all unused memory. This method will not
* remove the Property from the PropertyOwner.
*/
/**
* The destructor taking care of deallocating all unused memory. This method will not
* remove the Property from the PropertyOwner.
*/
virtual ~Property();
/**
* This method returns the class name of the Property. The method is used by the
* TemplateFactory to create new instances of Propertys. The returned value is almost
* always identical to the C++ class name of the derived class.
* \return The class name of the Property
*/
/**
* This method returns the class name of the Property. The method is used by the
* TemplateFactory to create new instances of Propertys. The returned value is almost
* always identical to the C++ class name of the derived class.
* \return The class name of the Property
*/
virtual std::string className() const = 0;
/**
* This method returns the encapsulated value of the Property to the caller. The type
* that is returned is determined by the type function and is up to the developer of
* the derived class. The default implementation returns an empty ghoul::any object.
* \return The value that is encapsulated by this Property, or an empty ghoul::any
* object if the method was not overritten.
*/
/**
* This method returns the encapsulated value of the Property to the caller. The type
* that is returned is determined by the type function and is up to the developer of
* the derived class. The default implementation returns an empty ghoul::any object.
* \return The value that is encapsulated by this Property, or an empty ghoul::any
* object if the method was not overritten.
*/
virtual ghoul::any get() const;
/**
* Sets the value encapsulated by this Property to the <code>value</code> passed to
* this function. It is the caller's responsibility to ensure that the type contained
* in <code>value</code> is compatible with the concrete subclass of the Property. The
* method Property::type will return the desired type for the Property. The default
* implementation of this method ignores the input.
* \param value The new value that should be stored in this Property
*/
/**
* Sets the value encapsulated by this Property to the <code>value</code> passed to
* this function. It is the caller's responsibility to ensure that the type contained
* in <code>value</code> is compatible with the concrete subclass of the Property. The
* method Property::type will return the desired type for the Property. The default
* implementation of this method ignores the input.
* \param value The new value that should be stored in this Property
*/
virtual void set(ghoul::any value);
/**
* This method returns the type that is requested by this Property for the set method.
* The default implementation returns the type of <code>void</code>.
* \return The type that is requested by this Property's Property::set method
*/
/**
* This method returns the type that is requested by this Property for the set method.
* The default implementation returns the type of <code>void</code>.
* \return The type that is requested by this Property's Property::set method
*/
virtual const std::type_info& type() const;
/**
* This method encodes the encapsulated value of this Property at the top of the Lua
* stack. The specific details of this serialization is up to the property developer
* as long as the rest of the stack is unchanged. The implementation has to be
* synchronized with the Property::setLuaValue method. The default implementation is a
* no-op.
* \param state The Lua state to which the value will be encoded
* \return <code>true</code> if the encoding succeeded, <code>false</code> otherwise
*/
virtual bool getLuaValue(lua_State* state) const;
/**
* This method encodes the encapsulated value of this Property at the top of the Lua
* stack. The specific details of this serialization is up to the property developer
* as long as the rest of the stack is unchanged. The implementation has to be
* synchronized with the Property::setLuaValue method. The default implementation is a
* no-op.
* \param state The Lua state to which the value will be encoded
* \return <code>true</code> if the encoding succeeded, <code>false</code> otherwise
*/
virtual bool getLuaValue(lua_State* state) const;
/**
* This method sets the value encapsulated by this Property by deserializing the value
* on top of the passed Lua stack. The specific details of the deserialization are up
* to the Property developer, but they must only depend on the top element of the
* stack and must leave all other elements unchanged. The implementation has to be
* synchronized with the Property::getLuaValue method. The default implementation is a
* no-op.
* \param state The Lua state from which the value will be decoded
* \return <code>true</code> if the decoding and setting of the value succeeded,
* <code>false</code> otherwise
*/
virtual bool setLuaValue(lua_State* state);
/**
* This method sets the value encapsulated by this Property by deserializing the value
* on top of the passed Lua stack. The specific details of the deserialization are up
* to the Property developer, but they must only depend on the top element of the
* stack and must leave all other elements unchanged. The implementation has to be
* synchronized with the Property::getLuaValue method. The default implementation is a
* no-op.
* \param state The Lua state from which the value will be decoded
* \return <code>true</code> if the decoding and setting of the value succeeded,
* <code>false</code> otherwise
*/
virtual bool setLuaValue(lua_State* state);
/**
* Returns the Lua type that will be put onto the stack in the Property::getLua method
* and which will be consumed by the Property::setLuaValue method. The returned value
* can belong to the set of Lua types: <code>LUA_TNONE</code>, <code>LUA_TNIL</code>,
* <code>LUA_TBOOLEAN</code>, <code>LUA_TLIGHTUSERDATA</code>,
* <code>LUA_TNUMBER</code>, <code>LUA_TSTRING</code>, <code>LUA_TTABLE</code>,
* <code>LUA_TFUNCTION</code>, <code>LUA_TUSERDATA</code>, or
* <code>LUA_TTHREAD</code>. The default implementation will return
* <code>LUA_TNONE</code>.
* \return The Lua type that will be consumed or produced by the Property::getLuaValue
/**
* Returns the Lua type that will be put onto the stack in the Property::getLua method
* and which will be consumed by the Property::setLuaValue method. The returned value
* can belong to the set of Lua types: <code>LUA_TNONE</code>, <code>LUA_TNIL</code>,
* <code>LUA_TBOOLEAN</code>, <code>LUA_TLIGHTUSERDATA</code>,
* <code>LUA_TNUMBER</code>, <code>LUA_TSTRING</code>, <code>LUA_TTABLE</code>,
* <code>LUA_TFUNCTION</code>, <code>LUA_TUSERDATA</code>, or
* <code>LUA_TTHREAD</code>. The default implementation will return
* <code>LUA_TNONE</code>.
* \return The Lua type that will be consumed or produced by the Property::getLuaValue
* and Property::setLuaValue methods.
*/
virtual int typeLua() const;
*/
virtual int typeLua() const;
/**
* This method encodes the encapsulated value of this Property as a
/**
* This method encodes the encapsulated value of this Property as a
* <code>std::string</code>. The specific details of this serialization is up to the
* property developer. The implementation has to be synchronized with the
Property::setStringValue method. The default implementation is a no-op.
* \param value The value to which the Property will be encoded
* \return <code>true</code> if the encoding succeeded, <code>false</code> otherwise
*/
* \param value The value to which the Property will be encoded
* \return <code>true</code> if the encoding succeeded, <code>false</code> otherwise
*/
virtual bool getStringValue(std::string& value) const;
/**
* This method sets the value encapsulated by this Property by deserializing the
/**
* This method sets the value encapsulated by this Property by deserializing the
* passed <code>std::string</code>. The specific details of the deserialization are up
* to the Property developer. The implementation has to be synchronized with the
* to the Property developer. The implementation has to be synchronized with the
* Property::getLuaValue method. The default implementation is a no-op.
* \param value The value from which the Property will be decoded
* \return <code>true</code> if the decoding and setting of the value succeeded,
* <code>false</code> otherwise
*/
* \param value The value from which the Property will be decoded
* \return <code>true</code> if the decoding and setting of the value succeeded,
* <code>false</code> otherwise
*/
virtual bool setStringValue(std::string value);
/**
* This method registers a <code>callback</code> function that will be called every
* time if either Property:set or Property::setLuaValue was called with a value that
/**
* This method registers a <code>callback</code> function that will be called every
* time if either Property:set or Property::setLuaValue was called with a value that
* is different from the previously stored value. The callback can be removed by
* passing an empty <code>std::function<void()></code> object.
* \param callback The callback function that is called when the encapsulated type has
* been successfully changed by either the Property::set or Property::setLuaValue
* \param callback The callback function that is called when the encapsulated type has
* been successfully changed by either the Property::set or Property::setLuaValue
* methods.
*/
*/
virtual void onChange(std::function<void()> callback);
/**
* This method returns the unique identifier of this Property.
* \return The unique identifier of this Property
*/
/**
* This method returns the unique identifier of this Property.
* \return The unique identifier of this Property
*/
const std::string& identifier() const;
/**
* Returns the fully qualified name for this Property that uniquely identifies this
* Property within OpenSpace. It consists of the <code>identifier</code> preceded by
* all levels of PropertyOwner%s separated with <code>.</code>; for example:
* <code>owner1.owner2.identifier</code>.
* \return The fully qualified identifier for this Property
*/
std::string fullyQualifiedIdentifier() const;
/**
* Returns the fully qualified name for this Property that uniquely identifies this
* Property within OpenSpace. It consists of the <code>identifier</code> preceded by
* all levels of PropertyOwner%s separated with <code>.</code>; for example:
* <code>owner1.owner2.identifier</code>.
* \return The fully qualified identifier for this Property
*/
std::string fullyQualifiedIdentifier() const;
/**
* Returns the PropertyOwner of this Property or <code>nullptr</code>, if it does not
* have an owner.
*\ return The Property of this Property
*/
/**
* Returns the PropertyOwner of this Property or <code>nullptr</code>, if it does not
* have an owner.
*\ return The Property of this Property
*/
PropertyOwner* owner() const;
/**
* Assigned the Property to a new PropertyOwner. This method does not inform the
* PropertyOwner of this action.
* \param owner The new PropertyOwner for this Property
*/
/**
* Assigned the Property to a new PropertyOwner. This method does not inform the
* PropertyOwner of this action.
* \param owner The new PropertyOwner for this Property
*/
void setPropertyOwner(PropertyOwner* owner);
/**
* Returns the human-readable GUI name for this Property that has been set in the
* constructor. This method returns the same value as accessing the metaData object
* and requesting the <code>std::string</code> stored for the <code>guiName</code>
* key.
* \return The human-readable GUI name for this Property
*/
std::string guiName() const;
/**
* Returns the human-readable GUI name for this Property that has been set in the
* constructor. This method returns the same value as accessing the metaData object
* and requesting the <code>std::string</code> stored for the <code>guiName</code>
* key.
* \return The human-readable GUI name for this Property
*/
std::string guiName() const;
/**
* Returns the description for this Property that contains all necessary information
* required for creating a GUI representation. The format of the description is a
* valid Lua table, i.e., it is surrounded by a pair of <code>{</code> and
* <code>}</code> with key,value pairs between. Each value can either be a number, a
* string, a bool, or another table. The general values set by this base function
* are: <code>Identifier</code>, <code>Name</code>, <code>Type</code>. All other
* values are specific to the type and are added in a specific subclass, which require
* the subclass to call this method first.
* \return The descriptive text for the Property that can be used for constructing a
* GUI representation
*/
virtual std::string description() const;
/**
* Returns the description for this Property that contains all necessary information
* required for creating a GUI representation. The format of the description is a
* valid Lua table, i.e., it is surrounded by a pair of <code>{</code> and
* <code>}</code> with key,value pairs between. Each value can either be a number, a
* string, a bool, or another table. The general values set by this base function
* are: <code>Identifier</code>, <code>Name</code>, <code>Type</code>. All other
* values are specific to the type and are added in a specific subclass, which require
* the subclass to call this method first.
* \return The descriptive text for the Property that can be used for constructing a
* GUI representation
*/
virtual std::string description() const;
/**
* Sets the identifier of the group that this Property belongs to. Property groups can
* be used, for example, by GUI application to visually group different properties,
* but it has no impact on the Property itself. The default value for the groupID is
* <code>""</code>.
* \param groupId The group id that this property should belong to
*/
/**
* Sets the identifier of the group that this Property belongs to. Property groups can
* be used, for example, by GUI application to visually group different properties,
* but it has no impact on the Property itself. The default value for the groupID is
* <code>""</code>.
* \param groupId The group id that this property should belong to
*/
void setGroupIdentifier(std::string groupId);
/**
* Returns the group idenfier that this Property belongs to, or <code>""</code> if it
* belongs to no group.
* \return The group identifier that this Property belongs to
*/
/**
* Returns the group idenfier that this Property belongs to, or <code>""</code> if it
* belongs to no group.
* \return The group identifier that this Property belongs to
*/
std::string groupIdentifier() const;
/**
* Determines a hint if this Property should be visible, or hidden. Each application
* accessing the properties is free to ignore this hint. It is stored in the metaData
* Dictionary with the key: <code>isVisible</code>. The default value is
* <code>true</code>.
* \param state <code>true</code> if the Property should be visible,
* <code>false</code> otherwise.
*/
/**
* Determines a hint if this Property should be visible, or hidden. Each application
* accessing the properties is free to ignore this hint. It is stored in the metaData
* Dictionary with the key: <code>isVisible</code>. The default value is
* <code>true</code>.
* \param state <code>true</code> if the Property should be visible,
* <code>false</code> otherwise.
*/
void setVisible(bool state);
/**
* This method determines if this Property should be read-only in external
* applications. This setting is only a hint and does not need to be followed by GUI
* applications and does not have any effect on the Property::set,
/**
* This method determines if this Property should be read-only in external
* applications. This setting is only a hint and does not need to be followed by GUI
* applications and does not have any effect on the Property::set,
* Property::setLuaValue, or Property::setStringValue methods. The value is stored in
* the metaData Dictionary with the key: <code>isReadOnly</code>. The default value is
* <code>false</code>.
* \param state <code>true</code> if the Property should be read only,
* <code>false</code> otherwise
*/
void setReadOnly(bool state);
* \param state <code>true</code> if the Property should be read only,
* <code>false</code> otherwise
*/
void setReadOnly(bool state);
/**
* This method allows the developer to give hints to the GUI about different
* representations for the GUI. The same Property (for example Vec4Property) can be
* used in different ways, each requiring a different input method. These values are
* stored in the metaData object using the <code>views.</code> prefix in front of the
* <code>option</code> parameter. See Property::ViewOptions for a default list of
* possible options. As these are only hints, the GUI is free to ignore any suggestion
* by the developer.
* \param option The view option that should be modified
* \param value Determines if the view option should be active (<code>true</code>) or
* deactivated (<code>false</code>)
*/
/**
* This method allows the developer to give hints to the GUI about different
* representations for the GUI. The same Property (for example Vec4Property) can be
* used in different ways, each requiring a different input method. These values are
* stored in the metaData object using the <code>views.</code> prefix in front of the
* <code>option</code> parameter. See Property::ViewOptions for a default list of
* possible options. As these are only hints, the GUI is free to ignore any suggestion
* by the developer.
* \param option The view option that should be modified
* \param value Determines if the view option should be active (<code>true</code>) or
* deactivated (<code>false</code>)
*/
void setViewOption(std::string option, bool value = true);
/**
* Default view options that can be used in the Property::setViewOption method. The
* values are: Property::ViewOptions::Color = <code>color</code>,
* Property::ViewOptions::LightPosition = <code>lightPosition</code>,
* Property::ViewOptions::PowerScaledScalar = <code>powerScaledScalar</code>, and
* Property::ViewOptions::PowerScaledCoordinate = <code>powerScaledCoordinate</code>.
*/
/**
* Default view options that can be used in the Property::setViewOption method. The
* values are: Property::ViewOptions::Color = <code>color</code>,
* Property::ViewOptions::LightPosition = <code>lightPosition</code>,
* Property::ViewOptions::PowerScaledScalar = <code>powerScaledScalar</code>, and
* Property::ViewOptions::PowerScaledCoordinate = <code>powerScaledCoordinate</code>.
*/
struct ViewOptions {
static const std::string Color;
static const std::string LightPosition;
@@ -302,68 +302,68 @@ public:
static const std::string PowerScaledCoordinate;
};
/**
* Returns the metaData that contains all information for external applications to
* correctly display information about the Property. No information that is stored in
* this Dictionary is necessary for the programmatic use of the Property.
* \return The Dictionary containing all meta data information about this Property
*/
/**
* Returns the metaData that contains all information for external applications to
* correctly display information about the Property. No information that is stored in
* this Dictionary is necessary for the programmatic use of the Property.
* \return The Dictionary containing all meta data information about this Property
*/
const ghoul::Dictionary& metaData() const;
protected:
static const std::string IdentifierKey;
static const std::string NameKey;
static const std::string TypeKey;
static const std::string MetaDataKey;
static const std::string IdentifierKey;
static const std::string NameKey;
static const std::string TypeKey;
static const std::string MetaDataKey;
/**
* Creates the information that is general to every Property and adds the
* <code>Identifier</code>, <code>Name</code>, <code>Type</code>, and
* <code>MetaData</code> keys and their values. The meta data is handles by the
* generateMetaDataDescription method, which has to be overloaded if a concrete base
* class wants to add meta data that is not curated by the Property class
* \return The base description common to all Property classes
*/
std::string generateBaseDescription() const;
/**
* Creates the information that is general to every Property and adds the
* <code>Identifier</code>, <code>Name</code>, <code>Type</code>, and
* <code>MetaData</code> keys and their values. The meta data is handles by the
* generateMetaDataDescription method, which has to be overloaded if a concrete base
* class wants to add meta data that is not curated by the Property class
* \return The base description common to all Property classes
*/
std::string generateBaseDescription() const;
/**
* Creates the information for the <code>MetaData</code> key-part of the Lua
* description for the Property. The result can be included as one key-value pair in
* the description text generated by subclasses. Only the metadata curated by the
* Property class is used in this method.
* \return The metadata information text for the property
*/
virtual std::string generateMetaDataDescription() const;
/**
* Creates the information for the <code>MetaData</code> key-part of the Lua
* description for the Property. The result can be included as one key-value pair in
* the description text generated by subclasses. Only the metadata curated by the
* Property class is used in this method.
* \return The metadata information text for the property
*/
virtual std::string generateMetaDataDescription() const;
/**
* Creates the information that is specific to each subclass of Property%s. If a
* subclass needs to add additional information into the description, it has to
* override this method and return the string containing all of the additional
* information. The base implementation of the #description method will return the Lua
* script:
* <code>return { generateBaseDescription(), generateMetaDataDescription(),</code>
* <code>generateAdditionalDescription()}</code>, which #generateMetaDataDescription
* and this method being the override points to customize the behavior.
* \return The information specific to each subclass of Property
*/
virtual std::string generateAdditionalDescription() const;
/**
* Creates the information that is specific to each subclass of Property%s. If a
* subclass needs to add additional information into the description, it has to
* override this method and return the string containing all of the additional
* information. The base implementation of the #description method will return the Lua
* script:
* <code>return { generateBaseDescription(), generateMetaDataDescription(),</code>
* <code>generateAdditionalDescription()}</code>, which #generateMetaDataDescription
* and this method being the override points to customize the behavior.
* \return The information specific to each subclass of Property
*/
virtual std::string generateAdditionalDescription() const;
/**
* This method must be called by all subclasses whenever the encapsulated value has
* changed and a potential listener has to be informed.
*/
void notifyListener();
/**
* This method must be called by all subclasses whenever the encapsulated value has
* changed and a potential listener has to be informed.
*/
void notifyListener();
/// The PropetyOwner this Property belongs to, or <code>nullptr</code>
/// The PropetyOwner this Property belongs to, or <code>nullptr</code>
PropertyOwner* _owner;
/// The identifier for this Property
/// The identifier for this Property
std::string _identifier;
/// The Dictionary containing all meta data necessary for external applications
/// The Dictionary containing all meta data necessary for external applications
ghoul::Dictionary _metaData;
/// The callback function that will be invoked whenever the encapsulated value changes
/// The callback function that will be invoked whenever the encapsulated value changes
std::function<void()> _onChangeCallback;
};

View File

@@ -47,108 +47,108 @@ namespace properties {
template <typename T>
class PropertyDelegate {
public:
/**
* This method returns the class name for the class <code>T</code>. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \return The class name for the class <code>T</code>
*/
/**
* This method returns the class name for the class <code>T</code>. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \return The class name for the class <code>T</code>
*/
static std::string className();
/**
* This method will return the preferred default value for the class <code>T</code>.
* The default implementation will lead to a compile-time error if the class method is
* not specialized.
* \return The default value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
/**
* This method will return the preferred default value for the class <code>T</code>.
* The default implementation will lead to a compile-time error if the class method is
* not specialized.
* \return The default value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static U defaultValue();
/**
* This method will return the preferred default minimum value for the class
* <code>T</code>. 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 minimum value 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>
*/
/**
* This method will return the preferred default minimum value for the class
* <code>T</code>. 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 minimum value 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 defaultMinimumValue();
/**
* This method will return the preferred default maximum value for the class
* <code>T</code>. 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 maximum value 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>
*/
/**
* This method will return the preferred default maximum value for the class
* <code>T</code>. 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 maximum value 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 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();
/**
* 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
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \param state The Lua state from which the value is retrieved
* \param success Will be <code>true</code> if the conversion succeeded;
* <code>false</code> otherwise
* \return The value that was created by converting the top value from the stack
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static U fromLuaValue(lua_State* state, bool& success);
/**
* 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
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \param state The Lua state from which the value is retrieved
* \param success Will be <code>true</code> if the conversion succeeded;
* <code>false</code> otherwise
* \return The value that was created by converting the top value from the stack
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static U fromLuaValue(lua_State* state, bool& success);
/**
* This method converts the passed <code>value</code>, encodes it and places it on the
* top value of the Lua stack and returns the success back to the caller. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \param state The Lua state from which the value is retrieved
* \param value The value that will be converted into a Lua object
* \return <code>true</code> if the conversion succeeded; <code>false</code> otherwise
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static bool toLuaValue(lua_State* state, U value);
/**
* This method converts the passed <code>value</code>, encodes it and places it on the
* top value of the Lua stack and returns the success back to the caller. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \param state The Lua state from which the value is retrieved
* \param value The value that will be converted into a Lua object
* \return <code>true</code> if the conversion succeeded; <code>false</code> otherwise
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static bool toLuaValue(lua_State* state, U value);
/**
* Returns the Lua type that will be put onto the stack in the
* PropertyDelegate::toLuaValue method and which will be consumed by the
* PropertyDelegate::fromLuaValue method. The returned value can belong to the set of
* Lua types: <code>LUA_TNONE</code>, <code>LUA_TNIL</code>,
* <code>LUA_TBOOLEAN</code>, <code>LUA_TLIGHTUSERDATA</code>,
* <code>LUA_TNUMBER</code>, <code>LUA_TSTRING</code>, <code>LUA_TTABLE</code>,
* <code>LUA_TFUNCTION</code>, <code>LUA_TUSERDATA</code>, or
* <code>LUA_TTHREAD</code>. The default implementation will return
* <code>LUA_TNONE</code>. The default implementation will lead to a compile-time
* error if the class method is not specialized.
* \return The Lua type that will be consumed or produced by the
* PropertyDelegate::toLuaValue and PropertyDelegate::fromLuaValue methods.
*/
static int typeLua();
/**
* Returns the Lua type that will be put onto the stack in the
* PropertyDelegate::toLuaValue method and which will be consumed by the
* PropertyDelegate::fromLuaValue method. The returned value can belong to the set of
* Lua types: <code>LUA_TNONE</code>, <code>LUA_TNIL</code>,
* <code>LUA_TBOOLEAN</code>, <code>LUA_TLIGHTUSERDATA</code>,
* <code>LUA_TNUMBER</code>, <code>LUA_TSTRING</code>, <code>LUA_TTABLE</code>,
* <code>LUA_TFUNCTION</code>, <code>LUA_TUSERDATA</code>, or
* <code>LUA_TTHREAD</code>. The default implementation will return
* <code>LUA_TNONE</code>. The default implementation will lead to a compile-time
* error if the class method is not specialized.
* \return The Lua type that will be consumed or produced by the
* PropertyDelegate::toLuaValue and PropertyDelegate::fromLuaValue methods.
*/
static int typeLua();
template <typename U>
static U fromString(std::string value, bool& success);

View File

@@ -30,14 +30,14 @@ namespace properties {
template <typename T>
std::string PropertyDelegate<T>::className() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::className specialization");
"Unimplemented PropertyDelegate::className specialization");
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::defaultValue() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultValue specialization");
"Unimplemented PropertyDelegate::defaultValue specialization");
}
template <typename T>
@@ -57,28 +57,28 @@ U PropertyDelegate<T>::defaultMaximumValue() {
template <typename T>
template <typename U>
U PropertyDelegate<T>::defaultSteppingValue() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultSteppingValue specialization");
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultSteppingValue specialization");
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::fromLuaValue(lua_State* state, bool& success) {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::fromLuaValue specialization");
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::fromLuaValue specialization");
}
template <typename T>
template <typename U>
bool PropertyDelegate<T>::toLuaValue(lua_State* state, U value) {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::toLuaValue specialization");
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::toLuaValue specialization");
}
template <typename T>
int PropertyDelegate<T>::typeLua() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::luaType specialization");
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::luaType specialization");
}
template <typename T>

View File

@@ -49,173 +49,173 @@ namespace properties {
*/
class PropertyOwner {
public:
/// The separator that is used while accessing the properties and/or sub-owners
/// The separator that is used while accessing the properties and/or sub-owners
static const char URISeparator = '.';
/// The constructor initializing the PropertyOwner's name to <code>""</code>
/// The constructor initializing the PropertyOwner's name to <code>""</code>
PropertyOwner();
/**
* The destructor will remove all Propertys and PropertyOwners it owns along with
* itself.
*/
/**
* The destructor will remove all Propertys and PropertyOwners it owns along with
* itself.
*/
virtual ~PropertyOwner();
/**
* Sets the name for this PropertyOwner. If the PropertyOwner does not have an owner
* itself, the name must be globally unique. If the PropertyOwner has an owner, the
* name must be unique to the owner (including the owner's properties). No uniqueness
* check will be preformed here, but rather in the PropertyOwner::addProperty and
* PropertyOwner::addPropertySubOwner methods).
* \param name The name of this PropertyOwner. It may not contain any <code>.</code>s
*/
/**
* Sets the name for this PropertyOwner. If the PropertyOwner does not have an owner
* itself, the name must be globally unique. If the PropertyOwner has an owner, the
* name must be unique to the owner (including the owner's properties). No uniqueness
* check will be preformed here, but rather in the PropertyOwner::addProperty and
* PropertyOwner::addPropertySubOwner methods).
* \param name The name of this PropertyOwner. It may not contain any <code>.</code>s
*/
void setName(std::string name);
/**
* Returns the name of this PropertyOwner.
* \return The name of this PropertyOwner
*/
/**
* Returns the name of this PropertyOwner.
* \return The name of this PropertyOwner
*/
const std::string& name() const;
/**
* Returns a list of all Propertys directly owned by this PropertyOwner. This list not
* include Propertys owned by other sub-owners.
* \return A list of all Propertys directly owned by this PropertyOwner
*/
/**
* Returns a list of all Propertys directly owned by this PropertyOwner. This list not
* include Propertys owned by other sub-owners.
* \return A list of all Propertys directly owned by this PropertyOwner
*/
const std::vector<Property*>& properties() const;
/**
* Returns a list of all Propertys directly or indirectly owned by this PropertyOwner.
* \return A list of all Propertys directly or indirectly owned by this PropertyOwner
*/
std::vector<Property*> propertiesRecursive() const;
/**
* Returns a list of all Propertys directly or indirectly owned by this PropertyOwner.
* \return A list of all Propertys directly or indirectly owned by this PropertyOwner
*/
std::vector<Property*> propertiesRecursive() const;
/**
* Retrieves a Property identified by <code>URI</code> from this PropertyOwner. If
* <code>id</code> does not contain a <code>.</code> the identifier must refer to a
* Property directly owned by this PropertyOwner. If the identifier contains one or
* more <code>.</code>, the first part of the name will be recursively extracted and
* used as a name for a sub-owner and only the last part of the identifier is
* referring to a Property owned by PropertyOwner named by the second-but-last name.
* \param URI The identifier of the Property that should be extracted
* \return If the Property cannot be found, <code>nullptr</code> is returned,
* otherwise the pointer to the Property is returned
*/
/**
* Retrieves a Property identified by <code>URI</code> from this PropertyOwner. If
* <code>id</code> does not contain a <code>.</code> the identifier must refer to a
* Property directly owned by this PropertyOwner. If the identifier contains one or
* more <code>.</code>, the first part of the name will be recursively extracted and
* used as a name for a sub-owner and only the last part of the identifier is
* referring to a Property owned by PropertyOwner named by the second-but-last name.
* \param URI The identifier of the Property that should be extracted
* \return If the Property cannot be found, <code>nullptr</code> is returned,
* otherwise the pointer to the Property is returned
*/
Property* property(const std::string& URI) const;
/**
* This method checks if a Property with the provided <code>URI</code> exists in this
* PropertyOwner (or any sub-owner). If the identifier contains one or more
* <code>.</code>, the first part of the name will be recursively extracted and is
* used as a name for a sub-owner and only the last part of the identifier is
* referring to a Property owned by PropertyOwner named by the second-but-last name.
* \return <code>true</code> if the <code>URI</code> refers to a Property;
* <code>false</code> otherwise.
*/
/**
* This method checks if a Property with the provided <code>URI</code> exists in this
* PropertyOwner (or any sub-owner). If the identifier contains one or more
* <code>.</code>, the first part of the name will be recursively extracted and is
* used as a name for a sub-owner and only the last part of the identifier is
* referring to a Property owned by PropertyOwner named by the second-but-last name.
* \return <code>true</code> if the <code>URI</code> refers to a Property;
* <code>false</code> otherwise.
*/
bool hasProperty(const std::string& URI) const;
void setPropertyOwner(PropertyOwner* owner) { _owner = owner; }
PropertyOwner* owner() const { return _owner; }
PropertyOwner* owner() const { return _owner; }
/**
* Returns a list of all sub-owners this PropertyOwner has. Each name of a sub-owner
* has to be unique with respect to other sub-owners as well as Property's owned by
* this PropertyOwner.
* \return A list of all sub-owners this PropertyOwner has
*/
/**
* Returns a list of all sub-owners this PropertyOwner has. Each name of a sub-owner
* has to be unique with respect to other sub-owners as well as Property's owned by
* this PropertyOwner.
* \return A list of all sub-owners this PropertyOwner has
*/
const std::vector<PropertyOwner*>& propertySubOwners() const;
/**
* This method returns the direct sub-owner of this PropertyOwner with the provided
* <code>name</code>. This means that <code>name</code> cannot contain any
* <code>.</code> as this character is not allowed in PropertyOwner names. If the
* <code>name</code> does not name a valid sub-owner of this PropertyOwner, a
* <code>nullptr</code> will be returned.
* \param name The name of the sub-owner that should be returned
* \return The PropertyOwner with the given <code>name</code>, or <code>nullptr</code>
*/
/**
* This method returns the direct sub-owner of this PropertyOwner with the provided
* <code>name</code>. This means that <code>name</code> cannot contain any
* <code>.</code> as this character is not allowed in PropertyOwner names. If the
* <code>name</code> does not name a valid sub-owner of this PropertyOwner, a
* <code>nullptr</code> will be returned.
* \param name The name of the sub-owner that should be returned
* \return The PropertyOwner with the given <code>name</code>, or <code>nullptr</code>
*/
PropertyOwner* propertySubOwner(const std::string& name) const;
/**
* Returns <code>true</code> if this PropertyOwner owns a sub-owner with the provided
* <code>name</code>; returns <code>false</code> otherwise.
* \param name The name of the sub-owner that should be looked up
* \return <code>true</code> if this PropertyOwner owns a sub-owner with the provided
* <code>name</code>; returns <code>false</code> otherwise
*/
/**
* Returns <code>true</code> if this PropertyOwner owns a sub-owner with the provided
* <code>name</code>; returns <code>false</code> otherwise.
* \param name The name of the sub-owner that should be looked up
* \return <code>true</code> if this PropertyOwner owns a sub-owner with the provided
* <code>name</code>; returns <code>false</code> otherwise
*/
bool hasPropertySubOwner(const std::string& name) const;
/**
* This method converts a provided <code>groupID</code>, used by the Propertys, into a
* human-readable <code>name</code> which can be used by some external application.
* \param groupID The group identifier whose human-readable name should be set
* \param name The human-readable name for the group identifier
*/
/**
* This method converts a provided <code>groupID</code>, used by the Propertys, into a
* human-readable <code>name</code> which can be used by some external application.
* \param groupID The group identifier whose human-readable name should be set
* \param name The human-readable name for the group identifier
*/
void setPropertyGroupName(std::string groupID, std::string name);
/**
* Returns the human-readable name for the <code>groupID</code> for the Propertys of
* this PropertyOwner.
* \param groupID The group identifier whose human-readable name should be returned
* \return The human readable name for the Propertys identified by
* <code>groupID</code>
*/
/**
* Returns the human-readable name for the <code>groupID</code> for the Propertys of
* this PropertyOwner.
* \param groupID The group identifier whose human-readable name should be returned
* \return The human readable name for the Propertys identified by
* <code>groupID</code>
*/
const std::string& propertyGroupName(const std::string& groupID) const;
/**
* Assigns the Property <code>prop</code> to this PropertyOwner. This method will
* check if the name of the Property is unique amongst Propertys and sub-owners in
* this PropertyOwner. This method will also inform the Property about the change in
* ownership by calling the Property::setPropertyOwner method.
* \param prop The Property whose ownership is changed.
*/
/**
* Assigns the Property <code>prop</code> to this PropertyOwner. This method will
* check if the name of the Property is unique amongst Propertys and sub-owners in
* this PropertyOwner. This method will also inform the Property about the change in
* ownership by calling the Property::setPropertyOwner method.
* \param prop The Property whose ownership is changed.
*/
void addProperty(Property* prop);
/// \see Property::addProperty(Property*)
/// \see Property::addProperty(Property*)
void addProperty(Property& prop);
/**
* Adds the provided PropertyOwner to the list of sub-owners for this PropertyOwner.
* This means that the name of the <code>owner</code> has to be unique amonst the
* direct Property's as well as other PropertyOwner's that this PropertyOwner owns.
* This uniqueness will be tested in this method.
* \param owner The owner that should be assigned to this PropertyOwner
*/
/**
* Adds the provided PropertyOwner to the list of sub-owners for this PropertyOwner.
* This means that the name of the <code>owner</code> has to be unique amonst the
* direct Property's as well as other PropertyOwner's that this PropertyOwner owns.
* This uniqueness will be tested in this method.
* \param owner The owner that should be assigned to this PropertyOwner
*/
void addPropertySubOwner(PropertyOwner* owner);
/// \see PropertyOwner::addPropertySubOwner(PropertyOwner*)
/// \see PropertyOwner::addPropertySubOwner(PropertyOwner*)
void addPropertySubOwner(PropertyOwner& owner);
/**
* Removes the Property from this PropertyOwner. Notifies the Property about this
* change by calling the Property::setPropertyOwner method with a <code>nullptr</code>
* as parameter.
* \param prop The Property that should be removed from this PropertyOwner
*/
/**
* Removes the Property from this PropertyOwner. Notifies the Property about this
* change by calling the Property::setPropertyOwner method with a <code>nullptr</code>
* as parameter.
* \param prop The Property that should be removed from this PropertyOwner
*/
void removeProperty(Property* prop);
/// \see PropertyOwner::removeProperty(Property*)
/// \see PropertyOwner::removeProperty(Property*)
void removeProperty(Property& prop);
/**
* Removes the sub-owner from this PropertyOwner.
* \param owner The PropertyOwner that should be removed
*/
/**
* Removes the sub-owner from this PropertyOwner.
* \param owner The PropertyOwner that should be removed
*/
void removePropertySubOwner(PropertyOwner* owner);
/// \see PropertyOwner::removePropertySubOwner(PropertyOwner*)
/// \see PropertyOwner::removePropertySubOwner(PropertyOwner*)
void removePropertySubOwner(PropertyOwner& owner);
private:
/// The name of this PropertyOwner
/// The name of this PropertyOwner
std::string _name;
/// The owner of this PropertyOwner
PropertyOwner* _owner;
/// A list of all registered Property's
/// The owner of this PropertyOwner
PropertyOwner* _owner;
/// A list of all registered Property's
std::vector<Property*> _properties;
/// A list of all sub-owners
/// A list of all sub-owners
std::vector<PropertyOwner*> _subOwners;
/// The associations between group identifiers of Property's and human-readable names
/// The associations between group identifiers of Property's and human-readable names
std::map<std::string, std::string> _groupNames;
};

View File

@@ -34,23 +34,23 @@ namespace properties {
class SelectionProperty : public TemplateProperty<std::vector<int>> {
public:
struct Option {
int value;
std::string description;
};
struct Option {
int value;
std::string description;
};
SelectionProperty(std::string identifier, std::string guiName);
void addOption(Option option);
const std::vector<Option>& options() const;
SelectionProperty(std::string identifier, std::string guiName);
void addOption(Option option);
const std::vector<Option>& options() const;
private:
static const std::string OptionsKey;
std::string generateAdditionalDescription() const;
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;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
std::vector<int> _values;
};
template <>

View File

@@ -52,135 +52,135 @@ namespace properties {
template <typename T>
class TemplateProperty : public Property {
public:
typedef T ValueType;
typedef T ValueType;
/**
* The constructor initializing the TemplateProperty with the provided
* <code>identifier</code> and human-readable <code>guiName</code>. The default value
* for the stored type <code>T</code> is retrieved using the PropertyDelegate's
* PropertyDelegate::defaultValue method, which must be specialized for new types or
* a compile-error will occur.
* \param identifier The identifier that is used for this TemplateProperty
* \param guiName The human-readable GUI name for this TemplateProperty
*/
/**
* The constructor initializing the TemplateProperty with the provided
* <code>identifier</code> and human-readable <code>guiName</code>. The default value
* for the stored type <code>T</code> is retrieved using the PropertyDelegate's
* PropertyDelegate::defaultValue method, which must be specialized for new types or
* a compile-error will occur.
* \param identifier The identifier that is used for this TemplateProperty
* \param guiName The human-readable GUI name for this TemplateProperty
*/
TemplateProperty(std::string identifier, std::string guiName);
/**
* The constructor initializing the TemplateProperty with the provided
* <code>identifier</code>, human-readable <code>guiName</code> and provided
* <code>value</code>.
*/
/**
* The constructor initializing the TemplateProperty with the provided
* <code>identifier</code>, human-readable <code>guiName</code> and provided
* <code>value</code>.
*/
TemplateProperty(std::string identifier, std::string guiName, T value);
/**
* Returns the class name for this TemplateProperty. The default implementation makes
* a call to the PropertyDelegate::className method with the template parameter
* <code>T</code> as argument. For this to work, that method needs to be specialized
* to return the correct class name for the new template parameter T, or a
* compile-time error will occur.
* \return The class name for the TemplateProperty
*/
/**
* Returns the class name for this TemplateProperty. The default implementation makes
* a call to the PropertyDelegate::className method with the template parameter
* <code>T</code> as argument. For this to work, that method needs to be specialized
* to return the correct class name for the new template parameter T, or a
* compile-time error will occur.
* \return The class name for the TemplateProperty
*/
virtual std::string className() const override;
/**
* Returns the stored value packed into a ghoul::any object.
* \return The stored value packed into a ghoul::any object
*/
/**
* Returns the stored value packed into a ghoul::any object.
* \return The stored value packed into a ghoul::any object
*/
virtual ghoul::any get() const override;
/**
* Sets the value fro the provided ghoul::any object. If the types between
/**
* Sets the value fro the provided ghoul::any object. If the types between
* <code>T</code> and <code>value</code> disagree, an error is logged and the stored
* value remains unchanged.
*/
*/
virtual void set(ghoul::any value) override;
/**
* Returns the <code>std::type_info</code> describing the template parameter
* <code>T</code>. It can be used to test against a ghoul::any value before trying to
/**
* Returns the <code>std::type_info</code> describing the template parameter
* <code>T</code>. It can be used to test against a ghoul::any value before trying to
* assign it.
* \return The type info object describing the template parameter <code>T</code>
*/
* \return The type info object describing the template parameter <code>T</code>
*/
virtual const std::type_info& type() const override;
/**
* This method encodes the stored value into a Lua object and pushes that object onto
* the stack. The encoding is performed by calling PropertyDelegate::toLuaValue with
* the template parameter <code>T</code> as an argument. This method has to be
* specialized for each new type, or a compile-time error will occur.
* \param state The Lua state onto which the encoded object will be pushed
* \return <code>true</code> if the encoding succeeded; <code>false</code> otherwise
*/
bool getLuaValue(lua_State* state) const override;
/**
* This method encodes the stored value into a Lua object and pushes that object onto
* the stack. The encoding is performed by calling PropertyDelegate::toLuaValue with
* the template parameter <code>T</code> as an argument. This method has to be
* specialized for each new type, or a compile-time error will occur.
* \param state The Lua state onto which the encoded object will be pushed
* \return <code>true</code> if the encoding succeeded; <code>false</code> otherwise
*/
bool getLuaValue(lua_State* state) const override;
/**
* Sets the value of this TemplateProprty by decoding the object at the top of the Lua
* stack and, if successful, assigning it using the Property::set method. The decoding
* is performed by calling the PropertyDelegate::fromLuaValue with the template
* parameter <code>T</code> as argument. If the decoding is successful, the new value
* is set, otherwise it remains unchanged.
* \param state The Lua state from which the value will be decoded
* \return <code>true</code> if the decoding succeeded; <code>false</code> otherwise
*/
bool setLuaValue(lua_State* state) override;
/**
* Sets the value of this TemplateProprty by decoding the object at the top of the Lua
* stack and, if successful, assigning it using the Property::set method. The decoding
* is performed by calling the PropertyDelegate::fromLuaValue with the template
* parameter <code>T</code> as argument. If the decoding is successful, the new value
* is set, otherwise it remains unchanged.
* \param state The Lua state from which the value will be decoded
* \return <code>true</code> if the decoding succeeded; <code>false</code> otherwise
*/
bool setLuaValue(lua_State* state) override;
/// \see Property::typeLua
int typeLua() const override;
/// \see Property::typeLua
int typeLua() const override;
bool getStringValue(std::string& value) const override;
bool setStringValue(std::string value) override;
/**
* Returns the description for this TemplateProperty as a Lua script that returns a
* table on execution
* \return The description for this TemplateProperty
*/
//virtual std::string description() override;
/**
* Returns the description for this TemplateProperty as a Lua script that returns a
* table on execution
* \return The description for this TemplateProperty
*/
//virtual std::string description() override;
/**
* This operator allows the TemplateProperty to be used almost transparently as if it
* was of the type <code>T</code>. It makes assignments such as
* <code>T v = property;</code> possible by allowing implicit casts (even though,
* internally, not casts are performed. This method is next to zero overhead).
* \return The internal representation of the Property
*/
/**
* This operator allows the TemplateProperty to be used almost transparently as if it
* was of the type <code>T</code>. It makes assignments such as
* <code>T v = property;</code> possible by allowing implicit casts (even though,
* internally, not casts are performed. This method is next to zero overhead).
* \return The internal representation of the Property
*/
operator T();
/**
* This operator allows the TemplateProperty to be used almost transparently as if it
* was of the type <code>T</code>. It makes assignments such as
* <code>T v = property;</code> possible by allowing implicit casts (even though,
* internally, not casts are performed. This method is next to zero overhead).
* \return The internal representation of the Property
*/
operator T() const;
/**
* This operator allows the TemplateProperty to be used almost transparently as if it
* was of the type <code>T</code>. It makes assignments such as
* <code>T v = property;</code> possible by allowing implicit casts (even though,
* internally, not casts are performed. This method is next to zero overhead).
* \return The internal representation of the Property
*/
operator T() const;
/**
* The assignment operator allows the TemplateProperty's value to be set without using
* the TemplateProperty::set method. It will be done internally by thos method and it
* allows assignments such as <code>prop = T(1)</code>.
* \param val The value that should be set.
*/
/**
* The assignment operator allows the TemplateProperty's value to be set without using
* the TemplateProperty::set method. It will be done internally by thos method and it
* allows assignments such as <code>prop = T(1)</code>.
* \param val The value that should be set.
*/
TemplateProperty<T>& operator=(T val);
/**
* These method sets the stored value to the provided value <code>val</code>,
* moving it into place. This move only happens if the provided value <code>val</code>
* is different from the stored value, which needs an operator== to exist for the type
* <code>T</code>. If the value are different, the listeners are notified.
* \param val The new value for this TemplateProperty
*/
/**
* These method sets the stored value to the provided value <code>val</code>,
* moving it into place. This move only happens if the provided value <code>val</code>
* is different from the stored value, which needs an operator== to exist for the type
* <code>T</code>. If the value are different, the listeners are notified.
* \param val The new value for this TemplateProperty
*/
virtual void setValue(T val);
/**
* Returns the currently stored value.
* \return The currently stored value
*/
/**
* Returns the currently stored value.
* \return The currently stored value
*/
T value() const;
protected:
/// The value that this TemplateProperty currently stores
/// The value that this TemplateProperty currently stores
T _value;
};

View File

@@ -29,7 +29,7 @@ namespace properties {
// The following macros can be used to quickly generate the necessary PropertyDelegate
// specializations required by the TemplateProperty class. Use the
// REGISTER_TEMPLATEPROPERTY_HEADER macro in the header file and the
// REGISTER_TEMPLATEPROPERTY_HEADER macro in the header file and the
// REGISTER_TEMPLATEPROPERTY_SOURCE macro in the source file of your new specialization of
// a TemplateProperty
@@ -77,13 +77,13 @@ namespace properties {
// DEFAULT_VALUE = The value (as type T) which should be used as a default value
// FROM_LUA_LAMBDA_EXPRESSION = A lambda expression receiving a lua_State* as the first
// parameter, a bool& as the second parameter and returning
// a value T. It is used by the fromLua method of
// TemplateProperty. The lambda expression must extract the
// stored value from the lua_State, return the value and
// report success in the second argument
// a value T. It is used by the fromLua method of
// TemplateProperty. The lambda expression must extract the
// stored value from the lua_State, return the value and
// report success in the second argument
// TO_LUA_LAMBDA_EXPRESSION = A lambda expression receiving a lua_State*, a value T and
// returning a bool. The lambda expression must encode the
// value T onto the lua_State stack and return the success
// value T onto the lua_State stack and return the success
// LUA_TYPE = The Lua type that will be produced/consumed by the previous
// Lambda expressions
#define REGISTER_TEMPLATEPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE, \
@@ -170,7 +170,7 @@ std::string TemplateProperty<T>::className() const {
//template <typename T>
//std::string TemplateProperty<T>::description() {
// return
// return
//}
template <typename T>
@@ -180,7 +180,7 @@ TemplateProperty<T>::operator T() {
template <typename T>
TemplateProperty<T>::operator T() const {
return _value;
return _value;
}
template <typename T>
@@ -198,11 +198,11 @@ T openspace::properties::TemplateProperty<T>::value() const
template <typename T>
void openspace::properties::TemplateProperty<T>::setValue(T val)
{
const bool changed = (val != _value);
if (changed) {
_value = std::move(val);
notifyListener();
}
const bool changed = (val != _value);
if (changed) {
_value = std::move(val);
notifyListener();
}
}
template <typename T>
@@ -220,14 +220,14 @@ template <typename T>
void TemplateProperty<T>::set(ghoul::any value) {
try {
T v = ghoul::any_cast<T>(std::move(value));
if (v != _value) {
_value = std::move(v);
notifyListener();
}
if (v != _value) {
_value = std::move(v);
notifyListener();
}
}
catch (ghoul::bad_any_cast&) {
LERRORC("TemplateProperty", "Illegal cast from '" << value.type().name()
<< "' to '" << typeid(T).name() << "'");
<< "' to '" << typeid(T).name() << "'");
}
}
@@ -244,16 +244,16 @@ bool TemplateProperty<T>::getLuaValue(lua_State* state) const {
template <typename T>
bool TemplateProperty<T>::setLuaValue(lua_State* state) {
bool success = false;
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromLuaValue<T>(state, success);
if (success)
set(ghoul::any(thisValue));
return success;
bool success = false;
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromLuaValue<T>(state, success);
if (success)
set(ghoul::any(thisValue));
return success;
}
template <typename T>
int TemplateProperty<T>::typeLua() const {
return PropertyDelegate<TemplateProperty<T>>::typeLua();
return PropertyDelegate<TemplateProperty<T>>::typeLua();
}
template <typename T>

View File

@@ -36,34 +36,34 @@ namespace properties {
*/
class TriggerProperty : public Property {
public:
/**
* Initializes the TriggerProperty by delegating the <code>identifier</code> and
* <code>guiName</code> to the Property constructor.
* \param identifier The unique identifier used for this Property
* \param guiName The human-readable name of this Property
*/
TriggerProperty(std::string identifier, std::string guiName);
/**
* Initializes the TriggerProperty by delegating the <code>identifier</code> and
* <code>guiName</code> to the Property constructor.
* \param identifier The unique identifier used for this Property
* \param guiName The human-readable name of this Property
*/
TriggerProperty(std::string identifier, std::string guiName);
/**
* Returns the class name <code>TriggerProperty</code>.
* \return The class name <code>TriggerProperty</code>
*/
std::string className() const;
/**
* Returns the class name <code>TriggerProperty</code>.
* \return The class name <code>TriggerProperty</code>
*/
std::string className() const;
/**
* Accepts only the <code>LUA_TNIL</code> type and will notify all the listeners
* that the event has been triggered.
* \param state The unused Lua state
* \return Returns always <code>true</code>
*/
bool setLuaValue(lua_State* state);
/**
* Accepts only the <code>LUA_TNIL</code> type and will notify all the listeners
* that the event has been triggered.
* \param state The unused Lua state
* \return Returns always <code>true</code>
*/
bool setLuaValue(lua_State* state);
/**
* Silently ignores any value that is passed into this function and will trigger the
* listeners regardless of the value
* \param value The ignored value
*/
void set(ghoul::any value);
/**
* Silently ignores any value that is passed into this function and will trigger the
* listeners regardless of the value
* \param value The ignored value
*/
void set(ghoul::any value);
};
} // namespace properties

View File

@@ -41,14 +41,14 @@
#include <openspace/util/updatestructures.h>
namespace ghoul {
namespace filesystem {
class File;
}
namespace opengl {
namespace opengl {
class ProgramObject;
class Texture;
}
class Texture;
}
}
namespace openspace {
@@ -56,11 +56,11 @@ namespace openspace {
class RenderableVolume;
class Camera;
class Scene;
class ABufferRenderer : public Renderer, public RaycasterListener {
public:
ABufferRenderer();
virtual ~ABufferRenderer();
ABufferRenderer();
virtual ~ABufferRenderer();
void initialize() override;
void deinitialize() override;
@@ -70,7 +70,7 @@ public:
void setResolution(glm::ivec2 res) override;
void update();
void render(float blackoutFactor, bool doPerformanceMeasurements) override;
void render(float blackoutFactor, bool doPerformanceMeasurements) override;
/**
@@ -120,7 +120,7 @@ private:
int _nAaSamples;
ghoul::Dictionary _rendererData;
}; // ABufferRenderer
} // openspace
}; // ABufferRenderer
} // openspace
#endif // __RENDERER_H__
#endif // __RENDERER_H__

View File

@@ -37,15 +37,15 @@
#include <openspace/util/updatestructures.h>
namespace ghoul {
class Dictionary;
class Dictionary;
namespace filesystem {
class File;
}
namespace opengl {
namespace opengl {
class ProgramObject;
class Texture;
}
class Texture;
}
}
namespace openspace {
@@ -53,11 +53,11 @@ namespace openspace {
class RenderableVolume;
class Camera;
class Scene;
class FramebufferRenderer : public Renderer, public RaycasterListener {
public:
FramebufferRenderer();
virtual ~FramebufferRenderer();
FramebufferRenderer();
virtual ~FramebufferRenderer();
void initialize() override;
void deinitialize() override;
@@ -70,7 +70,7 @@ public:
void setResolution(glm::ivec2 res) override;
void update() override;
void render(float blackoutFactor, bool doPerformanceMeasurements) override;
void render(float blackoutFactor, bool doPerformanceMeasurements) override;
/**
* Update render data
@@ -105,7 +105,7 @@ private:
int _nAaSamples;
ghoul::Dictionary _rendererData;
}; // FramebufferRenderer
} // openspace
}; // FramebufferRenderer
} // openspace
#endif // __FRAMEBUFFERRENDERER_H__
#endif // __FRAMEBUFFERRENDERER_H__

View File

@@ -36,10 +36,10 @@
// Forward declare to minimize dependencies
namespace ghoul {
namespace opengl {
class Texture;
}
class Dictionary;
namespace opengl {
class Texture;
}
class Dictionary;
}
namespace openspace {
@@ -60,8 +60,8 @@ public:
virtual bool initialize() = 0;
virtual bool deinitialize() = 0;
virtual bool isReady() const = 0;
bool isEnabled() const;
virtual bool isReady() const = 0;
bool isEnabled() const;
void setBoundingSphere(const PowerScaledScalar& boundingSphere);
const PowerScaledScalar& getBoundingSphere();
@@ -70,29 +70,29 @@ public:
virtual void render(const RenderData& data, RendererTasks& rendererTask);
virtual void update(const UpdateData& data);
bool isVisible() const;
bool hasTimeInterval();
bool getInterval(double& start, double& end);
bool hasBody();
bool getBody(std::string& body);
void setBody(std::string& body);
bool isVisible() const;
bool hasTimeInterval();
bool getInterval(double& start, double& end);
bool hasBody();
bool getBody(std::string& body);
void setBody(std::string& body);
void onEnabledChange(std::function<void(bool)> callback);
static void setPscUniforms(ghoul::opengl::ProgramObject& program, const Camera& camera, const PowerScaledCoordinate& position);
protected:
properties::BoolProperty _enabled;
properties::BoolProperty _enabled;
private:
PowerScaledScalar boundingSphere_;
std::string _startTime;
std::string _endTime;
std::string _targetBody;
bool _hasBody;
bool _hasTimeInterval;
std::string _startTime;
std::string _endTime;
std::string _targetBody;
bool _hasBody;
bool _hasTimeInterval;
};
} // namespace openspace

View File

@@ -33,15 +33,15 @@
#include <map>
namespace ghoul {
class Dictionary;
class Dictionary;
namespace filesystem {
class File;
}
namespace opengl {
namespace opengl {
class ProgramObject;
class Texture;
}
class Texture;
}
}
namespace openspace {
@@ -49,7 +49,7 @@ namespace openspace {
class RenderableVolume;
class Camera;
class Scene;
class Renderer {
public:
virtual void initialize() = 0;
@@ -60,14 +60,14 @@ public:
virtual void setResolution(glm::ivec2 res) = 0;
virtual void update() = 0;
virtual void render(float blackoutFactor, bool doPerformanceMeasurements) = 0;
virtual void render(float blackoutFactor, bool doPerformanceMeasurements) = 0;
/**
* Update render data
* Responsible for calling renderEngine::setRenderData
*/
virtual void updateRendererData() = 0;
}; // Renderer
} // openspace
}; // Renderer
} // openspace
#endif // __RENDERER_H__
#endif // __RENDERER_H__

View File

@@ -53,73 +53,73 @@ namespace openspace {
*/
class ScreenSpaceRenderable : public properties::PropertyOwner {
public:
ScreenSpaceRenderable();
~ScreenSpaceRenderable();
ScreenSpaceRenderable();
~ScreenSpaceRenderable();
virtual void render() = 0;
virtual bool initialize() = 0;
virtual bool deinitialize() = 0;
virtual void update() = 0;
virtual bool isReady() const = 0;
bool isEnabled() const;
glm::vec2 euclideanPosition() const {return _euclideanPosition.value();};
glm::vec2 sphericalPosition() const {return _sphericalPosition.value();};
float depth() const {return _depth.value();};
virtual void render() = 0;
virtual bool initialize() = 0;
virtual bool deinitialize() = 0;
virtual void update() = 0;
virtual bool isReady() const = 0;
bool isEnabled() const;
glm::vec2 euclideanPosition() const {return _euclideanPosition.value();};
glm::vec2 sphericalPosition() const {return _sphericalPosition.value();};
float depth() const {return _depth.value();};
protected:
void createPlane();
void useEuclideanCoordinates(bool b);
void createPlane();
void useEuclideanCoordinates(bool b);
/**
* @brief Converts vec2 polar coordinates to euclidean
*
* @param polar the coordinates theta and phi
* @param radius the radius position value of the plane
*
* @return glm::vec2 with the x and y position value of the plane
*/
glm::vec2 toEuclidean(glm::vec2 polar, float radius);
/**
* @brief Converts vec2 polar coordinates to euclidean
*
* @param polar the coordinates theta and phi
* @param radius the radius position value of the plane
*
* @return glm::vec2 with the x and y position value of the plane
*/
glm::vec2 toEuclidean(glm::vec2 polar, float radius);
/**
* @brief Converts vec2 euclidean coordinates to sperical
*
* @param euclidean the coordinates x and y
* @return glm::vec2 with the spherical coordinates theta and phi.
*/
glm::vec2 toSpherical(glm::vec2 euclidean);
void registerProperties();
void unregisterProperties();
/**
* @brief Converts vec2 euclidean coordinates to sperical
*
* @param euclidean the coordinates x and y
* @return glm::vec2 with the spherical coordinates theta and phi.
*/
glm::vec2 toSpherical(glm::vec2 euclidean);
void registerProperties();
void unregisterProperties();
void createShaders();
glm::mat4 scaleMatrix();
glm::mat4 rotationMatrix();
glm::mat4 translationMatrix();
void draw(glm::mat4 modelTransform);
void createShaders();
glm::mat4 scaleMatrix();
glm::mat4 rotationMatrix();
glm::mat4 translationMatrix();
void draw(glm::mat4 modelTransform);
properties::BoolProperty _enabled;
properties::BoolProperty _useFlatScreen;
properties::Vec2Property _euclideanPosition;
properties::Vec2Property _sphericalPosition;
properties::FloatProperty _depth;
properties::FloatProperty _scale;
properties::FloatProperty _alpha;
properties::TriggerProperty _delete;
properties::BoolProperty _enabled;
properties::BoolProperty _useFlatScreen;
properties::Vec2Property _euclideanPosition;
properties::Vec2Property _sphericalPosition;
properties::FloatProperty _depth;
properties::FloatProperty _scale;
properties::FloatProperty _alpha;
properties::TriggerProperty _delete;
GLuint _quad;
GLuint _vertexPositionBuffer;
const std::string _rendererPath;
ghoul::Dictionary _rendererData;
const std::string _vertexPath;
const std::string _fragmentPath;
std::unique_ptr<ghoul::opengl::Texture> _texture;
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
GLuint _quad;
GLuint _vertexPositionBuffer;
const std::string _rendererPath;
ghoul::Dictionary _rendererData;
const std::string _vertexPath;
const std::string _fragmentPath;
std::unique_ptr<ghoul::opengl::Texture> _texture;
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
bool _useEuclideanCoordinates;
const float _planeDepth = -2.0;
glm::vec2 _originalViewportSize;
bool _useEuclideanCoordinates;
const float _planeDepth = -2.0;
glm::vec2 _originalViewportSize;
float _radius;
float _radius;
};
} // namespace openspace
#endif // __SCREENSPACERENDERABLE_H__

View File

@@ -44,11 +44,11 @@ namespace openspace {
class SceneGraphNode : public properties::PropertyOwner {
public:
struct PerformanceRecord {
long long renderTime; // time in ns
long long updateTimeRenderable; // time in ns
long long updateTimeEphemeris; // time in ns
};
struct PerformanceRecord {
long long renderTime; // time in ns
long long updateTimeRenderable; // time in ns
long long updateTimeEphemeris; // time in ns
};
static std::string RootNodeName;
@@ -61,19 +61,19 @@ public:
static SceneGraphNode* createFromDictionary(const ghoul::Dictionary& dictionary);
bool initialize();
bool initialize();
bool deinitialize();
void update(const UpdateData& data);
void evaluate(const Camera* camera, const psc& parentPosition = psc());
void render(const RenderData& data, RendererTasks& tasks);
void updateCamera(Camera* camera) const;
void updateCamera(Camera* camera) const;
//void addNode(SceneGraphNode* child);
void addChild(SceneGraphNode* child);
void setParent(SceneGraphNode* parent);
//bool abandonChild(SceneGraphNode* child);
//bool abandonChild(SceneGraphNode* child);
const psc& position() const;
psc worldPosition() const;
@@ -86,7 +86,7 @@ public:
SceneGraphNode* childNode(const std::string& name);
const PerformanceRecord& performanceRecord() const { return _performanceRecord; }
const PerformanceRecord& performanceRecord() const { return _performanceRecord; }
void setRenderable(Renderable* renderable);
const Renderable* renderable() const;
@@ -101,11 +101,11 @@ public:
private:
bool sphereInsideFrustum(const psc& s_pos, const PowerScaledScalar& s_rad, const Camera* camera);
std::vector<SceneGraphNode*> _children;
std::vector<SceneGraphNode*> _children;
SceneGraphNode* _parent;
Ephemeris* _ephemeris;
PerformanceRecord _performanceRecord;
PerformanceRecord _performanceRecord;
Renderable* _renderable;
bool _renderableVisible;

View File

@@ -58,26 +58,26 @@ public:
* describing the function, and whether it should be shared in a parallel
* connection (#parallelShared)
*/
struct Function {
struct Function {
/// The name of the function
std::string name;
std::string name;
/// The function pointer that is executed if the function is called
lua_CFunction function;
lua_CFunction function;
/// A text describing the arugments to this function
std::string argumentText;
std::string argumentText;
/// A help text describing what the function does/
std::string helpText;
std::string helpText;
/// If <code>true</code>, this function will be shared with other parallel
/// connections
bool parallelShared;
};
};
/// The name of the library
std::string name;
/// The list of all functions for this library
std::vector<Function> functions;
std::vector<Function> functions;
/// Comparison function that compares two LuaLibrary%s name
bool operator<(const LuaLibrary& rhs) const;
bool operator<(const LuaLibrary& rhs) const;
};
/**
@@ -92,25 +92,25 @@ public:
*/
void deinitialize();
void initializeLuaState(lua_State* state);
void initializeLuaState(lua_State* state);
void addLibrary(LuaLibrary library);
void addLibrary(LuaLibrary library);
bool hasLibrary(const std::string& name);
bool runScript(const std::string& script);
bool runScriptFile(const std::string& filename);
bool writeDocumentation(const std::string& filename, const std::string& type) const;
bool writeDocumentation(const std::string& filename, const std::string& type) const;
void serialize(SyncBuffer* syncBuffer);
void serialize(SyncBuffer* syncBuffer);
void deserialize(SyncBuffer* syncBuffer);
void deserialize(SyncBuffer* syncBuffer);
void postSynchronizationPreDraw();
void postSynchronizationPreDraw();
void preSynchronization();
void preSynchronization();
void queueScript(const std::string &script);
void queueScript(const std::string &script);
std::vector<std::string> cachedScripts();
@@ -122,7 +122,7 @@ public:
void cacheScript(const std::string &library, const std::string &function, const std::string &script);
private:
bool registerLuaLibrary(lua_State* state, const LuaLibrary& library);
bool registerLuaLibrary(lua_State* state, const LuaLibrary& library);
void addLibraryFunctions(lua_State* state, const LuaLibrary& library, bool replace);
bool isLibraryNameAllowed(lua_State* state, const std::string& name);
@@ -133,11 +133,11 @@ private:
lua_State* _state = nullptr;
std::set<LuaLibrary> _registeredLibraries;
//sync variables
std::mutex _mutex;
std::vector<std::string> _queuedScripts;
std::vector<std::string> _receivedScripts;
std::string _currentSyncedScript;
//sync variables
std::mutex _mutex;
std::vector<std::string> _queuedScripts;
std::vector<std::string> _receivedScripts;
std::string _currentSyncedScript;
//parallel variables
std::map<std::string, std::map<std::string, std::string>> _cachedScripts;

View File

@@ -48,8 +48,8 @@ private:
void updateVertices();
std::vector<float> _vertices;
bool _initialized;
GLuint _vaoId;
GLuint _vBufferId;
GLuint _vaoId;
GLuint _vBufferId;
glm::vec3 _size;
glm::vec3 _normal;
float _planeDistance;

View File

@@ -39,8 +39,8 @@ public:
bool initialize();
void render();
GLuint _vaoId;
GLuint _vBufferId;
GLuint _vaoId;
GLuint _vBufferId;
glm::vec3 _size;
};

View File

@@ -90,7 +90,7 @@ namespace openspace {
// mutable bool _viewMatrixIsDirty;
//};
class SyncBuffer;
class SyncBuffer;
class Camera {
public:
@@ -99,38 +99,38 @@ public:
void setPosition(psc pos);
const psc& position() const;
const psc& unsynchedPosition() const;
const psc& unsynchedPosition() const;
void setModelMatrix(glm::mat4 modelMatrix);
const glm::mat4& modelMatrix() const;
void setModelMatrix(glm::mat4 modelMatrix);
const glm::mat4& modelMatrix() const;
void setViewMatrix(glm::mat4 viewMatrix);
const glm::mat4& viewMatrix() const;
void setViewMatrix(glm::mat4 viewMatrix);
const glm::mat4& viewMatrix() const;
void setProjectionMatrix(glm::mat4 projectionMatrix);
const glm::mat4& projectionMatrix() const;
void setProjectionMatrix(glm::mat4 projectionMatrix);
const glm::mat4& projectionMatrix() const;
const glm::mat4& viewProjectionMatrix() const;
void setCameraDirection(glm::vec3 cameraDirection);
glm::vec3 cameraDirection() const;
void setFocusPosition(psc pos);
const psc& focusPosition() const;
void setFocusPosition(psc pos);
const psc& focusPosition() const;
void setViewRotationMatrix(glm::mat4 m);
const glm::mat4& viewRotationMatrix() const;
void setViewRotationMatrix(glm::mat4 m);
const glm::mat4& viewRotationMatrix() const;
void compileViewRotationMatrix();
void rotate(const glm::quat& rotation);
void setRotation(glm::quat rotation);
// const glm::quat& rotation() const;
void setRotation(glm::mat4 rotation);
void setRotation(glm::mat4 rotation);
const glm::vec3& viewDirection() const;
const glm::vec3& viewDirection() const;
const float& maxFov() const;
const float& maxFov() const;
const float& sinMaxFov() const;
void setMaxFov(float fov);
void setScaling(glm::vec2 scaling);
@@ -139,43 +139,43 @@ public:
void setLookUpVector(glm::vec3 lookUp);
const glm::vec3& lookUpVector() const;
void postSynchronizationPreDraw();
void preSynchronization();
void serialize(SyncBuffer* syncBuffer);
void deserialize(SyncBuffer* syncBuffer);
void postSynchronizationPreDraw();
void preSynchronization();
void serialize(SyncBuffer* syncBuffer);
void deserialize(SyncBuffer* syncBuffer);
private:
float _maxFov;
float _sinMaxFov;
mutable glm::mat4 _viewProjectionMatrix;
glm::mat4 _modelMatrix;
glm::mat4 _viewMatrix;
glm::mat4 _projectionMatrix;
glm::mat4 _modelMatrix;
glm::mat4 _viewMatrix;
glm::mat4 _projectionMatrix;
mutable bool _dirtyViewProjectionMatrix;
glm::vec3 _viewDirection;
glm::vec3 _cameraDirection;
psc _focusPosition;
psc _focusPosition;
// glm::quat _viewRotation;
glm::vec3 _lookUp;
mutable std::mutex _mutex;
//local variables
glm::mat4 _localViewRotationMatrix;
glm::vec2 _localScaling;
psc _localPosition;
mutable std::mutex _mutex;
//local variables
glm::mat4 _localViewRotationMatrix;
glm::vec2 _localScaling;
psc _localPosition;
//shared copies of local variables
glm::vec2 _sharedScaling;
psc _sharedPosition;
glm::mat4 _sharedViewRotationMatrix;
//shared copies of local variables
glm::vec2 _sharedScaling;
psc _sharedPosition;
glm::mat4 _sharedViewRotationMatrix;
//synced copies of local variables
glm::vec2 _syncedScaling;
psc _syncedPosition;
glm::mat4 _syncedViewRotationMatrix;
//synced copies of local variables
glm::vec2 _syncedScaling;
psc _syncedPosition;
glm::mat4 _syncedViewRotationMatrix;
};
} // namespace openspace

View File

@@ -61,8 +61,8 @@ namespace openspace {
enum class MouseAction {
Release = 0,
Press = 1,
Repeat = 2
Press = 1,
Repeat = 2
};
// The X11 library header files define Button1-Button5 as defines, so they have to be
@@ -85,7 +85,7 @@ enum class MouseButton {
Button7 = 6,
Button8 = 8,
Last = Button8,
Left = Button1,
Left = Button1,
Right = Button2,
Middle = Button3
};

View File

@@ -44,7 +44,7 @@ public:
PowerScaledCoordinate();
PowerScaledCoordinate(PowerScaledCoordinate&& rhs);
PowerScaledCoordinate(const PowerScaledCoordinate& rhs);
PowerScaledCoordinate(const PowerScaledCoordinate& rhs);
// Sets the power scaled coordinates directly
PowerScaledCoordinate(glm::vec4 v);
@@ -61,11 +61,11 @@ public:
// returns the rescaled, "normal" coordinates
glm::vec3 vec3() const;
// return the full psc as dvec4()
glm::dvec4 dvec4() const;
// return the full psc as dvec4()
glm::dvec4 dvec4() const;
// rescaled return as dvec3
glm::dvec3 dvec3() const;
// rescaled return as dvec3
glm::dvec3 dvec3() const;
// length of the vector as a pss
PowerScaledScalar length() const;

View File

@@ -36,52 +36,52 @@ namespace openspace {
class PowerScaledScalar {
public:
// constructors
PowerScaledScalar();
PowerScaledScalar(const glm::vec2 &v);
PowerScaledScalar(float f1, float f2);
static PowerScaledScalar CreatePSS(double d1);
// constructors
PowerScaledScalar();
PowerScaledScalar(const glm::vec2 &v);
PowerScaledScalar(float f1, float f2);
static PowerScaledScalar CreatePSS(double d1);
const glm::vec2& vec2() const;
float lengthf() const;
const glm::vec2& vec2() const;
float lengthf() const;
// operator overloading
PowerScaledScalar& operator=(const PowerScaledScalar& rhs);
PowerScaledScalar& operator+=(const PowerScaledScalar& rhs);
const PowerScaledScalar operator+(const PowerScaledScalar& rhs) const;
PowerScaledScalar& operator-=(const PowerScaledScalar& rhs);
const PowerScaledScalar operator-(const PowerScaledScalar& rhs) const;
PowerScaledScalar& operator*=(const PowerScaledScalar& rhs);
const PowerScaledScalar operator*(const PowerScaledScalar& rhs) const;
PowerScaledScalar& operator*=(const float& rhs);
const PowerScaledScalar operator*(const float& rhs) const;
float& operator[](unsigned int idx);
float operator[](unsigned int idx) const;
// operator overloading
PowerScaledScalar& operator=(const PowerScaledScalar& rhs);
PowerScaledScalar& operator+=(const PowerScaledScalar& rhs);
const PowerScaledScalar operator+(const PowerScaledScalar& rhs) const;
PowerScaledScalar& operator-=(const PowerScaledScalar& rhs);
const PowerScaledScalar operator-(const PowerScaledScalar& rhs) const;
PowerScaledScalar& operator*=(const PowerScaledScalar& rhs);
const PowerScaledScalar operator*(const PowerScaledScalar& rhs) const;
PowerScaledScalar& operator*=(const float& rhs);
const PowerScaledScalar operator*(const float& rhs) const;
float& operator[](unsigned int idx);
float operator[](unsigned int idx) const;
// comparison
bool operator==(const PowerScaledScalar& other) const;
bool operator<(const PowerScaledScalar& other) const;
bool operator>(const PowerScaledScalar& other) const;
bool operator<=(const PowerScaledScalar& other) const;
bool operator>=(const PowerScaledScalar& other) const;
bool operator==(double other) const;
bool operator<(double other) const;
bool operator>(double other) const;
bool operator<=(double other) const;
bool operator>=(double other) const;
// comparison
bool operator==(const PowerScaledScalar& other) const;
bool operator<(const PowerScaledScalar& other) const;
bool operator>(const PowerScaledScalar& other) const;
bool operator<=(const PowerScaledScalar& other) const;
bool operator>=(const PowerScaledScalar& other) const;
bool operator==(double other) const;
bool operator<(double other) const;
bool operator>(double other) const;
bool operator<=(double other) const;
bool operator>=(double other) const;
// glm integration
PowerScaledScalar& operator=(const glm::vec2& rhs);
PowerScaledScalar& operator=(float rhs);
// glm integration
PowerScaledScalar& operator=(const glm::vec2& rhs);
PowerScaledScalar& operator=(float rhs);
friend std::ostream& operator<<(std::ostream& os, const PowerScaledScalar& rhs);
// allow the power scaled coordinates to access private members
friend class PowerScaledCoordinate;
// allow the power scaled coordinates to access private members
friend class PowerScaledCoordinate;
private:
// float vector used when returning float values
glm::vec2 _data;
// float vector used when returning float values
glm::vec2 _data;
};

View File

@@ -37,9 +37,9 @@ class PowerScaledSphere {
public:
// initializers
PowerScaledSphere(const PowerScaledScalar& radius,
int segments = 8);
PowerScaledSphere(properties::Vec4Property &radius,
int segments, std::string planetName);
int segments = 8);
PowerScaledSphere(properties::Vec4Property &radius,
int segments, std::string planetName);
~PowerScaledSphere();
PowerScaledSphere(const PowerScaledSphere& cpy);
@@ -57,9 +57,9 @@ public:
GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase
} Vertex;
GLuint _vaoID;
GLuint _vBufferID;
GLuint _iBufferID;
GLuint _vaoID;
GLuint _vBufferID;
GLuint _iBufferID;
unsigned int _isize;
unsigned int _vsize;

View File

@@ -31,18 +31,18 @@ namespace openspace {
class ProgressBar {
public:
ProgressBar(int end, int width = 70, std::ostream& stream = std::cout);
~ProgressBar();
ProgressBar(int end, int width = 70, std::ostream& stream = std::cout);
~ProgressBar();
ProgressBar& operator=(const ProgressBar& rhs) = delete;
void print(int current);
void print(int current);
private:
int _width;
int _previous;
int _end;
std::ostream& _stream;
int _width;
int _previous;
int _end;
std::ostream& _stream;
};

View File

@@ -45,22 +45,22 @@ public:
* This struct stores the incoming log entries with their #level, #timeString,
* #category, #message, and the generated #timeStamp used for the expiry calculation.
*/
struct LogEntry {
struct LogEntry {
/// The ghoul::logging::LogManager::LogLevel of the log message
LogLevel level;
LogLevel level;
/// The timepoint when the log message arrived at the ScreenLog
std::chrono::time_point<std::chrono::steady_clock> timeStamp;
/// The time string as retrieved from the log message
std::string timeString;
std::string timeString;
/// The category as retrieved from the log message
std::string category;
std::string category;
/// The actual message of the log entry
std::string message;
};
std::string message;
};
/**
* Constructor that creates a ScreenLog with the provided \p timeToLive, and the
@@ -80,8 +80,8 @@ public:
* \param category The category of the log message
* \param message The actual log message that was transmitted
*/
void log(ghoul::logging::LogManager::LogLevel level, const std::string& category,
const std::string& message) override;
void log(ghoul::logging::LogManager::LogLevel level, const std::string& category,
const std::string& message) override;
/**
* This method removes all the stored LogEntry%s that have expired, calculated by
@@ -100,7 +100,7 @@ public:
private:
/// The list of all LogEntry%s stored by this ScreenLog
std::vector<LogEntry> _entries;
std::vector<LogEntry> _entries;
/// The time-to-live for the LogEntry%s in this ScreenLog. Is used by the
/// #removeExpiredEntries method to remove expired entries.

View File

@@ -58,85 +58,85 @@ class SyncBuffer;
class Time {
public:
/**
* Initializes the Time singleton.
* \return <code>true</code> if the initialization succeeded, <code>false</code>
* otherwise
/**
* Initializes the Time singleton.
* \return <code>true</code> if the initialization succeeded, <code>false</code>
* otherwise
* \pre The Time singleton must not have been initialized
*/
static void initialize();
*/
static void initialize();
/**
* Deinitializes the Time singleton. This method will not unload the kernel that was
* possibly loaded during the initialize method.
/**
* Deinitializes the Time singleton. This method will not unload the kernel that was
* possibly loaded during the initialize method.
* \pre The Time singleton must have been initialized
*/
static void deinitialize();
*/
static void deinitialize();
/**
* Returns the reference to the Time singleton object.
* \return The reference to the Time singleton object
/**
* Returns the reference to the Time singleton object.
* \return The reference to the Time singleton object
* \pre The Time singleton must have been initialized
*/
*/
static Time& ref();
/**
* Returns <code>true</code> if the singleton has been successfully initialized,
* <code>false</code> otherwise
* \return <code>true</code> if the singleton has been successfully initialized,
* <code>false</code> otherwise
*/
static bool isInitialized();
/**
* Sets the current time to the specified value in seconds past the J2000 epoch. This
* value can be negative to represent dates before the epoch.
* \param value The number of seconds after the J2000 epoch
/**
* Returns <code>true</code> if the singleton has been successfully initialized,
* <code>false</code> otherwise
* \return <code>true</code> if the singleton has been successfully initialized,
* <code>false</code> otherwise
*/
static bool isInitialized();
/**
* Sets the current time to the specified value in seconds past the J2000 epoch. This
* value can be negative to represent dates before the epoch.
* \param value The number of seconds after the J2000 epoch
* \param requireJump Whether or not the time change is big enough to require a
* time-jump; defaults to true as most calls to set time will require recomputation of
* planetary paths etc.
*/
void setTime(double value, bool requireJump = true);
*/
void setTime(double value, bool requireJump = true);
/**
* Sets the current time to the specified value given as a Spice compliant string as
* described in the Spice documentation
* (http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html)
* \param time The time to be set as a date string
/**
* Sets the current time to the specified value given as a Spice compliant string as
* described in the Spice documentation
* (http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html)
* \param time The time to be set as a date string
* \param requireJump Whether or not the time change is big enough to require a
* time-jump; defaults to true as most calls to set time will require recomputation of
* planetary paths etc.
*/
void setTime(std::string time, bool requireJump = true);
*/
void setTime(std::string time, bool requireJump = true);
/**
* Returns the current time as the number of seconds past the J2000 epoch. If the
* current time is a date before that epoch, the returned value will be negative.
* \return The current time as the number of seconds past the J2000 epoch
*/
double currentTime() const;
/**
* Returns the current time as the number of seconds past the J2000 epoch. If the
* current time is a date before that epoch, the returned value will be negative.
* \return The current time as the number of seconds past the J2000 epoch
*/
double currentTime() const;
/**
* Returns the current time as a formatted date string compliant with ISO 8601 and
* thus also compliant with the Spice library.
* \return The current time as a formatted date string
*/
std::string currentTimeUTC() const;
/**
* Returns the current time as a formatted date string compliant with ISO 8601 and
* thus also compliant with the Spice library.
* \return The current time as a formatted date string
*/
std::string currentTimeUTC() const;
/**
* Sets the delta time value that is the number of seconds that should pass for each
* real-time second. This value is used in the advanceTime(double) method to easily
* advance the simulation time.
* \param deltaT The number of seconds that should pass for each real-time second
*/
void setDeltaTime(double deltaT);
/**
* Sets the delta time value that is the number of seconds that should pass for each
* real-time second. This value is used in the advanceTime(double) method to easily
* advance the simulation time.
* \param deltaT The number of seconds that should pass for each real-time second
*/
void setDeltaTime(double deltaT);
/**
* Returns the delta time, that is the number of seconds that pass in the simulation
* for each real-time second
* \return The number of seconds that pass for each real-time second
*/
double deltaTime() const;
/**
* Returns the delta time, that is the number of seconds that pass in the simulation
* for each real-time second
* \return The number of seconds that pass for each real-time second
*/
double deltaTime() const;
/**
* Sets the pause function, i.e. setting the deltaTime to 0 (<code>pause</code> =
@@ -156,67 +156,67 @@ public:
*/
bool togglePause();
/**
* Advances the simulation time using the deltaTime() and the <code>tickTime</code>.
* The deltaTime() is the number of simulation seconds that pass for each real-time
* second. <code>tickTime</code> is the number of real-time seconds that passed since
* the last call to this method. If this method is called in the render loop, the
* <code>tickTime</code> should be equivalent to the frame time.
* \param tickTime The number of real-time seconds that passed since the last call
* to this method
* \return The new time value after advancing the time
*/
double advanceTime(double tickTime);
/**
* Advances the simulation time using the deltaTime() and the <code>tickTime</code>.
* The deltaTime() is the number of simulation seconds that pass for each real-time
* second. <code>tickTime</code> is the number of real-time seconds that passed since
* the last call to this method. If this method is called in the render loop, the
* <code>tickTime</code> should be equivalent to the frame time.
* \param tickTime The number of real-time seconds that passed since the last call
* to this method
* \return The new time value after advancing the time
*/
double advanceTime(double tickTime);
void serialize(SyncBuffer* syncBuffer);
void serialize(SyncBuffer* syncBuffer);
void deserialize(SyncBuffer* syncBuffer);
void deserialize(SyncBuffer* syncBuffer);
void postSynchronizationPreDraw();
void postSynchronizationPreDraw();
void preSynchronization();
void preSynchronization();
bool timeJumped() const;
bool timeJumped() const;
void setTimeJumped(bool jumped);
void setTimeJumped(bool jumped);
bool paused() const;
/**
* Returns the Lua library that contains all Lua functions available to change the
* current time, retrieve the current time etc. The functions contained are
* - openspace::luascriptfunctions::time_setDeltaTime
* - openspace::luascriptfunctions::time_deltaTime
* - openspace::luascriptfunctions::time_setTime
* - openspace::luascriptfunctions::time_currentTime
* - openspace::luascriptfunctions::time_currentTimeUTC
* \return The Lua library that contains all Lua functions available to change the
* Time singleton
*/
static scripting::ScriptEngine::LuaLibrary luaLibrary();
/**
* Returns the Lua library that contains all Lua functions available to change the
* current time, retrieve the current time etc. The functions contained are
* - openspace::luascriptfunctions::time_setDeltaTime
* - openspace::luascriptfunctions::time_deltaTime
* - openspace::luascriptfunctions::time_setTime
* - openspace::luascriptfunctions::time_currentTime
* - openspace::luascriptfunctions::time_currentTimeUTC
* \return The Lua library that contains all Lua functions available to change the
* Time singleton
*/
static scripting::ScriptEngine::LuaLibrary luaLibrary();
private:
static Time* _instance; ///< The singleton instance
//local copies
static Time* _instance; ///< The singleton instance
//local copies
/// The time stored as the number of seconds past the J2000 epoch
double _time = -1.0;
double _dt = 1.0;
bool _timeJumped = false;
double _time = -1.0;
double _dt = 1.0;
bool _timeJumped = false;
bool _timePaused = false;
bool _jockeHasToFixThisLater;
//shared copies
double _sharedTime = -1.0;
double _sharedDt = 1.0;
bool _sharedTimeJumped = false;
//shared copies
double _sharedTime = -1.0;
double _sharedDt = 1.0;
bool _sharedTimeJumped = false;
//synced copies
double _syncedTime = -1.0;
double _syncedDt = 1.0;
bool _syncedTimeJumped = false;
std::mutex _syncMutex;
//synced copies
double _syncedTime = -1.0;
double _syncedDt = 1.0;
bool _syncedTimeJumped = false;
std::mutex _syncMutex;
};
} // namespace openspace

View File

@@ -37,16 +37,16 @@ struct InitializeData {
};
struct UpdateData {
double time;
double time;
bool isTimeJump;
double delta;
bool doPerformanceMeasurement;
double delta;
bool doPerformanceMeasurement;
};
struct RenderData {
const Camera& camera;
psc position;
bool doPerformanceMeasurement;
const Camera& camera;
psc position;
bool doPerformanceMeasurement;
};
struct RaycasterTask {

View File

@@ -48,7 +48,7 @@ const psc& DynamicEphemeris::position() const {
}
void DynamicEphemeris::setPosition(psc pos) {
_position = pos;
_position = pos;
}
void DynamicEphemeris::update(const UpdateData&) {}

View File

@@ -35,8 +35,8 @@ public:
= ghoul::Dictionary());
virtual ~DynamicEphemeris();
virtual const psc& position() const;
virtual void update(const UpdateData& data) override;
void setPosition(psc pos);
virtual void update(const UpdateData& data) override;
void setPosition(psc pos);
private:
psc _position;
};

View File

@@ -29,7 +29,7 @@
namespace {
const std::string _loggerCat = "SpiceEphemeris";
//const std::string keyGhosting = "EphmerisGhosting";
//const std::string keyGhosting = "EphmerisGhosting";
const std::string KeyBody = "Body";
const std::string KeyOrigin = "Observer";
@@ -42,7 +42,7 @@ SpiceEphemeris::SpiceEphemeris(const ghoul::Dictionary& dictionary)
: _targetName("")
, _originName("")
, _position()
, _kernelsLoadedSuccessfully(true)
, _kernelsLoadedSuccessfully(true)
{
const bool hasBody = dictionary.getValue(KeyBody, _targetName);
if (!hasBody)
@@ -52,15 +52,15 @@ SpiceEphemeris::SpiceEphemeris(const ghoul::Dictionary& dictionary)
if (!hasObserver)
LERROR("SpiceEphemeris does not contain the key '" << KeyOrigin << "'");
//dictionary.getValue(keyGhosting, _ghosting);
//dictionary.getValue(keyGhosting, _ghosting);
ghoul::Dictionary kernels;
dictionary.getValue(KeyKernels, kernels);
for (size_t i = 1; i <= kernels.size(); ++i) {
std::string kernel;
bool success = kernels.getValue(std::to_string(i), kernel);
if (!success)
LERROR("'" << KeyKernels << "' has to be an array-style table");
ghoul::Dictionary kernels;
dictionary.getValue(KeyKernels, kernels);
for (size_t i = 1; i <= kernels.size(); ++i) {
std::string kernel;
bool success = kernels.getValue(std::to_string(i), kernel);
if (!success)
LERROR("'" << KeyKernels << "' has to be an array-style table");
try {
SpiceManager::ref().loadKernel(kernel);
@@ -70,7 +70,7 @@ SpiceEphemeris::SpiceEphemeris(const ghoul::Dictionary& dictionary)
LERROR("Could not load SPICE kernel: " << e.what());
_kernelsLoadedSuccessfully = false;
}
}
}
}
const psc& SpiceEphemeris::position() const {
@@ -78,21 +78,21 @@ const psc& SpiceEphemeris::position() const {
}
void SpiceEphemeris::update(const UpdateData& data) {
if (!_kernelsLoadedSuccessfully)
return;
if (!_kernelsLoadedSuccessfully)
return;
double lightTime = 0.0;
glm::dvec3 position = SpiceManager::ref().targetPosition(_targetName, _originName, "GALACTIC", {}, data.time, lightTime);
//double interval = openspace::ImageSequencer::ref().getIntervalLength();
//if (_ghosting == "TRUE" && interval > 60){
// double _time = openspace::ImageSequencer::ref().getNextCaptureTime();
// SpiceManager::ref().getTargetPosition(_targetName, _originName,
// "GALACTIC", "NONE", _time, position, lightTime);
//}
//
_position = psc::CreatePowerScaledCoordinate(position.x, position.y, position.z);
_position[3] += 3;
double lightTime = 0.0;
glm::dvec3 position = SpiceManager::ref().targetPosition(_targetName, _originName, "GALACTIC", {}, data.time, lightTime);
//double interval = openspace::ImageSequencer::ref().getIntervalLength();
//if (_ghosting == "TRUE" && interval > 60){
// double _time = openspace::ImageSequencer::ref().getNextCaptureTime();
// SpiceManager::ref().getTargetPosition(_targetName, _originName,
// "GALACTIC", "NONE", _time, position, lightTime);
//}
//
_position = psc::CreatePowerScaledCoordinate(position.x, position.y, position.z);
_position[3] += 3;
}
} // namespace openspace

View File

@@ -35,15 +35,15 @@ class SpiceEphemeris : public Ephemeris {
public:
SpiceEphemeris(const ghoul::Dictionary& dictionary);
const psc& position() const;
void update(const UpdateData& data) override;
void update(const UpdateData& data) override;
private:
std::string _targetName;
std::string _originName;
psc _position;
bool _kernelsLoadedSuccessfully;
//std::string _ghosting;
std::string _name;
bool _kernelsLoadedSuccessfully;
//std::string _ghosting;
std::string _name;
};
} // namespace openspace

View File

@@ -35,7 +35,7 @@ public:
= ghoul::Dictionary());
virtual ~StaticEphemeris();
virtual const psc& position() const;
virtual void update(const UpdateData& data) override;
virtual void update(const UpdateData& data) override;
private:
psc _position;
};

View File

@@ -31,29 +31,29 @@
namespace {
const std::string _loggerCat = "ModelGeometry";
const std::string keyGeomModelFile = "GeometryFile";
const int8_t CurrentCacheVersion = 3;
const std::string keyGeomModelFile = "GeometryFile";
const int8_t CurrentCacheVersion = 3;
const std::string keyType = "Type";
const std::string keyName = "Name";
const std::string keySize = "Magnification";
const std::string keyName = "Name";
const std::string keySize = "Magnification";
}
namespace openspace {
namespace modelgeometry {
ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) {
std::string geometryType;
const bool success = dictionary.getValue(
keyType, geometryType);
if (!success) {
std::string geometryType;
const bool success = dictionary.getValue(
keyType, geometryType);
if (!success) {
LERROR("ModelGeometry did not contain a correct value of the key '"
<< keyType << "'");
<< keyType << "'");
return nullptr;
}
ghoul::TemplateFactory<ModelGeometry>* factory
= FactoryManager::ref().factory<ModelGeometry>();
}
ghoul::TemplateFactory<ModelGeometry>* factory
= FactoryManager::ref().factory<ModelGeometry>();
ModelGeometry* result = factory->create(geometryType, dictionary);
ModelGeometry* result = factory->create(geometryType, dictionary);
if (result == nullptr) {
LERROR("Failed to create a ModelGeometry object of type '" << geometryType
<< "'");
@@ -65,27 +65,27 @@ ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dict
ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary)
: _parent(nullptr)
, _magnification("magnification", "Magnification", 0.f, 0.f, 10.f)
, _mode(GL_TRIANGLES)
, _mode(GL_TRIANGLES)
{
setName("ModelGeometry");
setName("ModelGeometry");
std::string name;
bool success = dictionary.getValue(keyName, name);
ghoul_assert(success, "Name tag was not present");
std::string name;
bool success = dictionary.getValue(keyName, name);
ghoul_assert(success, "Name tag was not present");
if (dictionary.hasKeyAndValue<double>(keySize))
_magnification = static_cast<float>(dictionary.value<double>(keySize));
success = dictionary.getValue(keyGeomModelFile, _file);
if (!success) {
LERROR("Geometric Model file of '" << name << "' did not provide a key '"
<< keyGeomModelFile << "'");
}
_file = FileSys.absolutePath(_file);
success = dictionary.getValue(keyGeomModelFile, _file);
if (!success) {
LERROR("Geometric Model file of '" << name << "' did not provide a key '"
<< keyGeomModelFile << "'");
}
_file = FileSys.absolutePath(_file);
if (!FileSys.fileExists(_file, ghoul::filesystem::FileSystem::RawPath::Yes))
LERROR("Could not load the geometric model file '" << _file << "': File not found");
LERROR("Could not load the geometric model file '" << _file << "': File not found");
addProperty(_magnification);
}
@@ -94,53 +94,53 @@ ModelGeometry::~ModelGeometry() {
}
void ModelGeometry::render() {
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo);
glDrawElements(_mode, static_cast<GLsizei>(_indices.size()), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo);
glDrawElements(_mode, static_cast<GLsizei>(_indices.size()), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
}
void ModelGeometry::changeRenderMode(const GLenum mode) {
_mode = mode;
_mode = mode;
}
bool ModelGeometry::initialize(Renderable* parent) {
_parent = parent;
PowerScaledScalar ps = PowerScaledScalar(1.0, 0.0); // will set proper bounding soon.
_parent->setBoundingSphere(ps);
PowerScaledScalar ps = PowerScaledScalar(1.0, 0.0); // will set proper bounding soon.
_parent->setBoundingSphere(ps);
if (_vertices.empty())
return false;
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vbo);
glGenBuffers(1, &_ibo);
if (_vertices.empty())
return false;
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vbo);
glGenBuffers(1, &_ibo);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, _vertices.size() * sizeof(Vertex), _vertices.data(), GL_STATIC_DRAW);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, _vertices.size() * sizeof(Vertex), _vertices.data(), GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, location)));
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, tex)));
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)));
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, location)));
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, tex)));
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _indices.size() * sizeof(int), _indices.data(), GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _indices.size() * sizeof(int), _indices.data(), GL_STATIC_DRAW);
glBindVertexArray(0);
glBindVertexArray(0);
return true;
}
void ModelGeometry::deinitialize() {
glDeleteBuffers(1, &_vbo);
glDeleteVertexArrays(1, &_vaoID);
glDeleteBuffers(1, &_ibo);
glDeleteBuffers(1, &_vbo);
glDeleteVertexArrays(1, &_vaoID);
glDeleteBuffers(1, &_ibo);
}
bool ModelGeometry::loadObj(const std::string& filename) {
@@ -235,19 +235,19 @@ bool ModelGeometry::loadCachedFile(const std::string& filename) {
}
bool ModelGeometry::getVertices(std::vector<Vertex>* vertexList) {
vertexList->clear();
for (auto v : _vertices)
vertexList->push_back(v);
vertexList->clear();
for (auto v : _vertices)
vertexList->push_back(v);
return !(vertexList->empty());
return !(vertexList->empty());
}
bool ModelGeometry::getIndices(std::vector<int>* indexList) {
indexList->clear();
for (auto i : _indices)
indexList->push_back(i);
indexList->clear();
for (auto i : _indices)
indexList->push_back(i);
return !(indexList->empty());
return !(indexList->empty());
}
void ModelGeometry::setUniforms(ghoul::opengl::ProgramObject& program) {

View File

@@ -37,42 +37,42 @@ namespace modelgeometry {
class ModelGeometry : public properties::PropertyOwner {
public:
static ModelGeometry* createFromDictionary(const ghoul::Dictionary& dictionary);
static ModelGeometry* createFromDictionary(const ghoul::Dictionary& dictionary);
struct Vertex {
GLfloat location[4];
GLfloat tex[2];
GLfloat normal[3];
};
struct Vertex {
GLfloat location[4];
GLfloat tex[2];
GLfloat normal[3];
};
ModelGeometry(const ghoul::Dictionary& dictionary);
virtual ~ModelGeometry();
virtual bool initialize(Renderable* parent);
virtual void deinitialize();
void render();
virtual bool loadModel(const std::string& filename) = 0;
void changeRenderMode(const GLenum mode);
bool getVertices(std::vector<Vertex>* vertexList);
bool getIndices(std::vector<int>* indexList);
ModelGeometry(const ghoul::Dictionary& dictionary);
virtual ~ModelGeometry();
virtual bool initialize(Renderable* parent);
virtual void deinitialize();
void render();
virtual bool loadModel(const std::string& filename) = 0;
void changeRenderMode(const GLenum mode);
bool getVertices(std::vector<Vertex>* vertexList);
bool getIndices(std::vector<int>* indexList);
virtual void setUniforms(ghoul::opengl::ProgramObject& program);
protected:
Renderable* _parent;
Renderable* _parent;
bool loadObj(const std::string& filename);
bool loadCachedFile(const std::string& filename);
bool saveCachedFile(const std::string& filename);
bool loadObj(const std::string& filename);
bool loadCachedFile(const std::string& filename);
bool saveCachedFile(const std::string& filename);
properties::FloatProperty _magnification;
GLuint _vaoID;
GLuint _vbo;
GLuint _ibo;
GLenum _mode;
GLuint _vaoID;
GLuint _vbo;
GLuint _ibo;
GLenum _mode;
std::vector<Vertex> _vertices;
std::vector<int> _indices;
std::string _file;
std::vector<Vertex> _vertices;
std::vector<int> _indices;
std::string _file;
};
} // namespace modelgeometry

View File

@@ -34,13 +34,13 @@ namespace openspace {
namespace planetgeometry {
PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) {
std::string geometryType;
const bool success = dictionary.getValue(KeyType, geometryType);
if (!success) {
std::string geometryType;
const bool success = dictionary.getValue(KeyType, geometryType);
if (!success) {
LERROR("PlanetGeometry did not contain a correct value of the key '"
<< KeyType << "'");
<< KeyType << "'");
return nullptr;
}
}
ghoul::TemplateFactory<PlanetGeometry>* factory
= FactoryManager::ref().factory<PlanetGeometry>();
@@ -56,7 +56,7 @@ PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& di
PlanetGeometry::PlanetGeometry()
: _parent(nullptr)
{
setName("PlanetGeometry");
setName("PlanetGeometry");
}
PlanetGeometry::~PlanetGeometry()

View File

@@ -38,54 +38,54 @@
#include <math.h>
namespace {
const std::string _loggerCat = "RenderableConstellationBounds";
const std::string _loggerCat = "RenderableConstellationBounds";
const std::string keyVertexFile = "File";
const std::string keyConstellationFile = "ConstellationFile";
const std::string keyReferenceFrame = "ReferenceFrame";
const std::string keyVertexFile = "File";
const std::string keyConstellationFile = "ConstellationFile";
const std::string keyReferenceFrame = "ReferenceFrame";
const std::string defaultReferenceFrame = "J2000";
const std::string defaultReferenceFrame = "J2000";
float deg2rad(float deg) {
return static_cast<float>((deg / 360.f) * 2.f * M_PI);
}
float convertHrsToRadians(float rightAscension) {
// 360 degrees / 24h = 15 degrees/h
return deg2rad(rightAscension * 15);
}
float deg2rad(float deg) {
return static_cast<float>((deg / 360.f) * 2.f * M_PI);
}
float convertHrsToRadians(float rightAscension) {
// 360 degrees / 24h = 15 degrees/h
return deg2rad(rightAscension * 15);
}
}
namespace openspace {
RenderableConstellationBounds::RenderableConstellationBounds(
const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _vertexFilename("")
, _constellationFilename("")
, _distance("distance", "Distance to the celestial Sphere", 15.f, 0.f, 30.f)
, _constellationSelection("constellationSelection", "Constellation Selection")
, _originReferenceFrame("")
, _vao(0)
, _vbo(0)
const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _vertexFilename("")
, _constellationFilename("")
, _distance("distance", "Distance to the celestial Sphere", 15.f, 0.f, 30.f)
, _constellationSelection("constellationSelection", "Constellation Selection")
, _originReferenceFrame("")
, _vao(0)
, _vbo(0)
{
bool success = dictionary.getValue(keyVertexFile, _vertexFilename);
if (!success) {
LERROR("RenderableConstellationBounds did not contain a key '" <<
keyVertexFile << "'");
}
bool success = dictionary.getValue(keyVertexFile, _vertexFilename);
if (!success) {
LERROR("RenderableConstellationBounds did not contain a key '" <<
keyVertexFile << "'");
}
dictionary.getValue(keyConstellationFile, _constellationFilename);
dictionary.getValue(keyConstellationFile, _constellationFilename);
success = dictionary.getValue(keyReferenceFrame, _originReferenceFrame);
if (!success) {
_originReferenceFrame = defaultReferenceFrame;
}
success = dictionary.getValue(keyReferenceFrame, _originReferenceFrame);
if (!success) {
_originReferenceFrame = defaultReferenceFrame;
}
addProperty(_distance);
addProperty(_constellationSelection);
_constellationSelection.onChange(
std::bind(&RenderableConstellationBounds::selectionPropertyHasChanged, this)
);
addProperty(_distance);
addProperty(_constellationSelection);
_constellationSelection.onChange(
std::bind(&RenderableConstellationBounds::selectionPropertyHasChanged, this)
);
}
RenderableConstellationBounds::~RenderableConstellationBounds() {
@@ -97,50 +97,50 @@ bool RenderableConstellationBounds::initialize() {
"${MODULE_BASE}/shaders/constellationbounds_vs.glsl",
"${MODULE_BASE}/shaders/constellationbounds_fs.glsl");
if (!_program)
return false;
if (!_program)
return false;
bool loadSuccess = loadVertexFile();
if (!loadSuccess)
return false;
loadSuccess = loadConstellationFile();
if (!loadSuccess)
return false;
bool loadSuccess = loadVertexFile();
if (!loadSuccess)
return false;
loadSuccess = loadConstellationFile();
if (!loadSuccess)
return false;
fillSelectionProperty();
fillSelectionProperty();
if (_vao == 0) {
glGenVertexArrays(1, &_vao);
LDEBUG("Generating Vertex Array id '" << _vao << "'");
}
if (_vbo == 0) {
glGenBuffers(1, &_vbo);
LDEBUG("Generating Vertex Buffer Object id '" << _vbo << "'");
}
if (_vao == 0) {
glGenVertexArrays(1, &_vao);
LDEBUG("Generating Vertex Array id '" << _vao << "'");
}
if (_vbo == 0) {
glGenBuffers(1, &_vbo);
LDEBUG("Generating Vertex Buffer Object id '" << _vbo << "'");
}
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER,
_vertexValues.size() * 3 * sizeof(float),
&_vertexValues[0],
GL_STATIC_DRAW
);
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER,
_vertexValues.size() * 3 * sizeof(float),
&_vertexValues[0],
GL_STATIC_DRAW
);
GLint positionAttrib = _program->attributeLocation("in_position");
glEnableVertexAttribArray(positionAttrib);
glVertexAttribPointer(positionAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
GLint positionAttrib = _program->attributeLocation("in_position");
glEnableVertexAttribArray(positionAttrib);
glVertexAttribPointer(positionAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
return true;
return true;
}
bool RenderableConstellationBounds::deinitialize() {
glDeleteBuffers(1, &_vbo);
_vbo = 0;
glDeleteVertexArrays(1, &_vao);
_vao = 0;
glDeleteBuffers(1, &_vbo);
_vbo = 0;
glDeleteVertexArrays(1, &_vao);
_vao = 0;
RenderEngine& renderEngine = OsEng.renderEngine();
if (_program) {
@@ -148,204 +148,204 @@ bool RenderableConstellationBounds::deinitialize() {
_program = nullptr;
}
return true;
return true;
}
bool RenderableConstellationBounds::isReady() const {
return (_vao != 0) && (_vbo != 0) && (_program != nullptr);
return (_vao != 0) && (_vbo != 0) && (_program != nullptr);
}
void RenderableConstellationBounds::render(const RenderData& data) {
_program->activate();
_program->activate();
//glm::mat4 modelMatrix = data.camera.modelMatrix();
glm::mat4 viewMatrix = data.camera.viewMatrix();
glm::mat4 projectionMatrix = data.camera.projectionMatrix();
//glm::mat4 modelMatrix = data.camera.modelMatrix();
glm::mat4 viewMatrix = data.camera.viewMatrix();
glm::mat4 projectionMatrix = data.camera.projectionMatrix();
setPscUniforms(*_program.get(), data.camera, data.position);
setPscUniforms(*_program.get(), data.camera, data.position);
_program->setUniform("exponent", _distance);
_program->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_program->setUniform("ModelTransform", glm::mat4(glm::dmat4(_stateMatrix)));
_program->setUniform("exponent", _distance);
_program->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_program->setUniform("ModelTransform", glm::mat4(glm::dmat4(_stateMatrix)));
glBindVertexArray(_vao);
for (const ConstellationBound& bound : _constellationBounds) {
if (bound.isEnabled) {
glDrawArrays(
//GL_LINE_STRIP,
GL_LINE_LOOP,
static_cast<GLsizei>(bound.startIndex),
static_cast<GLsizei>(bound.nVertices)
);
}
}
glBindVertexArray(0);
_program->deactivate();
glBindVertexArray(_vao);
for (const ConstellationBound& bound : _constellationBounds) {
if (bound.isEnabled) {
glDrawArrays(
//GL_LINE_STRIP,
GL_LINE_LOOP,
static_cast<GLsizei>(bound.startIndex),
static_cast<GLsizei>(bound.nVertices)
);
}
}
glBindVertexArray(0);
_program->deactivate();
}
void RenderableConstellationBounds::update(const UpdateData& data) {
_stateMatrix = SpiceManager::ref().positionTransformMatrix(
_originReferenceFrame,
"GALACTIC",
data.time
);
_originReferenceFrame,
"GALACTIC",
data.time
);
}
bool RenderableConstellationBounds::loadVertexFile() {
if (_vertexFilename.empty())
return false;
if (_vertexFilename.empty())
return false;
std::string fileName = absPath(_vertexFilename);
std::ifstream file(fileName);
if (!file.good()) {
LERROR("Could not open file '" << fileName << "' for reading");
return false;
}
std::string fileName = absPath(_vertexFilename);
std::ifstream file(fileName);
if (!file.good()) {
LERROR("Could not open file '" << fileName << "' for reading");
return false;
}
ConstellationBound currentBound;
currentBound.constellationAbbreviation = "";
ConstellationBound currentBound;
currentBound.constellationAbbreviation = "";
std::string currentLine;
int currentLineNumber = 1;
std::string currentLine;
int currentLineNumber = 1;
float ra;
float dec;
std::string constellationName;
SpiceDouble rectangularValues[3];
float ra;
float dec;
std::string constellationName;
SpiceDouble rectangularValues[3];
// Overview of the reading algorithm:
// We keep an active ConstellationBound (currentBound) and update it until we read
// a new constellation name, at which point the currentBound is stored away, a new,
// empty ConstellationBound is created and set at the currentBound
while (file.good()) {
std::getline(file, currentLine);
if (currentLine.empty())
continue;
// Overview of the reading algorithm:
// We keep an active ConstellationBound (currentBound) and update it until we read
// a new constellation name, at which point the currentBound is stored away, a new,
// empty ConstellationBound is created and set at the currentBound
while (file.good()) {
std::getline(file, currentLine);
if (currentLine.empty())
continue;
// @CHECK: Is this the best way of doing this? ---abock
std::stringstream s(currentLine);
s >> ra;
s >> dec;
s >> constellationName;
// @CHECK: Is this the best way of doing this? ---abock
std::stringstream s(currentLine);
s >> ra;
s >> dec;
s >> constellationName;
if (!s.good()) {
// If this evaluates to true, the stream was not completely filled, which
// means that the line was incomplete, so there was an error
LERROR("Error reading file '" << fileName << "' at line #" << currentLineNumber);
break;
}
if (!s.good()) {
// If this evaluates to true, the stream was not completely filled, which
// means that the line was incomplete, so there was an error
LERROR("Error reading file '" << fileName << "' at line #" << currentLineNumber);
break;
}
// Did we arrive at a new constellation?
if (constellationName != currentBound.constellationAbbreviation) {
// Store how many vertices we read during the active time of the constellation
currentBound.nVertices = (_vertexValues.size() - currentBound.startIndex);
// Store the constellation and start a new one
_constellationBounds.push_back(currentBound);
currentBound = ConstellationBound();
currentBound.isEnabled = true;
currentBound.constellationAbbreviation = constellationName;
currentBound.constellationFullName = constellationName;
currentBound.startIndex = _vertexValues.size();
}
// Did we arrive at a new constellation?
if (constellationName != currentBound.constellationAbbreviation) {
// Store how many vertices we read during the active time of the constellation
currentBound.nVertices = (_vertexValues.size() - currentBound.startIndex);
// Store the constellation and start a new one
_constellationBounds.push_back(currentBound);
currentBound = ConstellationBound();
currentBound.isEnabled = true;
currentBound.constellationAbbreviation = constellationName;
currentBound.constellationFullName = constellationName;
currentBound.startIndex = _vertexValues.size();
}
// The file format stores the right ascension in hours, while SPICE expects them
// to be in radians
ra = convertHrsToRadians(ra);
// The file format stores the right ascension in hours, while SPICE expects them
// to be in radians
ra = convertHrsToRadians(ra);
// Likewise, the declination is stored in degrees and needs to be converted
dec = deg2rad(dec);
// Likewise, the declination is stored in degrees and needs to be converted
dec = deg2rad(dec);
// Convert the (right ascension, declination) to rectangular coordinates)
// The 1.0 is the distance of the celestial sphere, we will scale that in the
// render function
radrec_c(1.0, ra, dec, rectangularValues);
// Convert the (right ascension, declination) to rectangular coordinates)
// The 1.0 is the distance of the celestial sphere, we will scale that in the
// render function
radrec_c(1.0, ra, dec, rectangularValues);
// Add the new vertex to our list of vertices
_vertexValues.push_back({{
static_cast<float>(rectangularValues[0]),
static_cast<float>(rectangularValues[1]),
static_cast<float>(rectangularValues[2])
}});
++currentLineNumber;
}
// Add the new vertex to our list of vertices
_vertexValues.push_back({{
static_cast<float>(rectangularValues[0]),
static_cast<float>(rectangularValues[1]),
static_cast<float>(rectangularValues[2])
}});
++currentLineNumber;
}
// Due to the way we read the file, the first (empty) constellation bounds will not
// contain any valid values. So we have to remove it
_constellationBounds.erase(_constellationBounds.begin());
// Due to the way we read the file, the first (empty) constellation bounds will not
// contain any valid values. So we have to remove it
_constellationBounds.erase(_constellationBounds.begin());
// And we still have the one value that was left when we exited the loop
currentBound.nVertices = (_vertexValues.size() - currentBound.startIndex);
_constellationBounds.push_back(currentBound);
// And we still have the one value that was left when we exited the loop
currentBound.nVertices = (_vertexValues.size() - currentBound.startIndex);
_constellationBounds.push_back(currentBound);
return true;
return true;
}
bool RenderableConstellationBounds::loadConstellationFile() {
if (_constellationFilename.empty())
return true;
if (_constellationFilename.empty())
return true;
std::string fileName = absPath(_constellationFilename);
std::ifstream file(fileName);
if (!file.good()) {
LERROR("Could not open file '" << fileName << "' for reading");
return false;
}
std::string fileName = absPath(_constellationFilename);
std::ifstream file(fileName);
if (!file.good()) {
LERROR("Could not open file '" << fileName << "' for reading");
return false;
}
std::string line;
int index = 0;
while (file.good()) {
std::getline(file, line);
if (line.empty())
continue;
std::string line;
int index = 0;
while (file.good()) {
std::getline(file, line);
if (line.empty())
continue;
std::string abbreviation;
std::stringstream s(line);
s >> abbreviation;
std::string abbreviation;
std::stringstream s(line);
s >> abbreviation;
auto it = std::find_if(_constellationBounds.begin(), _constellationBounds.end(),
[abbreviation](const ConstellationBound& bound) {
return bound.constellationAbbreviation == abbreviation;
});
if (it == _constellationBounds.end()) {
LERROR("Could not find constellation '" << abbreviation << "' in list");
return false;
}
auto it = std::find_if(_constellationBounds.begin(), _constellationBounds.end(),
[abbreviation](const ConstellationBound& bound) {
return bound.constellationAbbreviation == abbreviation;
});
if (it == _constellationBounds.end()) {
LERROR("Could not find constellation '" << abbreviation << "' in list");
return false;
}
// Update the constellations full name
s >> it->constellationFullName;
// Update the constellations full name
s >> it->constellationFullName;
++index;
}
++index;
}
return true;
return true;
}
void RenderableConstellationBounds::fillSelectionProperty() {
// Each constellation is associated with its position in the array as this is unique
// and will be constant during the runtime
for (int i = 0 ; i < _constellationBounds.size(); ++i) {
const ConstellationBound& bound = _constellationBounds[i];
_constellationSelection.addOption( { i, bound.constellationFullName } );
}
// Each constellation is associated with its position in the array as this is unique
// and will be constant during the runtime
for (int i = 0 ; i < _constellationBounds.size(); ++i) {
const ConstellationBound& bound = _constellationBounds[i];
_constellationSelection.addOption( { i, bound.constellationFullName } );
}
}
void RenderableConstellationBounds::selectionPropertyHasChanged() {
const std::vector<int>& values = _constellationSelection;
// If no values are selected (the default), we want to show all constellations
if (values.size() == 0) {
for (ConstellationBound& b : _constellationBounds)
b.isEnabled = true;
}
else {
// In the worst case, this algorithm runs with 2 * nConstellations, which is
// acceptable as the number of constellations is < 100
// First disable all constellations
for (ConstellationBound& b : _constellationBounds)
b.isEnabled = false;
// then re-enable the ones for which we have indices
for (int value : values)
_constellationBounds[value].isEnabled = true;
}
const std::vector<int>& values = _constellationSelection;
// If no values are selected (the default), we want to show all constellations
if (values.size() == 0) {
for (ConstellationBound& b : _constellationBounds)
b.isEnabled = true;
}
else {
// In the worst case, this algorithm runs with 2 * nConstellations, which is
// acceptable as the number of constellations is < 100
// First disable all constellations
for (ConstellationBound& b : _constellationBounds)
b.isEnabled = false;
// then re-enable the ones for which we have indices
for (int value : values)
_constellationBounds[value].isEnabled = true;
}
}
} // namespace openspace

View File

@@ -52,76 +52,76 @@ namespace openspace {
*/
class RenderableConstellationBounds : public Renderable {
public:
RenderableConstellationBounds(const ghoul::Dictionary& dictionary);
~RenderableConstellationBounds();
RenderableConstellationBounds(const ghoul::Dictionary& dictionary);
~RenderableConstellationBounds();
bool initialize() override;
bool deinitialize() override;
bool initialize() override;
bool deinitialize() override;
bool isReady() const override;
bool isReady() const override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
/// Stores the constellation bounds
struct ConstellationBound {
std::string constellationAbbreviation; ///< The abbreviation of the constellation
std::string constellationFullName;
bool isEnabled;
size_t startIndex; ///< The index of the first vertex describing the bounds
size_t nVertices; ///< The number of vertices describing the bounds
};
/// Stores the constellation bounds
struct ConstellationBound {
std::string constellationAbbreviation; ///< The abbreviation of the constellation
std::string constellationFullName;
bool isEnabled;
size_t startIndex; ///< The index of the first vertex describing the bounds
size_t nVertices; ///< The number of vertices describing the bounds
};
/**
* Loads the file specified in <code>_vertexFilename</code> and fills the
* <code>_constellationBounds</code> variable, as well as the
* <code>_vertexValues</code> list. If this method fails, the content of either
* destination is undefined.
* \return <code>true</code> if the loading succeeded, <code>false</code> otherwise
*/
bool loadVertexFile();
/**
* Loads the file specified in <code>_vertexFilename</code> and fills the
* <code>_constellationBounds</code> variable, as well as the
* <code>_vertexValues</code> list. If this method fails, the content of either
* destination is undefined.
* \return <code>true</code> if the loading succeeded, <code>false</code> otherwise
*/
bool loadVertexFile();
/**
* Loads the file specified in <code>_constellationFilename</code> that contains the
* mapping between abbreviations and full names of constellations.
* \return <code>true</code> if the loading succeeded, <code>false</code> otherwise
*/
bool loadConstellationFile();
/**
* Loads the file specified in <code>_constellationFilename</code> that contains the
* mapping between abbreviations and full names of constellations.
* \return <code>true</code> if the loading succeeded, <code>false</code> otherwise
*/
bool loadConstellationFile();
/// Fills the <code>_constellationSelection</code> property with all constellations
void fillSelectionProperty();
/// Fills the <code>_constellationSelection</code> property with all constellations
void fillSelectionProperty();
/**
* Callback method that gets triggered when <code>_constellationSelection</code>
* changes.
*/
void selectionPropertyHasChanged();
/**
* Callback method that gets triggered when <code>_constellationSelection</code>
* changes.
*/
void selectionPropertyHasChanged();
std::string _vertexFilename; ///< The filename containing the constellation bounds
std::string _constellationFilename; ///< The file containing constellation names
std::string _vertexFilename; ///< The filename containing the constellation bounds
std::string _constellationFilename; ///< The file containing constellation names
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
/// The list of all loaded constellation bounds
std::vector<ConstellationBound> _constellationBounds;
typedef std::array<float, 3> Vertex;
std::vector<Vertex> _vertexValues; ///< A list of all vertices of all bounds
/// The list of all loaded constellation bounds
std::vector<ConstellationBound> _constellationBounds;
typedef std::array<float, 3> Vertex;
std::vector<Vertex> _vertexValues; ///< A list of all vertices of all bounds
/// The radius of the celestial sphere onto which the bounds are drawn
properties::FloatProperty _distance;
/// The radius of the celestial sphere onto which the bounds are drawn
properties::FloatProperty _distance;
/// The property that stores all indices of constellations that should be drawn
properties::SelectionProperty _constellationSelection;
/// The property that stores all indices of constellations that should be drawn
properties::SelectionProperty _constellationSelection;
std::string _originReferenceFrame; ///< Reference frame in which bounds are defined
/// Used to translate between the origin reference frame and the target frame
glm::dmat3 _stateMatrix;
std::string _originReferenceFrame; ///< Reference frame in which bounds are defined
/// Used to translate between the origin reference frame and the target frame
glm::dmat3 _stateMatrix;
GLuint _vao;
GLuint _vbo;
GLuint _vao;
GLuint _vbo;
};
} // namespace openspace

View File

@@ -31,13 +31,13 @@
//#include <imgui.h>
namespace {
const std::string _loggerCat = "RenderableCrawlingLine";
const std::string _loggerCat = "RenderableCrawlingLine";
const std::string KeySource = "Source";
const std::string KeyTarget = "Target";
const std::string KeyInstrument = "Instrument";
const std::string KeyReferenceFrame = "Frame";
const std::string keyColor = "RGB";
const std::string keyColor = "RGB";
static const int SourcePosition = 0;
static const int TargetPosition = 1;
@@ -58,23 +58,23 @@ RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictiona
dictionary.getValue(KeyReferenceFrame, _referenceFrame);
if (dictionary.hasKeyAndValue<glm::vec3>(keyColor))
dictionary.getValue(keyColor, _lineColor);
else
_lineColor = glm::vec3(1);
if (dictionary.hasKeyAndValue<glm::vec3>(keyColor))
dictionary.getValue(keyColor, _lineColor);
else
_lineColor = glm::vec3(1);
}
bool RenderableCrawlingLine::isReady() const {
bool ready = true;
bool ready = true;
ready &= !_source.empty();
ready &= !_target.empty();
ready &= !_instrumentName.empty();
ready &= (_program != nullptr);
return ready;
ready &= (_program != nullptr);
return ready;
}
bool RenderableCrawlingLine::initialize() {
_frameCounter = 0;
_frameCounter = 0;
bool completeSuccess = true;
_program = ghoul::opengl::ProgramObject::Build("RenderableCrawlingLine",
"${SHADERS}/modules/crawlingline/crawlingline_vs.glsl",
@@ -83,65 +83,65 @@ bool RenderableCrawlingLine::initialize() {
if (!_program)
return false;
glGenVertexArrays(1, &_vao);
glGenBuffers(1, &_vbo);
glGenVertexArrays(1, &_vao);
glGenBuffers(1, &_vbo);
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(psc), NULL, GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, (void*)0);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, (void*)0);
glBindVertexArray(0);
glBindVertexArray(0);
return completeSuccess;
return completeSuccess;
}
bool RenderableCrawlingLine::deinitialize(){
glDeleteVertexArrays(1, &_vao);
glDeleteVertexArrays(1, &_vao);
_vao = 0;
glDeleteBuffers(1, &_vbo);
glDeleteBuffers(1, &_vbo);
_vbo = 0;
return true;
return true;
}
void RenderableCrawlingLine::render(const RenderData& data) {
if (_drawLine) {
_program->activate();
_frameCounter++;
// fetch data
psc currentPosition = data.position;
psc campos = data.camera.position();
glm::mat4 camrot = data.camera.viewRotationMatrix();
if (_drawLine) {
_program->activate();
_frameCounter++;
// fetch data
psc currentPosition = data.position;
psc campos = data.camera.position();
glm::mat4 camrot = data.camera.viewRotationMatrix();
glm::mat4 transform = glm::mat4(1);
glm::mat4 transform = glm::mat4(1);
// setup the data to the shader
_program->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_program->setUniform("ModelTransform", transform);
// setup the data to the shader
_program->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_program->setUniform("ModelTransform", transform);
int frame = _frameCounter % 60;
float fadingFactor = static_cast<float>(sin((frame * pi_c()) / 60));
float alpha = 0.6f + fadingFactor*0.4f;
int frame = _frameCounter % 60;
float fadingFactor = static_cast<float>(sin((frame * pi_c()) / 60));
float alpha = 0.6f + fadingFactor*0.4f;
glLineWidth(2.f);
glLineWidth(2.f);
_program->setUniform("_alpha", alpha);
_program->setUniform("color", _lineColor);
setPscUniforms(_program, &data.camera, data.position);
_program->setUniform("color", _lineColor);
setPscUniforms(_program, &data.camera, data.position);
glBindVertexArray(_vao);
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(psc) * 2, _positions);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_LINES, 0, 2);
glBindVertexArray(0);
_program->deactivate();
glDrawArrays(GL_LINES, 0, 2);
glBindVertexArray(0);
_program->deactivate();
}
}
@@ -149,28 +149,28 @@ void RenderableCrawlingLine::update(const UpdateData& data) {
if (_program->isDirty())
_program->rebuildFromFile();
glm::dmat3 transformMatrix = glm::dmat3(1);
openspace::SpiceManager::ref().getPositionTransformMatrix(_source, _referenceFrame, data.time, transformMatrix);
openspace::SpiceManager::ref().getPositionTransformMatrix(_source, _referenceFrame, data.time, transformMatrix);
glm::mat4 tmp = glm::mat4(1);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++){
tmp[i][j] = static_cast<float>(transformMatrix[i][j]);
}
}
glm::mat4 tmp = glm::mat4(1);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++){
tmp[i][j] = static_cast<float>(transformMatrix[i][j]);
}
}
_positions[SourcePosition] = PowerScaledCoordinate::CreatePowerScaledCoordinate(0, 0, 0);
_positions[SourcePosition] = PowerScaledCoordinate::CreatePowerScaledCoordinate(0, 0, 0);
std::string shape, instrument;
std::vector<glm::dvec3> bounds;
glm::dvec3 boresight;
std::string shape, instrument;
std::vector<glm::dvec3> bounds;
glm::dvec3 boresight;
bool found = openspace::SpiceManager::ref().getFieldOfView(_source, shape, instrument, boresight, bounds);
bool found = openspace::SpiceManager::ref().getFieldOfView(_source, shape, instrument, boresight, bounds);
if (!found)
LERROR("Could not find field of view for instrument");
glm::vec4 target(boresight[0], boresight[1], boresight[2], 12);
target = tmp * target;
glm::vec4 target(boresight[0], boresight[1], boresight[2], 12);
target = tmp * target;
_positions[TargetPosition] = target;
_positions[TargetPosition] = target;
if (ImageSequencer2::ref().isReady()) {
_imageSequenceTime = ImageSequencer2::ref().instrumentActiveTime(_instrumentName);

View File

@@ -45,15 +45,15 @@
#include <math.h>
namespace {
const std::string _loggerCat = "RenderableModel";
const std::string keySource = "Rotation.Source";
const std::string keyDestination = "Rotation.Destination";
const std::string _loggerCat = "RenderableModel";
const std::string keySource = "Rotation.Source";
const std::string keyDestination = "Rotation.Destination";
const std::string keyGeometry = "Geometry";
const std::string keyBody = "Body";
const std::string keyStart = "StartTime";
const std::string keyEnd = "EndTime";
const std::string keyFading = "Shading.Fadeable";
//const std::string keyGhosting = "Shading.Ghosting";
const std::string keyBody = "Body";
const std::string keyStart = "StartTime";
const std::string keyEnd = "EndTime";
const std::string keyFading = "Shading.Fadeable";
//const std::string keyGhosting = "Shading.Ghosting";
}
@@ -61,8 +61,8 @@ namespace openspace {
RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _performFade("performFading", "Perform Fading", false)
, _colorTexturePath("colorTexture", "Color Texture")
, _performFade("performFading", "Perform Fading", false)
, _fading("fading", "Fade", 0)
, _programObject(nullptr)
, _texture(nullptr)
@@ -70,57 +70,57 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
, _alpha(1.f)
//, _isGhost(false)
, _performShading("performShading", "Perform Shading", true)
, _frameCount(0)
, _frameCount(0)
{
std::string name;
std::string name;
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
ghoul_assert(success, "Name was not passed to RenderableModel");
ghoul::Dictionary geometryDictionary;
success = dictionary.getValue(keyGeometry, geometryDictionary);
if (success) {
geometryDictionary.setValue(SceneGraphNode::KeyName, name);
_geometry = modelgeometry::ModelGeometry::createFromDictionary(geometryDictionary);
}
ghoul::Dictionary geometryDictionary;
success = dictionary.getValue(keyGeometry, geometryDictionary);
if (success) {
geometryDictionary.setValue(SceneGraphNode::KeyName, name);
_geometry = modelgeometry::ModelGeometry::createFromDictionary(geometryDictionary);
}
std::string texturePath = "";
success = dictionary.getValue("Textures.Color", texturePath);
if (success)
std::string texturePath = "";
success = dictionary.getValue("Textures.Color", texturePath);
if (success)
_colorTexturePath = absPath(texturePath);
addPropertySubOwner(_geometry);
addPropertySubOwner(_geometry);
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderableModel::loadTexture, this));
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderableModel::loadTexture, this));
dictionary.getValue(keySource, _source);
dictionary.getValue(keyDestination, _destination);
dictionary.getValue(keyBody, _target);
dictionary.getValue(keySource, _source);
dictionary.getValue(keyDestination, _destination);
dictionary.getValue(keyBody, _target);
openspace::SpiceManager::ref().addFrame(_target, _source);
openspace::SpiceManager::ref().addFrame(_target, _source);
setBoundingSphere(pss(1.f, 9.f));
addProperty(_performShading);
addProperty(_performShading);
if (dictionary.hasKeyAndValue<bool>(keyFading)) {
bool fading;
dictionary.getValue(keyFading, fading);
_performFade = fading;
}
addProperty(_performFade);
if (dictionary.hasKeyAndValue<bool>(keyFading)) {
bool fading;
dictionary.getValue(keyFading, fading);
_performFade = fading;
}
addProperty(_performFade);
//if (dictionary.hasKeyAndValue<bool>(keyGhosting)) {
// bool ghosting;
// dictionary.getValue(keyGhosting, ghosting);
// _isGhost = ghosting;
//}
//if (dictionary.hasKeyAndValue<bool>(keyGhosting)) {
// bool ghosting;
// dictionary.getValue(keyGhosting, ghosting);
// _isGhost = ghosting;
//}
}
bool RenderableModel::isReady() const {
bool ready = true;
ready &= (_programObject != nullptr);
ready &= (_texture != nullptr);
return ready;
bool ready = true;
ready &= (_programObject != nullptr);
ready &= (_texture != nullptr);
return ready;
}
bool RenderableModel::initialize() {
@@ -141,18 +141,18 @@ bool RenderableModel::initialize() {
completeSuccess &= (_texture != nullptr);
completeSuccess &= _geometry->initialize(this);
completeSuccess &= !_source.empty();
completeSuccess &= !_destination.empty();
completeSuccess &= !_source.empty();
completeSuccess &= !_destination.empty();
return completeSuccess;
}
bool RenderableModel::deinitialize() {
if (_geometry) {
_geometry->deinitialize();
delete _geometry;
if (_geometry) {
_geometry->deinitialize();
delete _geometry;
_geometry = nullptr;
}
}
_texture = nullptr;
@@ -162,59 +162,59 @@ bool RenderableModel::deinitialize() {
_programObject = nullptr;
}
return true;
return true;
}
void RenderableModel::render(const RenderData& data) {
_programObject->activate();
_frameCount++;
_frameCount++;
double lt;
double lt;
glm::mat4 transform = glm::mat4(1);
glm::mat4 tmp = glm::mat4(1);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
tmp[i][j] = static_cast<float>(_stateMatrix[i][j]);
}
}
transform *= tmp;
double time = openspace::Time::ref().currentTime();
bool targetPositionCoverage = openspace::SpiceManager::ref().hasSpkCoverage(_target, time);
if (!targetPositionCoverage){
int frame = _frameCount % 180;
glm::mat4 tmp = glm::mat4(1);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
tmp[i][j] = static_cast<float>(_stateMatrix[i][j]);
}
}
transform *= tmp;
double time = openspace::Time::ref().currentTime();
bool targetPositionCoverage = openspace::SpiceManager::ref().hasSpkCoverage(_target, time);
if (!targetPositionCoverage){
int frame = _frameCount % 180;
float fadingFactor = static_cast<float>(sin((frame * M_PI) / 180));
_alpha = 0.5f + fadingFactor * 0.5f;
}
else
_alpha = 1.0f;
float fadingFactor = static_cast<float>(sin((frame * M_PI) / 180));
_alpha = 0.5f + fadingFactor * 0.5f;
}
else
_alpha = 1.0f;
glm::dvec3 p =
SpiceManager::ref().targetPosition(_target, "SUN", "GALACTIC", {}, time, lt);
psc tmppos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
glm::vec3 cam_dir = glm::normalize(data.camera.position().vec3() - tmppos.vec3());
_programObject->setUniform("cam_dir", cam_dir);
_programObject->setUniform("transparency", _alpha);
_programObject->setUniform("sun_pos", _sunPosition.vec3());
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(*_programObject.get(), data.camera, data.position);
_programObject->setUniform("_performShading", _performShading);
glm::vec3 cam_dir = glm::normalize(data.camera.position().vec3() - tmppos.vec3());
_programObject->setUniform("cam_dir", cam_dir);
_programObject->setUniform("transparency", _alpha);
_programObject->setUniform("sun_pos", _sunPosition.vec3());
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(*_programObject.get(), data.camera, data.position);
_programObject->setUniform("_performShading", _performShading);
_geometry->setUniforms(*_programObject);
if (_performFade && _fading > 0.f){
_fading = _fading - 0.01f;
}
else if (!_performFade && _fading < 1.f){
_fading = _fading + 0.01f;
if (_performFade && _fading > 0.f){
_fading = _fading - 0.01f;
}
else if (!_performFade && _fading < 1.f){
_fading = _fading + 0.01f;
}
}
_programObject->setUniform("fading", _fading);
_programObject->setUniform("fading", _fading);
// Bind texture
ghoul::opengl::TextureUnit unit;
@@ -222,7 +222,7 @@ void RenderableModel::render(const RenderData& data) {
_texture->bind();
_programObject->setUniform("texture1", unit);
_geometry->render();
_geometry->render();
// disable shader
_programObject->deactivate();
@@ -231,25 +231,25 @@ void RenderableModel::render(const RenderData& data) {
void RenderableModel::update(const UpdateData& data) {
if (_programObject->isDirty())
_programObject->rebuildFromFile();
double _time = data.time;
double _time = data.time;
//if (_isGhost){
// futureTime = openspace::ImageSequencer::ref().getNextCaptureTime();
// double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - data.time;
// double interval = openspace::ImageSequencer::ref().getIntervalLength();
// double t = 1.f - remaining / openspace::ImageSequencer::ref().getIntervalLength();
// if (interval > 60) {
// if (t < 0.8)
// _fading = static_cast<float>(t);
// else if (t >= 0.95)
// _fading = _fading - 0.5f;
// }
// else
// _fading = 0.f;
// _time = futureTime;
//}
//if (_isGhost){
// futureTime = openspace::ImageSequencer::ref().getNextCaptureTime();
// double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - data.time;
// double interval = openspace::ImageSequencer::ref().getIntervalLength();
// double t = 1.f - remaining / openspace::ImageSequencer::ref().getIntervalLength();
// if (interval > 60) {
// if (t < 0.8)
// _fading = static_cast<float>(t);
// else if (t >= 0.95)
// _fading = _fading - 0.5f;
// }
// else
// _fading = 0.f;
// _time = futureTime;
//}
// set spice-orientation in accordance to timestamp
// set spice-orientation in accordance to timestamp
if (!_source.empty()) {
_stateMatrix = SpiceManager::ref().positionTransformMatrix(_source, _destination, _time);
}

View File

@@ -41,14 +41,14 @@ class ModelGeometry;
class RenderableModel : public Renderable {
public:
RenderableModel(const ghoul::Dictionary& dictionary);
RenderableModel(const ghoul::Dictionary& dictionary);
bool initialize() override;
bool deinitialize() override;
bool isReady() const override;
bool isReady() const override;
void render(const RenderData& data) override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
@@ -57,26 +57,26 @@ protected:
private:
properties::StringProperty _colorTexturePath;
properties::BoolProperty _performFade;
properties::FloatProperty _fading;
properties::BoolProperty _performFade;
properties::FloatProperty _fading;
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
std::unique_ptr<ghoul::opengl::Texture> _texture;
modelgeometry::ModelGeometry* _geometry;
modelgeometry::ModelGeometry* _geometry;
float _alpha;
glm::dmat3 _stateMatrix;
float _alpha;
glm::dmat3 _stateMatrix;
std::string _source;
std::string _destination;
std::string _target;
std::string _source;
std::string _destination;
std::string _target;
//bool _isGhost;
int _frameCount;
//bool _isGhost;
int _frameCount;
psc _sunPosition;
properties::BoolProperty _performShading;
properties::BoolProperty _performShading;
};
} // namespace openspace

View File

@@ -40,88 +40,88 @@
*/
namespace {
const std::string _loggerCat = "RenderableTrail";
//constants
const std::string keyName = "Name";
const std::string keyBody = "Body";
const std::string keyObserver = "Observer";
const std::string keyFrame = "Frame";
const std::string keyPathModule = "ModulePath";
const std::string keyColor = "RGB";
const std::string keyTimeSteps = "TimeSteps";
const std::string keyDrawLine = "DrawLine";
const std::string _loggerCat = "RenderableTrail";
//constants
const std::string keyName = "Name";
const std::string keyBody = "Body";
const std::string keyObserver = "Observer";
const std::string keyFrame = "Frame";
const std::string keyPathModule = "ModulePath";
const std::string keyColor = "RGB";
const std::string keyTimeSteps = "TimeSteps";
const std::string keyDrawLine = "DrawLine";
}
namespace openspace {
RenderablePath::RenderablePath(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _lineFade("lineFade", "Line Fade", 0.75f, 0.f, 5.f)
, _lineWidth("lineWidth", "Line Width", 2.f, 1.f, 20.f)
: Renderable(dictionary)
, _lineFade("lineFade", "Line Fade", 0.75f, 0.f, 5.f)
, _lineWidth("lineWidth", "Line Width", 2.f, 1.f, 20.f)
, _drawLine("drawline", "Draw Line", false)
, _programObject(nullptr)
, _programObject(nullptr)
, _successfullDictionaryFetch(true)
, _vaoID(0)
, _vBufferID(0)
, _needsSweep(true)
, _vaoID(0)
, _vBufferID(0)
, _needsSweep(true)
, _start(0.0)
, _stop(0.0)
{
_successfullDictionaryFetch &= dictionary.getValue(keyBody, _target);
_successfullDictionaryFetch &= dictionary.getValue(keyObserver, _observer);
_successfullDictionaryFetch &= dictionary.getValue(keyFrame, _frame);
_successfullDictionaryFetch &= dictionary.getValue(keyTimeSteps, _increment);
_successfullDictionaryFetch &= dictionary.getValue(keyBody, _target);
_successfullDictionaryFetch &= dictionary.getValue(keyObserver, _observer);
_successfullDictionaryFetch &= dictionary.getValue(keyFrame, _frame);
_successfullDictionaryFetch &= dictionary.getValue(keyTimeSteps, _increment);
glm::vec3 color(0.f);
if (dictionary.hasKeyAndValue<glm::vec3>(keyColor))
dictionary.getValue(keyColor, color);
_lineColor = color;
glm::vec3 color(0.f);
if (dictionary.hasKeyAndValue<glm::vec3>(keyColor))
dictionary.getValue(keyColor, color);
_lineColor = color;
bool drawLine = false;
if (dictionary.hasKeyAndValue<bool>(keyDrawLine))
dictionary.getValue(keyDrawLine, drawLine);
_drawLine = drawLine;
addProperty(_drawLine);
addProperty(_lineFade);
addProperty(_lineWidth);
_distanceFade = 1.0;
bool drawLine = false;
if (dictionary.hasKeyAndValue<bool>(keyDrawLine))
dictionary.getValue(keyDrawLine, drawLine);
_drawLine = drawLine;
addProperty(_drawLine);
addProperty(_lineFade);
addProperty(_lineWidth);
_distanceFade = 1.0;
}
bool RenderablePath::initialize() {
if (!_successfullDictionaryFetch) {
LERROR("The following keys need to be set in the Dictionary. Cannot initialize!");
LERROR(keyBody << ": " << _target);
LERROR(keyObserver << ": " << _observer);
LERROR(keyFrame << ": " << _frame);
return false;
}
if (!_successfullDictionaryFetch) {
LERROR("The following keys need to be set in the Dictionary. Cannot initialize!");
LERROR(keyBody << ": " << _target);
LERROR(keyObserver << ": " << _observer);
LERROR(keyFrame << ": " << _frame);
return false;
}
bool completeSuccess = true;
bool completeSuccess = true;
RenderEngine& renderEngine = OsEng.renderEngine();
_programObject = renderEngine.buildRenderProgram("PathProgram",
"${MODULE_BASE}/shaders/path_vs.glsl",
"${MODULE_BASE}/shaders/path_fs.glsl");
if (!_programObject)
return false;
if (!_programObject)
return false;
bool intervalSet = hasTimeInterval();
if (intervalSet) {
getInterval(_start, _stop);
bool intervalSet = hasTimeInterval();
if (intervalSet) {
getInterval(_start, _stop);
std::string start = SpiceManager::ref().dateFromEphemerisTime(_start);
std::string stop = SpiceManager::ref().dateFromEphemerisTime(_stop);
}
}
return completeSuccess;
return completeSuccess;
}
bool RenderablePath::deinitialize() {
glDeleteVertexArrays(1, &_vaoID);
glDeleteVertexArrays(1, &_vaoID);
_vaoID = 0;
glDeleteBuffers(1, &_vBufferID);
glDeleteBuffers(1, &_vBufferID);
_vBufferID = 0;
RenderEngine& renderEngine = OsEng.renderEngine();
@@ -130,148 +130,148 @@ bool RenderablePath::deinitialize() {
_programObject = nullptr;
}
return true;
return true;
}
bool RenderablePath::isReady() const {
return (_programObject != nullptr) && _successfullDictionaryFetch;
return (_programObject != nullptr) && _successfullDictionaryFetch;
}
void RenderablePath::render(const RenderData& data) {
double time = openspace::Time::ref().currentTime();
if (_start > time || _stop < time)
return;
double time = openspace::Time::ref().currentTime();
if (_start > time || _stop < time)
return;
//const psc& position = data.camera.position();
//const psc& origin = openspace::OpenSpaceEngine::ref().interactionHandler()->focusNode()->worldPosition();
//const PowerScaledScalar& pssl = (position - origin).length();
//double properLength = static_cast<double>(pssl.lengthf());
//const PowerScaledScalar corrected = PowerScaledScalar::CreatePSS(properLength);
//float exp = corrected[1];
//
//if (exp > 11)
// return;
_programObject->activate();
psc currentPosition = data.position;
glm::mat4 camrot = data.camera.viewRotationMatrix();
glm::mat4 transform = glm::mat4(1);
//const psc& position = data.camera.position();
//const psc& origin = openspace::OpenSpaceEngine::ref().interactionHandler()->focusNode()->worldPosition();
//const PowerScaledScalar& pssl = (position - origin).length();
//double properLength = static_cast<double>(pssl.lengthf());
//const PowerScaledScalar corrected = PowerScaledScalar::CreatePSS(properLength);
//float exp = corrected[1];
//
//if (exp > 11)
// return;
_programObject->activate();
psc currentPosition = data.position;
glm::mat4 camrot = data.camera.viewRotationMatrix();
glm::mat4 transform = glm::mat4(1);
// setup the data to the shader
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
_programObject->setUniform("color", _lineColor);
_programObject->setUniform("lastPosition", _lastPosition);
setPscUniforms(*_programObject.get(), data.camera, data.position);
// setup the data to the shader
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
_programObject->setUniform("color", _lineColor);
_programObject->setUniform("lastPosition", _lastPosition);
setPscUniforms(*_programObject.get(), data.camera, data.position);
if (_drawLine) {
glLineWidth(_lineWidth);
glBindVertexArray(_vaoID);
glDrawArrays(GL_LINE_STRIP, 0, static_cast<GLsizei>(_vertexArray.size()));
glBindVertexArray(0);
glLineWidth(1.f);
}
//float pointSize = std::min((11-exp),5.f);
//glPointSize(5);
glEnable(GL_PROGRAM_POINT_SIZE);
//GLfloat distanceParams[] = { 1.0f, 5.0f, 10.f }; //a, b, c
//GLfloat fadeThreshold[] = { 0.1f };
//
//glPointParameterf(GL_POINT_SIZE_MAX, 5.0f);
//glPointParameterf(GL_POINT_SIZE_MIN, 1.0f);
//glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, distanceParams);
////=> size = clamp(size*sqrt(1/(a+b*d+c*d^2)));
//glPointParameterfv(GL_POINT_FADE_THRESHOLD_SIZE, fadeThreshold);
if (_drawLine) {
glLineWidth(_lineWidth);
glBindVertexArray(_vaoID);
glDrawArrays(GL_LINE_STRIP, 0, static_cast<GLsizei>(_vertexArray.size()));
glBindVertexArray(0);
glLineWidth(1.f);
}
//float pointSize = std::min((11-exp),5.f);
//glPointSize(5);
glEnable(GL_PROGRAM_POINT_SIZE);
//GLfloat distanceParams[] = { 1.0f, 5.0f, 10.f }; //a, b, c
//GLfloat fadeThreshold[] = { 0.1f };
//
//glPointParameterf(GL_POINT_SIZE_MAX, 5.0f);
//glPointParameterf(GL_POINT_SIZE_MIN, 1.0f);
//glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, distanceParams);
////=> size = clamp(size*sqrt(1/(a+b*d+c*d^2)));
//glPointParameterfv(GL_POINT_FADE_THRESHOLD_SIZE, fadeThreshold);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(_vertexArray.size()));
glBindVertexArray(0);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(_vertexArray.size()));
glBindVertexArray(0);
glDisable(GL_PROGRAM_POINT_SIZE);
_programObject->deactivate();
_programObject->deactivate();
}
void RenderablePath::update(const UpdateData& data) {
if (data.isTimeJump)
_needsSweep = true;
if (data.isTimeJump)
_needsSweep = true;
if (_needsSweep) {
calculatePath(_observer);
sendToGPU();
_needsSweep = false;
}
if (_needsSweep) {
calculatePath(_observer);
sendToGPU();
_needsSweep = false;
}
if (_programObject->isDirty())
_programObject->rebuildFromFile();
if (_programObject->isDirty())
_programObject->rebuildFromFile();
}
void RenderablePath::calculatePath(std::string observer) {
double interval = (_stop - _start);
int segments = static_cast<int>(interval /_increment);
double interval = (_stop - _start);
int segments = static_cast<int>(interval /_increment);
if (segments == 0)
return;
double lightTime;
// bool correctPosition = true;
double lightTime;
// bool correctPosition = true;
double currentTime = _start;
_vertexArray.resize(segments);
double currentTime = _start;
_vertexArray.resize(segments);
psc pscPos;
//float r, g, b;
//float g = _lineColor[1];
//float b = _lineColor[2];
for (int i = 0; i < segments; i++) {
//float r, g, b;
//float g = _lineColor[1];
//float b = _lineColor[2];
for (int i = 0; i < segments; i++) {
glm::dvec3 p =
SpiceManager::ref().targetPosition(_target, observer, _frame, {}, currentTime, lightTime);
pscPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
pscPos[3] += 3;
//if (!correctPosition) {
// r = 1.f;
// g = b = 0.5f;
//}
//else if ((i % 8) == 0) {
// r = _lineColor[0];
// g = _lineColor[1];
// b = _lineColor[2];
//}
//else {
// r = g = b = 0.6f;
//}
//add position
_vertexArray[i] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
//add color for position
//_vertexArray[i + 1] = { r, g, b, a };
currentTime += _increment;
}
_lastPosition = pscPos.dvec4();
pscPos[3] += 3;
//if (!correctPosition) {
// r = 1.f;
// g = b = 0.5f;
//}
//else if ((i % 8) == 0) {
// r = _lineColor[0];
// g = _lineColor[1];
// b = _lineColor[2];
//}
//else {
// r = g = b = 0.6f;
//}
//add position
_vertexArray[i] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
//add color for position
//_vertexArray[i + 1] = { r, g, b, a };
currentTime += _increment;
}
_lastPosition = pscPos.dvec4();
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferSubData(GL_ARRAY_BUFFER, 0, _vertexArray.size() * sizeof(VertexInfo), &_vertexArray[0]);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferSubData(GL_ARRAY_BUFFER, 0, _vertexArray.size() * sizeof(VertexInfo), &_vertexArray[0]);
}
void RenderablePath::sendToGPU() {
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vertexArray.size() * sizeof(VertexInfo), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
glBufferSubData(GL_ARRAY_BUFFER, 0, _vertexArray.size() * sizeof(VertexInfo), &_vertexArray[0]);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vertexArray.size() * sizeof(VertexInfo), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
glBufferSubData(GL_ARRAY_BUFFER, 0, _vertexArray.size() * sizeof(VertexInfo), &_vertexArray[0]);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
//glEnableVertexAttribArray(1);
//glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(VertexInfo) * 2, (void*)(sizeof(VertexInfo)));
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
//glEnableVertexAttribArray(1);
//glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(VertexInfo) * 2, (void*)(sizeof(VertexInfo)));
glBindVertexArray(0);
glBindVertexArray(0);
}
} // namespace openspace

View File

@@ -32,61 +32,61 @@
#include <ghoul/opengl/ghoul_gl.h>
namespace ghoul {
namespace opengl {
class ProgramObject;
class Texture;
}
namespace opengl {
class ProgramObject;
class Texture;
}
}
namespace openspace {
class RenderablePath : public Renderable {
public:
RenderablePath(const ghoul::Dictionary& dictionary);
RenderablePath(const ghoul::Dictionary& dictionary);
bool initialize() override;
bool deinitialize() override;
bool initialize() override;
bool deinitialize() override;
bool isReady() const override;
bool isReady() const override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
void calculatePath(std::string observer);
void calculatePath(std::string observer);
private:
struct VertexInfo {
float x, y, z, e;
//float r, g, b, a;
};
void sendToGPU();
void addPosition(psc pos);
void addColor(glm::vec4 col);
struct VertexInfo {
float x, y, z, e;
//float r, g, b, a;
};
void sendToGPU();
void addPosition(psc pos);
void addColor(glm::vec4 col);
glm::vec3 _lineColor;
glm::vec4 _lastPosition;
properties::FloatProperty _lineFade;
properties::FloatProperty _lineWidth;
properties::BoolProperty _drawLine;
glm::vec3 _lineColor;
glm::vec4 _lastPosition;
properties::FloatProperty _lineFade;
properties::FloatProperty _lineWidth;
properties::BoolProperty _drawLine;
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
bool _successfullDictionaryFetch;
bool _successfullDictionaryFetch;
std::string _target;
std::string _observer;
std::string _frame;
std::string _target;
std::string _observer;
std::string _frame;
GLuint _vaoID;
GLuint _vBufferID;
bool _needsSweep;
GLuint _vaoID;
GLuint _vBufferID;
bool _needsSweep;
std::vector<VertexInfo> _vertexArray;
float _increment;
double _start;
double _stop;
float _distanceFade;
std::vector<VertexInfo> _vertexArray;
float _increment;
double _start;
double _stop;
float _distanceFade;
};
} // namespace openspace

View File

@@ -38,80 +38,80 @@
#include <ghoul/opengl/textureunit.h>
namespace {
const std::string _loggerCat = "RenderablePlane";
const std::string _loggerCat = "RenderablePlane";
const std::string keyFieldlines = "Fieldlines";
const std::string keyFilename = "File";
const std::string keyHints = "Hints";
const std::string keyShaders = "Shaders";
const std::string keyVertexShader = "VertexShader";
const std::string keyFragmentShader = "FragmentShader";
const std::string keyFieldlines = "Fieldlines";
const std::string keyFilename = "File";
const std::string keyHints = "Hints";
const std::string keyShaders = "Shaders";
const std::string keyVertexShader = "VertexShader";
const std::string keyFragmentShader = "FragmentShader";
}
namespace openspace {
RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _texturePath("texture", "Texture")
, _billboard("billboard", "Billboard", false)
, _projectionListener("projectionListener", "DisplayProjections", false)
, _size("size", "Size", glm::vec2(1,1), glm::vec2(0.f), glm::vec2(1.f, 25.f))
, _origin(Origin::Center)
, _shader(nullptr)
: Renderable(dictionary)
, _texturePath("texture", "Texture")
, _billboard("billboard", "Billboard", false)
, _projectionListener("projectionListener", "DisplayProjections", false)
, _size("size", "Size", glm::vec2(1,1), glm::vec2(0.f), glm::vec2(1.f, 25.f))
, _origin(Origin::Center)
, _shader(nullptr)
, _textureIsDirty(false)
, _texture(nullptr)
, _quad(0)
, _vertexPositionBuffer(0)
, _quad(0)
, _vertexPositionBuffer(0)
{
glm::vec2 size;
dictionary.getValue("Size", size);
dictionary.getValue("Size", size);
_size = size;
if (dictionary.hasKey("Name")){
dictionary.getValue("Name", _nodeName);
}
if (dictionary.hasKey("Name")){
dictionary.getValue("Name", _nodeName);
}
std::string origin;
if (dictionary.getValue("Origin", origin)) {
if (origin == "LowerLeft") {
_origin = Origin::LowerLeft;
}
else if (origin == "LowerRight") {
_origin = Origin::LowerRight;
}
else if (origin == "UpperLeft") {
_origin = Origin::UpperLeft;
}
else if (origin == "UpperRight") {
_origin = Origin::UpperRight;
}
else if (origin == "Center") {
_origin = Origin::Center;
}
}
std::string origin;
if (dictionary.getValue("Origin", origin)) {
if (origin == "LowerLeft") {
_origin = Origin::LowerLeft;
}
else if (origin == "LowerRight") {
_origin = Origin::LowerRight;
}
else if (origin == "UpperLeft") {
_origin = Origin::UpperLeft;
}
else if (origin == "UpperRight") {
_origin = Origin::UpperRight;
}
else if (origin == "Center") {
_origin = Origin::Center;
}
}
// Attempt to get the billboard value
bool billboard = false;
if (dictionary.getValue("Billboard", billboard)) {
_billboard = billboard;
}
if (dictionary.hasKey("ProjectionListener")){
bool projectionListener = false;
if (dictionary.getValue("ProjectionListener", projectionListener)) {
_projectionListener = projectionListener;
}
}
// Attempt to get the billboard value
bool billboard = false;
if (dictionary.getValue("Billboard", billboard)) {
_billboard = billboard;
}
if (dictionary.hasKey("ProjectionListener")){
bool projectionListener = false;
if (dictionary.getValue("ProjectionListener", projectionListener)) {
_projectionListener = projectionListener;
}
}
std::string texturePath = "";
bool success = dictionary.getValue("Texture", texturePath);
if (success) {
_texturePath = absPath(texturePath);
std::string texturePath = "";
bool success = dictionary.getValue("Texture", texturePath);
if (success) {
_texturePath = absPath(texturePath);
_textureFile = new ghoul::filesystem::File(_texturePath);
}
addProperty(_billboard);
addProperty(_texturePath);
addProperty(_texturePath);
_texturePath.onChange(std::bind(&RenderablePlane::loadTexture, this));
_textureFile->setCallback([&](const ghoul::filesystem::File&) { _textureIsDirty = true; });
@@ -119,7 +119,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
//_size.onChange(std::bind(&RenderablePlane::createPlane, this));
_size.onChange([this](){ _planeIsDirty = true; });
setBoundingSphere(_size.value());
setBoundingSphere(_size.value());
}
RenderablePlane::~RenderablePlane() {
@@ -128,12 +128,12 @@ RenderablePlane::~RenderablePlane() {
}
bool RenderablePlane::isReady() const {
bool ready = true;
if (!_shader)
ready &= false;
if(!_texture)
ready &= false;
return ready;
bool ready = true;
if (!_shader)
ready &= false;
if(!_texture)
ready &= false;
return ready;
}
bool RenderablePlane::initialize() {
@@ -141,7 +141,7 @@ bool RenderablePlane::initialize() {
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
createPlane();
if (_shader == nullptr) {
if (_shader == nullptr) {
// Plane Program
RenderEngine& renderEngine = OsEng.renderEngine();
@@ -155,21 +155,21 @@ bool RenderablePlane::initialize() {
loadTexture();
return isReady();
return isReady();
}
bool RenderablePlane::deinitialize() {
glDeleteVertexArrays(1, &_quad);
_quad = 0;
glDeleteVertexArrays(1, &_quad);
_quad = 0;
glDeleteBuffers(1, &_vertexPositionBuffer);
_vertexPositionBuffer = 0;
glDeleteBuffers(1, &_vertexPositionBuffer);
_vertexPositionBuffer = 0;
if (!_projectionListener){
// its parents job to kill texture
// iff projectionlistener
_texture = nullptr;
}
if (!_projectionListener){
// its parents job to kill texture
// iff projectionlistener
_texture = nullptr;
}
delete _textureFile;
_textureFile = nullptr;
@@ -181,42 +181,42 @@ bool RenderablePlane::deinitialize() {
_shader = nullptr;
}
return true;
return true;
}
void RenderablePlane::render(const RenderData& data) {
glm::mat4 transform = glm::mat4(1.0);
if (_billboard)
transform = glm::inverse(data.camera.viewRotationMatrix());
glm::mat4 transform = glm::mat4(1.0);
if (_billboard)
transform = glm::inverse(data.camera.viewRotationMatrix());
// Activate shader
_shader->activate();
if (_projectionListener){
//get parent node-texture and set with correct dimensions
SceneGraphNode* textureNode = OsEng.renderEngine().scene()->sceneGraphNode(_nodeName)->parent();
if (textureNode != nullptr){
RenderablePlanetProjection* t = static_cast<RenderablePlanetProjection*>(textureNode->renderable());
// Activate shader
_shader->activate();
if (_projectionListener){
//get parent node-texture and set with correct dimensions
SceneGraphNode* textureNode = OsEng.renderEngine().scene()->sceneGraphNode(_nodeName)->parent();
if (textureNode != nullptr){
RenderablePlanetProjection* t = static_cast<RenderablePlanetProjection*>(textureNode->renderable());
_texture = std::unique_ptr<ghoul::opengl::Texture>(t->baseTexture());
float h = _texture->height();
float w = _texture->width();
float scale = h / w;
transform = glm::scale(transform, glm::vec3(1.f, scale, 1.f));
}
}
float h = _texture->height();
float w = _texture->width();
float scale = h / w;
transform = glm::scale(transform, glm::vec3(1.f, scale, 1.f));
}
}
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_shader->setUniform("ModelTransform", transform);
setPscUniforms(*_shader.get(), data.camera, data.position);
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_shader->setUniform("ModelTransform", transform);
setPscUniforms(*_shader.get(), data.camera, data.position);
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
_shader->setUniform("texture1", unit);
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
_shader->setUniform("texture1", unit);
glBindVertexArray(_quad);
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(_quad);
glDrawArrays(GL_TRIANGLES, 0, 6);
_shader->deactivate();
_shader->deactivate();
}
void RenderablePlane::update(const UpdateData& data) {
@@ -233,32 +233,32 @@ void RenderablePlane::update(const UpdateData& data) {
}
void RenderablePlane::loadTexture() {
if (_texturePath.value() != "") {
if (_texturePath.value() != "") {
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath));
if (texture) {
LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'");
texture->uploadTexture();
if (texture) {
LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'");
texture->uploadTexture();
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
_texture = std::move(texture);
delete _textureFile;
_textureFile = new ghoul::filesystem::File(_texturePath);
_textureFile->setCallback([&](const ghoul::filesystem::File&) { _textureIsDirty = true; });
}
}
}
}
}
void RenderablePlane::createPlane() {
// ============================
// GEOMETRY (quad)
// GEOMETRY (quad)
// ============================
const GLfloat size = _size.value()[0];
const GLfloat w = _size.value()[1];
const GLfloat vertex_data[] = { // square of two triangles (sigh)
// x y z w s t
// x y z w s t
-size, -size, 0.0f, w, 0, 1,
size, size, 0.0f, w, 1, 0,
-size, size, 0.0f, w, 0, 0,

View File

@@ -42,46 +42,46 @@ namespace ghoul {
}
namespace openspace {
struct LinePoint;
struct LinePoint;
class RenderablePlane : public Renderable {
enum class Origin {
LowerLeft, LowerRight, UpperLeft, UpperRight, Center
};
enum class Origin {
LowerLeft, LowerRight, UpperLeft, UpperRight, Center
};
public:
RenderablePlane(const ghoul::Dictionary& dictionary);
RenderablePlane(const ghoul::Dictionary& dictionary);
~RenderablePlane();
bool initialize() override;
bool deinitialize() override;
bool initialize() override;
bool deinitialize() override;
bool isReady() const override;
bool isReady() const override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
void loadTexture();
void loadTexture();
void createPlane();
properties::StringProperty _texturePath;
properties::BoolProperty _billboard;
properties::BoolProperty _projectionListener;
properties::StringProperty _texturePath;
properties::BoolProperty _billboard;
properties::BoolProperty _projectionListener;
properties::Vec2Property _size;
Origin _origin;
std::string _nodeName;
Origin _origin;
std::string _nodeName;
bool _planeIsDirty;
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
bool _textureIsDirty;
std::unique_ptr<ghoul::opengl::Texture> _texture;
ghoul::filesystem::File* _textureFile;
GLuint _quad;
GLuint _vertexPositionBuffer;
GLuint _quad;
GLuint _vertexPositionBuffer;
};
} // namespace openspace

View File

@@ -209,7 +209,7 @@ void RenderablePlanet::render(const RenderData& data)
psc sun_pos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
// setup the data to the shader
// _programObject->setUniform("camdir", camSpaceEye);
// _programObject->setUniform("camdir", camSpaceEye);
_programObject->setUniform("transparency", _alpha);
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);

View File

@@ -52,9 +52,9 @@ public:
bool initialize() override;
bool deinitialize() override;
bool isReady() const override;
bool isReady() const override;
void render(const RenderData& data) override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
protected:
@@ -67,15 +67,15 @@ private:
std::unique_ptr<ghoul::opengl::Texture> _nightTexture;
planetgeometry::PlanetGeometry* _geometry;
properties::BoolProperty _performShading;
properties::IntProperty _rotation;
float _alpha;
properties::IntProperty _rotation;
float _alpha;
glm::dmat3 _stateMatrix;
std::string _nightTexturePath;
std::string _frame;
std::string _target;
bool _hasNightTexture;
double _time;
glm::dmat3 _stateMatrix;
std::string _nightTexturePath;
std::string _frame;
std::string _target;
bool _hasNightTexture;
double _time;
};
} // namespace openspace

View File

@@ -37,7 +37,7 @@
#include <math.h>
namespace {
const std::string _loggerCat = "RenderableSphere";
const std::string _loggerCat = "RenderableSphere";
const std::string keySize = "Size";
const std::string keySegments = "Segments";
@@ -53,15 +53,15 @@ namespace {
namespace openspace {
RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _texturePath("texture", "Texture")
: Renderable(dictionary)
, _texturePath("texture", "Texture")
, _orientation("orientation", "Orientation")
, _size("size", "Size", glm::vec2(1.f, 1.f), glm::vec2(0.f), glm::vec2(100.f))
, _segments("segments", "Segments", 8, 4, 100)
, _transparency("transparency", "Transparency", 1.f, 0.f, 1.f)
, _shader(nullptr)
, _texture(nullptr)
, _sphere(nullptr)
, _shader(nullptr)
, _texture(nullptr)
, _sphere(nullptr)
, _sphereIsDirty(false)
{
if (dictionary.hasKeyAndValue<glm::vec2>(keySize)) {
@@ -105,8 +105,8 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
addProperty(_transparency);
addProperty(_texturePath);
_texturePath.onChange(std::bind(&RenderableSphere::loadTexture, this));
addProperty(_texturePath);
_texturePath.onChange(std::bind(&RenderableSphere::loadTexture, this));
}
bool RenderableSphere::isReady() const {
@@ -128,7 +128,7 @@ bool RenderableSphere::initialize() {
loadTexture();
return isReady();
return isReady();
}
bool RenderableSphere::deinitialize() {
@@ -144,12 +144,12 @@ bool RenderableSphere::deinitialize() {
}
return true;
return true;
}
void RenderableSphere::render(const RenderData& data) {
glm::mat4 transform = glm::mat4(1.0);
glm::mat4 transform = glm::mat4(1.0);
transform = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(1, 0, 0));
@@ -159,16 +159,16 @@ void RenderableSphere::render(const RenderData& data) {
_shader->activate();
_shader->setIgnoreUniformLocationError(IgnoreError::Yes);
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_shader->setUniform("ModelTransform", transform);
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_shader->setUniform("ModelTransform", transform);
setPscUniforms(*_shader.get(), data.camera, data.position);
setPscUniforms(*_shader.get(), data.camera, data.position);
_shader->setUniform("alpha", _transparency);
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
_shader->setUniform("texture1", unit);
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
_shader->setUniform("texture1", unit);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
@@ -176,7 +176,7 @@ void RenderableSphere::render(const RenderData& data) {
_sphere->render();
_shader->setIgnoreUniformLocationError(IgnoreError::No);
_shader->deactivate();
_shader->deactivate();
}
void RenderableSphere::update(const UpdateData& data) {
@@ -192,20 +192,20 @@ void RenderableSphere::update(const UpdateData& data) {
}
void RenderableSphere::loadTexture() {
if (_texturePath.value() != "") {
if (_texturePath.value() != "") {
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(_texturePath);
if (texture) {
LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'");
texture->uploadTexture();
if (texture) {
LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'");
texture->uploadTexture();
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
// TODO: AnisotropicMipMap crashes on ATI cards ---abock
//texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
_texture = std::move(texture);
}
}
}
}
}
} // namespace openspace

View File

@@ -40,20 +40,20 @@ class PowerScaledSphere;
class RenderableSphere : public Renderable {
public:
RenderableSphere(const ghoul::Dictionary& dictionary);
RenderableSphere(const ghoul::Dictionary& dictionary);
bool initialize() override;
bool deinitialize() override;
bool initialize() override;
bool deinitialize() override;
bool isReady() const override;
bool isReady() const override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
void loadTexture();
void loadTexture();
properties::StringProperty _texturePath;
properties::StringProperty _texturePath;
properties::OptionProperty _orientation;
properties::Vec2Property _size;

View File

@@ -32,7 +32,7 @@
#include <math.h>
namespace {
const std::string _loggerCat = "RenderableSphericalGrid";
const std::string _loggerCat = "RenderableSphericalGrid";
const std::string KeyGridType = "GridType";
const std::string KeyGridColor = "GridColor";
const std::string KeyGridMatrix = "GridMatrix";
@@ -53,179 +53,179 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
, _iBufferID(0)
, _mode(GL_LINES)
{
_gridMatrix = glm::mat4(1);
dictionary.getValue(KeyGridType, _gridType);
dictionary.getValue(KeyGridColor, _gridColor);
_gridMatrix = glm::mat4(1);
dictionary.getValue(KeyGridType, _gridType);
dictionary.getValue(KeyGridColor, _gridColor);
staticGrid = dictionary.getValue(KeyGridMatrix, _gridMatrix);
if (!staticGrid){
staticGrid = dictionary.getValue(KeyGridParentsRotation, _parentsRotation);
}
dictionary.getValue(KeyGridSegments, _segments);
staticGrid = dictionary.getValue(KeyGridMatrix, _gridMatrix);
if (!staticGrid){
staticGrid = dictionary.getValue(KeyGridParentsRotation, _parentsRotation);
}
dictionary.getValue(KeyGridSegments, _segments);
/*glm::vec2 radius;
dictionary.getValue(constants::renderablesphericalgrid::gridRadius, radius);
*/
/*glm::vec2 radius;
dictionary.getValue(constants::renderablesphericalgrid::gridRadius, radius);
*/
_isize = int(6 * _segments * _segments);
_vsize = int((_segments + 1) * (_segments + 1));
_varray = new Vertex[_vsize];
_iarray = new int[_isize];
_isize = int(6 * _segments * _segments);
_vsize = int((_segments + 1) * (_segments + 1));
_varray = new Vertex[_vsize];
_iarray = new int[_isize];
static_assert(sizeof(Vertex) == 64, "The size of the Vertex needs to be 64 for performance");
static_assert(sizeof(Vertex) == 64, "The size of the Vertex needs to be 64 for performance");
int nr = 0;
const float fsegments = static_cast<float>(_segments);
const float r = static_cast<float>(radius[0]);
int nr = 0;
const float fsegments = static_cast<float>(_segments);
const float r = static_cast<float>(radius[0]);
//int nr2 = 0;
//int nr2 = 0;
for (int i = 0; i <= _segments; i++) {
// define an extra vertex around the y-axis due to texture mapping
for (int j = 0; j <= _segments; j++) {
const float fi = static_cast<float>(i);
const float fj = static_cast<float>(j);
for (int i = 0; i <= _segments; i++) {
// define an extra vertex around the y-axis due to texture mapping
for (int j = 0; j <= _segments; j++) {
const float fi = static_cast<float>(i);
const float fj = static_cast<float>(j);
// inclination angle (north to south)
const float theta = fi * float(M_PI) / fsegments*2.f; // 0 -> PI
// inclination angle (north to south)
const float theta = fi * float(M_PI) / fsegments*2.f; // 0 -> PI
// azimuth angle (east to west)
const float phi = fj * float(M_PI) * 2.0f / fsegments; // 0 -> 2*PI
// azimuth angle (east to west)
const float phi = fj * float(M_PI) * 2.0f / fsegments; // 0 -> 2*PI
const float x = r * sin(phi) * sin(theta); //
const float y = r * cos(theta); // up
const float z = r * cos(phi) * sin(theta); //
glm::vec3 normal = glm::vec3(x, y, z);
if (!(x == 0.f && y == 0.f && z == 0.f))
normal = glm::normalize(normal);
const float x = r * sin(phi) * sin(theta); //
const float y = r * cos(theta); // up
const float z = r * cos(phi) * sin(theta); //
glm::vec3 normal = glm::vec3(x, y, z);
if (!(x == 0.f && y == 0.f && z == 0.f))
normal = glm::normalize(normal);
//const float t1 = fj / fsegments;
const float t2 = fi / fsegments;
//const float t1 = fj / fsegments;
const float t2 = fi / fsegments;
// tex coord. not used, use to manip color
if (round(y) == 0.0f) _varray[nr].tex[0] = -2;
_varray[nr].tex[1] = t2;
// tex coord. not used, use to manip color
if (round(y) == 0.0f) _varray[nr].tex[0] = -2;
_varray[nr].tex[1] = t2;
glm::vec4 tmp(x, y, z, 1);
glm::mat4 rot = glm::rotate(glm::mat4(1), static_cast<float>(M_PI_2), glm::vec3(1, 0, 0));
tmp = _gridMatrix*rot*tmp;
for (int i = 0; i < 3; i++){
_varray[nr].location[i] = tmp[i];
_varray[nr].normal[i] = normal[i];
}
_varray[nr].location[3] = static_cast<GLfloat>(radius[1]);
++nr;
}
}
nr = 0;
// define indices for all triangles
for (int i = 1; i <= _segments; ++i) {
for (int j = 0; j < _segments; ++j) {
const int t = _segments + 1;
_iarray[nr] = t * (i - 1) + j + 0; ++nr;
_iarray[nr] = t * (i + 0) + j + 0; ++nr;
_iarray[nr] = t * (i + 0) + j + 1; ++nr;
_iarray[nr] = t * (i - 1) + j + 1; ++nr;
_iarray[nr] = t * (i - 1) + j + 0; ++nr;
}
}
glm::vec4 tmp(x, y, z, 1);
glm::mat4 rot = glm::rotate(glm::mat4(1), static_cast<float>(M_PI_2), glm::vec3(1, 0, 0));
tmp = _gridMatrix*rot*tmp;
for (int i = 0; i < 3; i++){
_varray[nr].location[i] = tmp[i];
_varray[nr].normal[i] = normal[i];
}
_varray[nr].location[3] = static_cast<GLfloat>(radius[1]);
++nr;
}
}
nr = 0;
// define indices for all triangles
for (int i = 1; i <= _segments; ++i) {
for (int j = 0; j < _segments; ++j) {
const int t = _segments + 1;
_iarray[nr] = t * (i - 1) + j + 0; ++nr;
_iarray[nr] = t * (i + 0) + j + 0; ++nr;
_iarray[nr] = t * (i + 0) + j + 1; ++nr;
_iarray[nr] = t * (i - 1) + j + 1; ++nr;
_iarray[nr] = t * (i - 1) + j + 0; ++nr;
}
}
}
RenderableSphericalGrid::~RenderableSphericalGrid(){
deinitialize();
deinitialize();
// Delete not done in deinitialize because new is done in constructor
delete[] _varray;
delete[] _iarray;
// Delete not done in deinitialize because new is done in constructor
delete[] _varray;
delete[] _iarray;
}
bool RenderableSphericalGrid::isReady() const {
bool ready = true;
ready &= (_gridProgram != nullptr);
return ready;
bool ready = true;
ready &= (_gridProgram != nullptr);
return ready;
}
bool RenderableSphericalGrid::deinitialize(){
glDeleteVertexArrays(1,&_vaoID);
_vaoID = 0;
glDeleteVertexArrays(1,&_vaoID);
_vaoID = 0;
glDeleteBuffers(1,&_vBufferID);
_vBufferID = 0;
glDeleteBuffers(1,&_vBufferID);
_vBufferID = 0;
glDeleteBuffers(1,&_iBufferID);
_iBufferID = 0;
glDeleteBuffers(1,&_iBufferID);
_iBufferID = 0;
return true;
return true;
}
bool RenderableSphericalGrid::initialize(){
bool completeSuccess = true;
if (_gridProgram == nullptr)
completeSuccess &= OsEng.ref().configurationManager().getValue("GridProgram", _gridProgram);
bool completeSuccess = true;
if (_gridProgram == nullptr)
completeSuccess &= OsEng.ref().configurationManager().getValue("GridProgram", _gridProgram);
// Initialize and upload to graphics card
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glGenBuffers(1, &_iBufferID);
// Initialize and upload to graphics card
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glGenBuffers(1, &_iBufferID);
// First VAO setup
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(Vertex), _varray, GL_STATIC_DRAW);
// First VAO setup
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(Vertex), _varray, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, location)));
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, tex)));
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, location)));
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, tex)));
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
glBindVertexArray(0);
glBindVertexArray(0);
return completeSuccess;
return completeSuccess;
}
void RenderableSphericalGrid::render(const RenderData& data){
_gridProgram->activate();
_gridProgram->activate();
glm::mat4 transform;
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
transform[i][j] = static_cast<float>(_parentMatrix[i][j]);
}
}
glm::mat4 transform;
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
transform[i][j] = static_cast<float>(_parentMatrix[i][j]);
}
}
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
// setup the data to the shader
_gridProgram->setIgnoreUniformLocationError(IgnoreError::Yes);
_gridProgram->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_gridProgram->setUniform("ModelTransform", transform);
setPscUniforms(*_gridProgram, data.camera, data.position);
_gridProgram->setUniform("gridColor", _gridColor);
// setup the data to the shader
_gridProgram->setIgnoreUniformLocationError(IgnoreError::Yes);
_gridProgram->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_gridProgram->setUniform("ModelTransform", transform);
setPscUniforms(*_gridProgram, data.camera, data.position);
_gridProgram->setUniform("gridColor", _gridColor);
glLineWidth(0.5f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glLineWidth(0.5f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glBindVertexArray(_vaoID); // select first VAO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glDrawElements(_mode, _isize, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
glBindVertexArray(_vaoID); // select first VAO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glDrawElements(_mode, _isize, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
_gridProgram->deactivate();
_gridProgram->deactivate();
}
void RenderableSphericalGrid::update(const UpdateData& data) {

View File

@@ -38,46 +38,46 @@
namespace openspace {
class RenderableSphericalGrid : public Renderable{
public:
RenderableSphericalGrid(const ghoul::Dictionary& dictionary);
~RenderableSphericalGrid();
RenderableSphericalGrid(const ghoul::Dictionary& dictionary);
~RenderableSphericalGrid();
bool initialize() override;
bool deinitialize() override;
bool initialize() override;
bool deinitialize() override;
bool isReady() const override;
bool isReady() const override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
protected:
typedef struct {
GLfloat location[4];
GLfloat tex[2];
GLfloat normal[3];
GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase
} Vertex;
typedef struct {
GLfloat location[4];
GLfloat tex[2];
GLfloat normal[3];
GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase
} Vertex;
ghoul::opengl::ProgramObject* _gridProgram;
std::string _gridType;
glm::vec4 _gridColor;
glm::mat4 _gridMatrix;
int _segments;
ghoul::opengl::ProgramObject* _gridProgram;
std::string _gridType;
glm::vec4 _gridColor;
glm::mat4 _gridMatrix;
int _segments;
bool staticGrid;
std::string _parentsRotation;
glm::dmat3 _parentMatrix;
PowerScaledScalar _radius;
bool staticGrid;
std::string _parentsRotation;
glm::dmat3 _parentMatrix;
PowerScaledScalar _radius;
GLuint _vaoID = 3;
GLuint _vBufferID = 4;
GLuint _iBufferID = 5;
GLuint _vaoID = 3;
GLuint _vBufferID = 4;
GLuint _iBufferID = 5;
GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
Vertex* _varray;
int* _iarray;
GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
Vertex* _varray;
int* _iarray;
};
}// namespace openspace
#endif

View File

@@ -309,7 +309,7 @@ void RenderableStars::update(const UpdateData& data) {
glBindVertexArray(0);
_dataIsDirty = false;
}
}
if (_pointSpreadFunctionTextureIsDirty) {
LDEBUG("Reloading Point Spread Function texture");

View File

@@ -45,7 +45,7 @@
namespace {
const std::string _loggerCat = "RenderableTrail";
//constants
const std::string keyName = "Name";
const std::string keyName = "Name";
const std::string keyBody = "Body";
const std::string keyObserver = "Observer";
const std::string keyFrame = "Frame";
@@ -54,7 +54,7 @@ namespace {
const std::string keyTropicalOrbitPeriod = "TropicalOrbitPeriod";
const std::string keyEarthOrbitRatio = "EarthOrbitRatio";
const std::string keyDayLength = "DayLength";
const std::string keyStamps = "TimeStamps";
const std::string keyStamps = "TimeStamps";
}
namespace openspace {
@@ -86,11 +86,11 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
dictionary.getValue(keyColor, color);
_lineColor = color;
bool timeStamps = false;
if (dictionary.hasKeyAndValue<bool>(keyStamps))
dictionary.getValue(keyStamps, timeStamps);
_showTimestamps = timeStamps;
addProperty(_showTimestamps);
bool timeStamps = false;
if (dictionary.hasKeyAndValue<bool>(keyStamps))
dictionary.getValue(keyStamps, timeStamps);
_showTimestamps = timeStamps;
addProperty(_showTimestamps);
_lineColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_lineColor);
@@ -98,7 +98,7 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
addProperty(_lineFade);
addProperty(_lineWidth);
_distanceFade = 1.0;
_distanceFade = 1.0;
}
bool RenderableTrail::initialize() {
@@ -160,20 +160,20 @@ void RenderableTrail::render(const RenderData& data) {
_programObject->setUniform("color", _lineColor);
_programObject->setUniform("nVertices", static_cast<unsigned int>(_vertexArray.size()));
_programObject->setUniform("lineFade", _lineFade);
_programObject->setUniform("forceFade", _distanceFade);
_programObject->setUniform("forceFade", _distanceFade);
//const psc& position = data.camera.position();
//const psc& origin = openspace::OpenSpaceEngine::ref().interactionHandler()->focusNode()->worldPosition();
//const PowerScaledScalar& pssl = (position - origin).length();
//
//if (pssl[0] < 0.000001){
// if (_distanceFade > 0.0f) _distanceFade -= 0.05f;
// _programObject->setUniform("forceFade", _distanceFade);
//}
//else{
// if (_distanceFade < 1.0f) _distanceFade += 0.05f;
// _programObject->setUniform("forceFade", _distanceFade);
//}
//const psc& position = data.camera.position();
//const psc& origin = openspace::OpenSpaceEngine::ref().interactionHandler()->focusNode()->worldPosition();
//const PowerScaledScalar& pssl = (position - origin).length();
//
//if (pssl[0] < 0.000001){
// if (_distanceFade > 0.0f) _distanceFade -= 0.05f;
// _programObject->setUniform("forceFade", _distanceFade);
//}
//else{
// if (_distanceFade < 1.0f) _distanceFade += 0.05f;
// _programObject->setUniform("forceFade", _distanceFade);
//}
glLineWidth(_lineWidth);
@@ -183,18 +183,18 @@ void RenderableTrail::render(const RenderData& data) {
glLineWidth(1.f);
if (_showTimestamps){
glPointSize(5.f);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(_vertexArray.size()));
glBindVertexArray(0);
}
if (_showTimestamps){
glPointSize(5.f);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(_vertexArray.size()));
glBindVertexArray(0);
}
_programObject->deactivate();
}
void RenderableTrail::update(const UpdateData& data) {
if (data.isTimeJump)
if (data.isTimeJump)
_needsSweep = true;
if (_needsSweep) {
@@ -206,12 +206,12 @@ void RenderableTrail::update(const UpdateData& data) {
double lightTime = 0.0;
bool intervalSet = hasTimeInterval();
double start = DBL_MIN;
double end = DBL_MAX;
if (intervalSet) {
getInterval(start, end);
}
bool intervalSet = hasTimeInterval();
double start = DBL_MIN;
double end = DBL_MAX;
if (intervalSet) {
getInterval(start, end);
}
// Points in the vertex array should always have a fixed distance. For this reason we
// keep the first entry in the array floating and always pointing to the current date
@@ -222,11 +222,11 @@ void RenderableTrail::update(const UpdateData& data) {
glm::dvec3 p;
// Update the floating current time
if (start > data.time)
if (start > data.time)
p = SpiceManager::ref().targetPosition(_target, _observer, _frame, {}, start, lightTime);
else if (end < data.time)
else if (end < data.time)
p = SpiceManager::ref().targetPosition(_target, _observer, _frame, {}, end, lightTime);
else
else
p = SpiceManager::ref().targetPosition(_target, _observer, _frame, {}, data.time, lightTime);
psc pscPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
@@ -246,14 +246,14 @@ void RenderableTrail::update(const UpdateData& data) {
for (int i = nValues; i > 0; --i) {
double et = _oldTime + i * _increment;
if (start > et)
et = start;
else if (end < et)
et = end;
if (start > et)
et = start;
else if (end < et)
et = end;
glm::dvec3 p =
SpiceManager::ref().targetPosition(_target, _observer, _frame, {}, et, lightTime);
pscPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
pscPos[3] += 3;
pscPos[3] += 3;
_vertexArray[i] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
}
@@ -281,12 +281,12 @@ void RenderableTrail::fullYearSweep(double time) {
float planetYear = SecondsPerEarthYear * _ratio;
int segments = static_cast<int>(_tropic);
bool intervalSet = hasTimeInterval();
double start = DBL_MIN;
double end = DBL_MAX;
if (intervalSet) {
intervalSet &= getInterval(start, end);
}
bool intervalSet = hasTimeInterval();
double start = DBL_MIN;
double end = DBL_MAX;
if (intervalSet) {
intervalSet &= getInterval(start, end);
}
_increment = planetYear / _tropic;
@@ -296,12 +296,12 @@ void RenderableTrail::fullYearSweep(double time) {
glm::dvec3 p;
bool failed = false;
for (int i = 0; i < segments+2; i++) {
if (start > time && intervalSet) {
time = start;
}
else if (end < time && intervalSet) {
time = end;
}
if (start > time && intervalSet) {
time = start;
}
else if (end < time && intervalSet) {
time = end;
}
if (!failed || intervalSet) {
try {
@@ -317,7 +317,7 @@ void RenderableTrail::fullYearSweep(double time) {
}
psc pscPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
pscPos[3] += 3;
pscPos[3] += 3;
_vertexArray[i] = {pscPos[0], pscPos[1], pscPos[2], pscPos[3]};
time -= _increment;

View File

@@ -63,7 +63,7 @@ private:
properties::Vec3Property _lineColor;
properties::FloatProperty _lineFade;
properties::FloatProperty _lineWidth;
properties::BoolProperty _showTimestamps;
properties::BoolProperty _showTimestamps;
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
@@ -86,7 +86,7 @@ private:
float _increment;
double _oldTime = 0.0;
float _distanceFade;
float _distanceFade;
};
} // namespace openspace

View File

@@ -33,46 +33,46 @@
namespace openspace {
ScreenSpaceFramebuffer::ScreenSpaceFramebuffer()
:ScreenSpaceRenderable()
,_size("size", "Size", glm::vec4(0), glm::vec4(0), glm::vec4(2000))
,_framebuffer(nullptr)
:ScreenSpaceRenderable()
,_size("size", "Size", glm::vec4(0), glm::vec4(0), glm::vec4(2000))
,_framebuffer(nullptr)
{
_id = id();
setName("ScreenSpaceFramebuffer" + std::to_string(_id));
registerProperties();
_id = id();
setName("ScreenSpaceFramebuffer" + std::to_string(_id));
registerProperties();
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
addProperty(_size);
OsEng.gui()._screenSpaceProperty.registerProperty(&_size);
_size.set(glm::vec4(0, 0, resolution.x,resolution.y));
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
addProperty(_size);
OsEng.gui()._screenSpaceProperty.registerProperty(&_size);
_size.set(glm::vec4(0, 0, resolution.x,resolution.y));
_scale.setValue(1.0f);
_scale.setValue(1.0f);
}
ScreenSpaceFramebuffer::~ScreenSpaceFramebuffer(){}
bool ScreenSpaceFramebuffer::initialize(){
_originalViewportSize = OsEng.windowWrapper().currentWindowResolution();
_originalViewportSize = OsEng.windowWrapper().currentWindowResolution();
createPlane();
createShaders();
createFragmentbuffer();
createPlane();
createShaders();
createFragmentbuffer();
return isReady();
return isReady();
}
bool ScreenSpaceFramebuffer::deinitialize(){
unregisterProperties();
unregisterProperties();
glDeleteVertexArrays(1, &_quad);
_quad = 0;
glDeleteVertexArrays(1, &_quad);
_quad = 0;
glDeleteBuffers(1, &_vertexPositionBuffer);
_vertexPositionBuffer = 0;
glDeleteBuffers(1, &_vertexPositionBuffer);
_vertexPositionBuffer = 0;
_texture = nullptr;
_texture = nullptr;
RenderEngine& renderEngine = OsEng.renderEngine();
RenderEngine& renderEngine = OsEng.renderEngine();
if (_shader) {
renderEngine.removeRenderProgram(_shader);
_shader = nullptr;
@@ -81,78 +81,78 @@ bool ScreenSpaceFramebuffer::deinitialize(){
_framebuffer->detachAll();
removeAllRenderFunctions();
return true;
return true;
}
void ScreenSpaceFramebuffer::render(){
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
glm::vec4 size = _size.value();
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
glm::vec4 size = _size.value();
float xratio = _originalViewportSize.x / (size.z-size.x);
float yratio = _originalViewportSize.y / (size.w-size.y);;
float xratio = _originalViewportSize.x / (size.z-size.x);
float yratio = _originalViewportSize.y / (size.w-size.y);;
if(!_renderFunctions.empty()){
glViewport (-size.x*xratio, -size.y*yratio, _originalViewportSize.x*xratio, _originalViewportSize.y*yratio);
GLint defaultFBO = _framebuffer->getActiveObject();
_framebuffer->activate();
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_ALPHA_TEST);
for(auto renderFunction : _renderFunctions){
(*renderFunction)();
}
_framebuffer->deactivate();
if(!_renderFunctions.empty()){
glViewport (-size.x*xratio, -size.y*yratio, _originalViewportSize.x*xratio, _originalViewportSize.y*yratio);
GLint defaultFBO = _framebuffer->getActiveObject();
_framebuffer->activate();
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_ALPHA_TEST);
for(auto renderFunction : _renderFunctions){
(*renderFunction)();
}
_framebuffer->deactivate();
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glViewport (0, 0, resolution.x, resolution.y);
glm::mat4 rotation = rotationMatrix();
glm::mat4 translation = translationMatrix();
glm::mat4 scale = scaleMatrix();
scale = glm::scale(scale, glm::vec3((1.0/xratio), -(1.0/yratio), 1.0f));
glm::mat4 modelTransform = rotation*translation*scale;
draw(modelTransform);
}
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glViewport (0, 0, resolution.x, resolution.y);
glm::mat4 rotation = rotationMatrix();
glm::mat4 translation = translationMatrix();
glm::mat4 scale = scaleMatrix();
scale = glm::scale(scale, glm::vec3((1.0/xratio), -(1.0/yratio), 1.0f));
glm::mat4 modelTransform = rotation*translation*scale;
draw(modelTransform);
}
}
void ScreenSpaceFramebuffer::update(){}
bool ScreenSpaceFramebuffer::isReady() const{
bool ready = true;
if (!_shader)
ready &= false;
if(!_texture)
ready &= false;
return ready;
bool ready = true;
if (!_shader)
ready &= false;
if(!_texture)
ready &= false;
return ready;
}
void ScreenSpaceFramebuffer::setSize(glm::vec4 size){
_size.set(size);
_size.set(size);
}
void ScreenSpaceFramebuffer::addRenderFunction(std::shared_ptr<std::function<void()>> renderFunction){
_renderFunctions.push_back(renderFunction);
_renderFunctions.push_back(renderFunction);
}
void ScreenSpaceFramebuffer::removeAllRenderFunctions(){
_renderFunctions.clear();
_renderFunctions.clear();
}
void ScreenSpaceFramebuffer::createFragmentbuffer(){
_framebuffer = std::make_unique<ghoul::opengl::FramebufferObject>();
_framebuffer->activate();
_texture = std::make_unique<ghoul::opengl::Texture>(glm::uvec3(_originalViewportSize.x, _originalViewportSize.y, 1));
_texture->uploadTexture();
_texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
_framebuffer->attachTexture(_texture.get(), GL_COLOR_ATTACHMENT0);
_framebuffer->deactivate();
_framebuffer = std::make_unique<ghoul::opengl::FramebufferObject>();
_framebuffer->activate();
_texture = std::make_unique<ghoul::opengl::Texture>(glm::uvec3(_originalViewportSize.x, _originalViewportSize.y, 1));
_texture->uploadTexture();
_texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
_framebuffer->attachTexture(_texture.get(), GL_COLOR_ATTACHMENT0);
_framebuffer->deactivate();
}
int ScreenSpaceFramebuffer::id(){
static int id = 0;
return id++;
static int id = 0;
return id++;
}
} //namespace openspace

View File

@@ -38,29 +38,29 @@ namespace openspace {
*/
class ScreenSpaceFramebuffer : public ScreenSpaceRenderable {
public:
ScreenSpaceFramebuffer();
~ScreenSpaceFramebuffer();
ScreenSpaceFramebuffer();
~ScreenSpaceFramebuffer();
bool initialize() override;
bool deinitialize() override;
void render() override;
void update() override;
bool isReady() const override;
bool initialize() override;
bool deinitialize() override;
void render() override;
void update() override;
bool isReady() const override;
void setSize(glm::vec4);
void addRenderFunction(std::shared_ptr<std::function<void()>> renderFunction);
void removeAllRenderFunctions();
void setSize(glm::vec4);
void addRenderFunction(std::shared_ptr<std::function<void()>> renderFunction);
void removeAllRenderFunctions();
private:
void createFragmentbuffer();
static int id();
void createFragmentbuffer();
static int id();
properties::Vec4Property _size;
properties::Vec4Property _size;
std::unique_ptr<ghoul::opengl::FramebufferObject> _framebuffer;
std::vector<std::shared_ptr<std::function<void()>>> _renderFunctions;
std::unique_ptr<ghoul::opengl::FramebufferObject> _framebuffer;
std::vector<std::shared_ptr<std::function<void()>>> _renderFunctions;
int _id;
int _id;
};
} //namespace openspace

View File

@@ -26,65 +26,65 @@
#include <ghoul/filesystem/filesystem>
namespace {
const std::string _loggerCat = "ScreenSpaceImage";
const std::string _loggerCat = "ScreenSpaceImage";
}
namespace openspace {
ScreenSpaceImage::ScreenSpaceImage(std::string texturePath)
:ScreenSpaceRenderable()
,_texturePath("texturePath", "Texture path", texturePath)
:ScreenSpaceRenderable()
,_texturePath("texturePath", "Texture path", texturePath)
{
_id = id();
setName("ScreenSpaceImage" + std::to_string(_id));
registerProperties();
_id = id();
setName("ScreenSpaceImage" + std::to_string(_id));
registerProperties();
addProperty(_texturePath);
OsEng.gui()._screenSpaceProperty.registerProperty(&_texturePath);
_texturePath.onChange([this](){ loadTexture(); });
addProperty(_texturePath);
OsEng.gui()._screenSpaceProperty.registerProperty(&_texturePath);
_texturePath.onChange([this](){ loadTexture(); });
}
ScreenSpaceImage::~ScreenSpaceImage(){}
bool ScreenSpaceImage::initialize(){
_originalViewportSize = OsEng.windowWrapper().currentWindowResolution();
_originalViewportSize = OsEng.windowWrapper().currentWindowResolution();
createPlane();
createShaders();
loadTexture();
createPlane();
createShaders();
loadTexture();
return isReady();
return isReady();
}
bool ScreenSpaceImage::deinitialize(){
unregisterProperties();
unregisterProperties();
glDeleteVertexArrays(1, &_quad);
_quad = 0;
glDeleteVertexArrays(1, &_quad);
_quad = 0;
glDeleteBuffers(1, &_vertexPositionBuffer);
_vertexPositionBuffer = 0;
glDeleteBuffers(1, &_vertexPositionBuffer);
_vertexPositionBuffer = 0;
_texturePath = "";
_texture = nullptr;
_texturePath = "";
_texture = nullptr;
RenderEngine& renderEngine = OsEng.renderEngine();
if (_shader) {
renderEngine.removeRenderProgram(_shader);
_shader = nullptr;
}
RenderEngine& renderEngine = OsEng.renderEngine();
if (_shader) {
renderEngine.removeRenderProgram(_shader);
_shader = nullptr;
}
return true;
return true;
}
void ScreenSpaceImage::render(){
glm::mat4 rotation = rotationMatrix();
glm::mat4 translation = translationMatrix();
glm::mat4 scale = scaleMatrix();
glm::mat4 modelTransform = rotation*translation*scale;
glm::mat4 rotation = rotationMatrix();
glm::mat4 translation = translationMatrix();
glm::mat4 scale = scaleMatrix();
glm::mat4 modelTransform = rotation*translation*scale;
draw(modelTransform);
draw(modelTransform);
}
@@ -92,31 +92,31 @@ void ScreenSpaceImage::update(){}
bool ScreenSpaceImage::isReady() const{
bool ready = true;
if (!_shader)
ready &= false;
if(!_texture)
ready &= false;
return ready;
bool ready = true;
if (!_shader)
ready &= false;
if(!_texture)
ready &= false;
return ready;
}
void ScreenSpaceImage::loadTexture() {
if (_texturePath.value() != "") {
if (_texturePath.value() != "") {
std::unique_ptr<ghoul::opengl::Texture> texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath.value()));
if (texture) {
LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'");
texture->uploadTexture();
if (texture) {
LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'");
texture->uploadTexture();
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
_texture = std::move(texture);
}
}
}
}
}
int ScreenSpaceImage::id(){
static int id = 0;
return id++;
static int id = 0;
return id++;
}
}

View File

@@ -38,21 +38,21 @@ namespace openspace {
class ScreenSpaceImage : public ScreenSpaceRenderable {
public:
ScreenSpaceImage(std::string texturePath);
~ScreenSpaceImage();
ScreenSpaceImage(std::string texturePath);
~ScreenSpaceImage();
bool initialize() override;
bool deinitialize() override;
void render() override;
void update() override;
bool isReady() const override;
bool initialize() override;
bool deinitialize() override;
void render() override;
void update() override;
bool isReady() const override;
private:
void loadTexture();
static int id();
properties::StringProperty _texturePath;
int _id;
void loadTexture();
static int id();
properties::StringProperty _texturePath;
int _id;
};
} //namespace openspace

View File

@@ -43,45 +43,45 @@ namespace planetgeometry {
SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
: PlanetGeometry()
, _realRadius("radius", "Radius", glm::vec4(1.f, 1.f, 1.f, 0.f), glm::vec4(-10.f, -10.f, -10.f, -20.f),
glm::vec4(10.f, 10.f, 10.f, 20.f))
, _realRadius("radius", "Radius", glm::vec4(1.f, 1.f, 1.f, 0.f), glm::vec4(-10.f, -10.f, -10.f, -20.f),
glm::vec4(10.f, 10.f, 10.f, 20.f))
, _segments("segments", "Segments", 20, 1, 50)
, _sphere(nullptr)
{
using constants::simplespheregeometry::keyRadius;
using constants::simplespheregeometry::keySegments;
using constants::simplespheregeometry::keyRadius;
using constants::simplespheregeometry::keySegments;
// The name is passed down from the SceneGraphNode
// The name is passed down from the SceneGraphNode
bool success = dictionary.getValue(SceneGraphNode::KeyName, _name);
assert(success);
glm::vec4 radius;
success = dictionary.getValue(keyRadius, _modRadius);
if (!success) {
LERROR("SimpleSphereGeometry of '" << _name << "' did not provide a key '"
assert(success);
glm::vec4 radius;
success = dictionary.getValue(keyRadius, _modRadius);
if (!success) {
LERROR("SimpleSphereGeometry of '" << _name << "' did not provide a key '"
<< keyRadius << "'");
}
else {
radius[0] = _modRadius[0];
radius[1] = _modRadius[0];
radius[2] = _modRadius[0];
radius[3] = _modRadius[1];
_realRadius = radius; // In case the kernels does not supply a real
}
}
else {
radius[0] = _modRadius[0];
radius[1] = _modRadius[0];
radius[2] = _modRadius[0];
radius[3] = _modRadius[1];
_realRadius = radius; // In case the kernels does not supply a real
}
double segments;
success = dictionary.getValue(keySegments, segments);
if (!success) {
LERROR("SimpleSphereGeometry of '" << _name << "' did not provide a key '"
if (!success) {
LERROR("SimpleSphereGeometry of '" << _name << "' did not provide a key '"
<< keySegments << "'");
}
else
_segments = static_cast<int>(segments);
}
else
_segments = static_cast<int>(segments);
// The shader need the radii values but they are not changeable runtime
// TODO: Possibly add a scaling property @AA
// The shader need the radii values but they are not changeable runtime
// TODO: Possibly add a scaling property @AA
addProperty(_realRadius);
// Changing the radius/scaling should affect the shader but not the geometry? @AA
// Changing the radius/scaling should affect the shader but not the geometry? @AA
//_radius.onChange(std::bind(&SimpleSphereGeometry::createSphere, this));
addProperty(_segments);
_segments.onChange(std::bind(&SimpleSphereGeometry::createSphere, this));
@@ -100,8 +100,8 @@ bool SimpleSphereGeometry::initialize(RenderablePlanet* parent)
void SimpleSphereGeometry::deinitialize()
{
if (_sphere)
delete _sphere;
if (_sphere)
delete _sphere;
_sphere = nullptr;
}
@@ -118,8 +118,8 @@ void SimpleSphereGeometry::createSphere(){
if(_sphere)
delete _sphere;
//_sphere = new PowerScaledSphere(planetSize, _segments);
_sphere = new PowerScaledSphere(_realRadius, _segments, _name);
//_sphere = new PowerScaledSphere(planetSize, _segments);
_sphere = new PowerScaledSphere(_realRadius, _segments, _name);
_sphere->initialize();
}

View File

@@ -45,15 +45,15 @@ public:
bool initialize(RenderablePlanet* parent) override;
void deinitialize() override;
void render() override;
PowerScaledSphere* _planet;
PowerScaledSphere* _planet;
private:
void createSphere();
glm::vec2 _modRadius;
properties::Vec4Property _realRadius;
glm::vec2 _modRadius;
properties::Vec4Property _realRadius;
properties::IntProperty _segments;
std::string _name;
std::string _name;
PowerScaledSphere* _sphere;
};

View File

@@ -37,21 +37,21 @@ namespace modelgeometry {
WavefrontGeometry::WavefrontGeometry(const ghoul::Dictionary& dictionary)
: ModelGeometry(dictionary)
{
loadObj(_file);
loadObj(_file);
}
bool WavefrontGeometry::initialize(Renderable* parent) {
bool success = ModelGeometry::initialize(parent);
bool success = ModelGeometry::initialize(parent);
return success;
}
void WavefrontGeometry::deinitialize() {
ModelGeometry::deinitialize();
ModelGeometry::deinitialize();
}
bool WavefrontGeometry::loadModel(const std::string& filename) {
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string err;
bool success = tinyobj::LoadObj(shapes, materials, err, filename.c_str(), filename.c_str());
@@ -86,18 +86,18 @@ bool WavefrontGeometry::loadModel(const std::string& filename) {
// The _shapeCounts array stores for each shape, how many vertices that shape has
size_t currentPosition = 0;
size_t p = 0;
psc tmp;
for (int i = 0; i < shapes.size(); ++i) {
for (int j = 0; j < shapes[i].mesh.positions.size() / 3; ++j) {
tmp = PowerScaledCoordinate::CreatePowerScaledCoordinate(shapes[i].mesh.positions[3 * j + 0],
shapes[i].mesh.positions[3 * j + 1],
shapes[i].mesh.positions[3 * j + 2]
);
psc tmp;
for (int i = 0; i < shapes.size(); ++i) {
for (int j = 0; j < shapes[i].mesh.positions.size() / 3; ++j) {
tmp = PowerScaledCoordinate::CreatePowerScaledCoordinate(shapes[i].mesh.positions[3 * j + 0],
shapes[i].mesh.positions[3 * j + 1],
shapes[i].mesh.positions[3 * j + 2]
);
_vertices[j + currentPosition].location[0] = tmp[0];
_vertices[j + currentPosition].location[1] = tmp[1];
_vertices[j + currentPosition].location[2] = tmp[2];
_vertices[j + currentPosition].location[3] = tmp[3];
_vertices[j + currentPosition].location[0] = tmp[0];
_vertices[j + currentPosition].location[1] = tmp[1];
_vertices[j + currentPosition].location[2] = tmp[2];
_vertices[j + currentPosition].location[3] = tmp[3];
_vertices[j + currentPosition].normal[0] = shapes[i].mesh.normals[3 * j + 0];
_vertices[j + currentPosition].normal[1] = shapes[i].mesh.normals[3 * j + 1];
@@ -107,7 +107,7 @@ bool WavefrontGeometry::loadModel(const std::string& filename) {
_vertices[j + currentPosition].tex[0] = shapes[i].mesh.texcoords[2 * j + 0];
_vertices[j + currentPosition].tex[1] = shapes[i].mesh.texcoords[2 * j + 1];
}
}
currentPosition += shapes[i].mesh.positions.size() / 3;
@@ -119,7 +119,7 @@ bool WavefrontGeometry::loadModel(const std::string& filename) {
p += shapes[i].mesh.indices.size();
}
return true;
return true;
}

View File

@@ -34,16 +34,16 @@ class RenderableModelProjection;
namespace modelgeometry {
class WavefrontGeometry : public ModelGeometry {
public:
WavefrontGeometry(const ghoul::Dictionary& dictionary);
class WavefrontGeometry : public ModelGeometry {
public:
WavefrontGeometry(const ghoul::Dictionary& dictionary);
bool initialize(Renderable* parent) override;
void deinitialize() override;
bool initialize(Renderable* parent) override;
void deinitialize() override;
private:
bool loadModel(const std::string& filename);
};
private:
bool loadModel(const std::string& filename);
};
} // namespace modelgeometry
} // namespace openspace

View File

@@ -33,8 +33,8 @@ in vec4 vs_position;
Fragment getFragment()
{
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 position = vs_position;
float depth = pscDepth(position);
Fragment frag;
frag.color = vec4(1.0, 0.0, 0.0, 1.0);

View File

@@ -35,11 +35,11 @@ out vec4 vs_position;
#include "PowerScaling/powerScaling_vs.hglsl"
void main() {
vec4 tmp = vec4(in_position, exponent);
vs_position = tmp;
vec4 tmp = vec4(in_position, exponent);
vs_position = tmp;
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}

View File

@@ -40,12 +40,12 @@ uniform float lineFade;
#include "PowerScaling/powerScaling_vs.hglsl"
void main() {
float id = float(gl_VertexID) / float(nVertices * lineFade);
fade = 1.0 - id;
float id = float(gl_VertexID) / float(nVertices * lineFade);
fade = 1.0 - id;
vec4 tmp = in_point_position;
vec4 position = pscTransform(tmp, ModelTransform);
vs_point_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
vec4 tmp = in_point_position;
vec4 position = pscTransform(tmp, ModelTransform);
vs_point_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}

View File

@@ -33,14 +33,14 @@ in vec4 vs_position;
Fragment getFragment()
{
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 diffuse;
if (gl_FrontFacing)
diffuse = texture(texture1, vs_st);
else {
diffuse = vec4(0.8);
}
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 diffuse;
if (gl_FrontFacing)
diffuse = texture(texture1, vs_st);
else {
diffuse = vec4(0.8);
}
Fragment frag;
frag.color = diffuse;

View File

@@ -38,12 +38,12 @@ out float s;
void main()
{
vec4 tmp = in_position;
vec4 position = pscTransform(tmp, ModelTransform);
vec4 tmp = in_position;
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
vs_st = in_st;
position = ViewProjection * position;
gl_Position = z_normalization(position);
vs_position = tmp;
vs_st = in_st;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}

View File

@@ -45,40 +45,40 @@ in vec4 vs_position;
#include "fragment.glsl"
Fragment getFragment() {
vec4 position = vs_position;
float depth = pscDepth(position);
//depth = length(campos - position);
vec4 diffuse = texture(texture1, vs_st);
vec4 position = vs_position;
float depth = pscDepth(position);
//depth = length(campos - position);
vec4 diffuse = texture(texture1, vs_st);
diffuse[3] = fading;
diffuse[3] = fading;
if (_performShading) {
vec4 spec = vec4(0.0);
vec3 n = normalize(vs_normal.xyz);
vec3 l_pos = vec3(sun_pos); // sun.
vec3 l_dir = normalize(l_pos-objpos.xyz);
float intensity = min(max(1*dot(n,l_dir), 0.0), 1);
float shine = 100;
vec4 specular = vec4(1.0);
vec4 ambient =diffuse*0.4;
ambient[3] = transparency;
if(intensity > 0.0f){
// halfway vector
vec3 h = normalize(l_dir + normalize(cam_dir));
// specular factor
float intSpec = max(dot(n,h),0.0);
spec = specular * pow(intSpec, shine);
}
diffuse = vec4(max(intensity * diffuse , ambient).xyz,1) +spec*1.5*diffuse ;
}
if (_performShading) {
vec4 spec = vec4(0.0);
vec3 n = normalize(vs_normal.xyz);
vec3 l_pos = vec3(sun_pos); // sun.
vec3 l_dir = normalize(l_pos-objpos.xyz);
float intensity = min(max(1*dot(n,l_dir), 0.0), 1);
float shine = 100;
vec4 specular = vec4(1.0);
vec4 ambient =diffuse*0.4;
ambient[3] = transparency;
if(intensity > 0.0f){
// halfway vector
vec3 h = normalize(l_dir + normalize(cam_dir));
// specular factor
float intSpec = max(dot(n,h),0.0);
spec = specular * pow(intSpec, shine);
}
diffuse = vec4(max(intensity * diffuse , ambient).xyz,1) +spec*1.5*diffuse ;
}
diffuse[3] = fading*transparency;
diffuse[3] = fading*transparency;
Fragment frag;
frag.color = diffuse;
frag.depth = depth;
return frag;
Fragment frag;
frag.color = diffuse;
frag.depth = depth;
return frag;
}

View File

@@ -42,20 +42,20 @@ out float s;
#include "PowerScaling/powerScaling_vs.hglsl"
void main() {
vec4 pos = in_position;
pos.w += _magnification;
vec4 pos = in_position;
pos.w += _magnification;
// set variables
vs_st = in_st;
//vs_stp = in_position.xyz;
vs_position = pos;
vec4 tmp = pos;
// set variables
vs_st = in_st;
//vs_stp = in_position.xyz;
vs_position = pos;
vec4 tmp = pos;
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}

View File

@@ -34,8 +34,8 @@ uniform vec3 color;
Fragment getFragment() {
vec4 position = vs_point_position;
float depth = pscDepth(position);
vec4 diffuse = vs_point_color;
vec4 diffuse = vs_point_color;
Fragment frag;
frag.color = diffuse;

View File

@@ -58,11 +58,11 @@ uniform mat4 projection;
void main() {
gs_point_color = vs_point_color[0];
gs_point_position = vs_point_position[0];
//gs_point_position = gl_in[0].gl_Position;
if (isHour[0] == 1) {
/*vec4 projPos[4];
gs_point_color = vs_point_color[0];
gs_point_position = vs_point_position[0];
//gs_point_position = gl_in[0].gl_Position;
if (isHour[0] == 1) {
/*vec4 projPos[4];
for (int i = 0; i < 4; ++i) {
vec4 p1 = gl_in[0].gl_Position;
p1.xy += vec2(99999999*(corners[i] - vec2(0.5)));
@@ -82,26 +82,26 @@ void main() {
// return;
for(int i = 0; i < 4; i++) {
gs_point_position = gl_in[0].gl_Position;
gs_point_position = gl_in[0].gl_Position;
gl_Position = projPos[i];
// billboardSize = sizeInPixels;
EmitVertex();
EmitVertex();
}
for(int i = 0; i < 4; i++) {
for(int i = 0; i < 4; i++) {
gl_Position = gl_in[0].gl_Position;;
// billboardSize = sizeInPixels;
}*/
gl_Position = gl_in[0].gl_Position;
EmitVertex();
EndPrimitive();
}
else {
gl_Position = gl_in[0].gl_Position;
EmitVertex();
EndPrimitive();
return;
}
}*/
gl_Position = gl_in[0].gl_Position;
EmitVertex();
EndPrimitive();
}
else {
gl_Position = gl_in[0].gl_Position;
EmitVertex();
EndPrimitive();
return;
}
}

View File

@@ -32,22 +32,22 @@ in vec4 vs_position;
#include "fragment.glsl"
Fragment getFragment() {
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 diffuse;
if(gl_FrontFacing)
diffuse = texture(texture1, vs_st);
else
diffuse = texture(texture1, vec2(1-vs_st.s,vs_st.t));
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 diffuse;
if(gl_FrontFacing)
diffuse = texture(texture1, vs_st);
else
diffuse = texture(texture1, vec2(1-vs_st.s,vs_st.t));
//vec4 diffuse = vec4(1,vs_st,1);
//vec4 diffuse = vec4(1,0,0,1);
// if(position.w > 9.0) {
// diffuse = vec4(1,0,0,1);
// }
//vec4 diffuse = vec4(1,vs_st,1);
//vec4 diffuse = vec4(1,0,0,1);
// if(position.w > 9.0) {
// diffuse = vec4(1,0,0,1);
// }
if (diffuse.a == 0.0)
discard;
if (diffuse.a == 0.0)
discard;
Fragment frag;
frag.color = diffuse;

View File

@@ -38,12 +38,12 @@ out float s;
void main()
{
vec4 tmp = in_position;
vec4 position = pscTransform(tmp, ModelTransform);
vec4 tmp = in_position;
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
vs_st = in_st;
position = ViewProjection * position;
gl_Position = z_normalization(position);
vs_position = tmp;
vs_st = in_st;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}

View File

@@ -35,16 +35,16 @@ in vec4 vs_position;
Fragment getFragment(){
Fragment frag;
Fragment frag;
// power scale coordinates for depth. w value is set to 1.0.
float depth = (1.0 + log(abs(OcclusionDepth) + 1/pow(k, 1.0))/log(k)) / 27.0;
frag.color = texture(texture1, vec2(vs_st.s, 1-vs_st.t));
frag.color.a = (frag.color.a != 0.0f) ? Alpha : frag.color.a;
if(frag.color.a == 0.0f){
discard;
}
frag.depth = denormalizeFloat(depth);
// power scale coordinates for depth. w value is set to 1.0.
float depth = (1.0 + log(abs(OcclusionDepth) + 1/pow(k, 1.0))/log(k)) / 27.0;
frag.color = texture(texture1, vec2(vs_st.s, 1-vs_st.t));
frag.color.a = (frag.color.a != 0.0f) ? Alpha : frag.color.a;
if(frag.color.a == 0.0f){
discard;
}
frag.depth = denormalizeFloat(depth);
return frag;
return frag;
}

View File

@@ -35,7 +35,7 @@ out vec2 vs_st;
out vec4 vs_position;
void main(){
vs_st = in_st;
vs_position = ViewProjectionMatrix*ModelTransform*in_position;
gl_Position = vec4(vs_position);
vs_st = in_st;
vs_position = ViewProjectionMatrix*ModelTransform*in_position;
gl_Position = vec4(vs_position);
}

Some files were not shown because too many files have changed in this diff Show More