diff --git a/.gitignore b/.gitignore
index 7a0cc5fa00..aca64bfb7d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,8 +27,5 @@ html/
latex/
shaders/ABuffer/constants.hglsl
*.OpenSpaceGenerated.glsl
-shaders/writeToTexture_fs.glsl
-shaders/writeToTexture_vs.glsl
-src/rendering/planets/writeToTexture.cpp
LuaScripting.txt
-
+log.html
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bf554d97e8..7f8dc30076 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,7 +26,7 @@
#########################################################################################
# General Settings
#########################################################################################
-
+
cmake_minimum_required (VERSION 2.8)
project (OpenSpace)
@@ -46,7 +46,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OPENSPACE_LIBRARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OPENSPACE_BINARY_DIR})
-#include(cotire)
+include(cotire)
# Make sure a build type is set. Default is Debug.
if(NOT CMAKE_BUILD_TYPE)
diff --git a/config/sgct/single.xml b/config/sgct/single.xml
index 9609397b43..6ae96d20cf 100644
--- a/config/sgct/single.xml
+++ b/config/sgct/single.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/include/openspace/abuffer/abufferSingleLinked.h b/include/openspace/abuffer/abufferSingleLinked.h
index 248b856a6a..ab171c3c4f 100644
--- a/include/openspace/abuffer/abufferSingleLinked.h
+++ b/include/openspace/abuffer/abufferSingleLinked.h
@@ -47,17 +47,11 @@ protected:
virtual bool reinitializeInternal();
private:
-
- GLuint *_data;
GLuint _anchorPointerTexture;
GLuint _anchorPointerTextureInitializer;
GLuint _atomicCounterBuffer;
GLuint _fragmentBuffer;
GLuint _fragmentTexture;
-
-
-
-
}; // ABufferSingleLinked
} // openspace
diff --git a/include/openspace/engine/gui.h b/include/openspace/engine/gui.h
index 4ee66e318d..36363c42a3 100644
--- a/include/openspace/engine/gui.h
+++ b/include/openspace/engine/gui.h
@@ -93,6 +93,7 @@ private:
std::set _vec3Properties;
std::set _stringProperties;
std::set _optionProperty;
+ std::set _selectionProperty;
std::set _triggerProperty;
std::map> _propertiesByOwner;
diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h
index 1bdfbaf05c..a0b38eb422 100644
--- a/include/openspace/engine/openspaceengine.h
+++ b/include/openspace/engine/openspaceengine.h
@@ -80,7 +80,7 @@ public:
private:
OpenSpaceEngine(std::string programName);
- ~OpenSpaceEngine() = default;
+ ~OpenSpaceEngine();
void clearAllWindows();
bool gatherCommandlineArguments();
diff --git a/include/openspace/properties/property.h b/include/openspace/properties/property.h
index 46828d13df..f14ab44e2e 100644
--- a/include/openspace/properties/property.h
+++ b/include/openspace/properties/property.h
@@ -200,6 +200,20 @@ public:
*/
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 { and
+ * } 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: Identifier, Name, Type. 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,
@@ -274,6 +288,43 @@ public:
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;
+
+ /**
+ * Creates the information that is general to every Property and adds the
+ * Identifier, Name, Type, and
+ * MetaData 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 MetaData 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:
+ * return { generateBaseDescription(), generateMetaDataDescription(),
+ * generateAdditionalDescription()}, 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.
diff --git a/include/openspace/properties/selectionproperty.h b/include/openspace/properties/selectionproperty.h
index 59f2f6eb17..86b20298cb 100644
--- a/include/openspace/properties/selectionproperty.h
+++ b/include/openspace/properties/selectionproperty.h
@@ -46,7 +46,7 @@ public:
void addOption(Option option);
const std::vector& options() const;
- void setValue(std::vector value) override;
+ //void setValue(std::vector value) override;
private:
/// The list of options which have been registered with this OptionProperty
diff --git a/include/openspace/properties/templateproperty.h b/include/openspace/properties/templateproperty.h
index 926bcefa35..ade144b939 100644
--- a/include/openspace/properties/templateproperty.h
+++ b/include/openspace/properties/templateproperty.h
@@ -127,6 +127,13 @@ public:
/// \see Property::typeLua
int typeLua() const 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 T. It makes assignments such as
diff --git a/include/openspace/properties/templateproperty.inl b/include/openspace/properties/templateproperty.inl
index 5459d644ef..a999a151b8 100644
--- a/include/openspace/properties/templateproperty.inl
+++ b/include/openspace/properties/templateproperty.inl
@@ -126,6 +126,11 @@ std::string TemplateProperty::className() const {
return PropertyDelegate>::className();
}
+//template
+//std::string TemplateProperty::description() {
+// return
+//}
+
template
TemplateProperty::operator T() {
return _value;
diff --git a/include/openspace/rendering/model/wavefrontgeometry.h b/include/openspace/rendering/model/wavefrontgeometry.h
index 1a13d8030c..c22c0fc248 100644
--- a/include/openspace/rendering/model/wavefrontgeometry.h
+++ b/include/openspace/rendering/model/wavefrontgeometry.h
@@ -47,6 +47,7 @@ public:
GLfloat location[4];
GLfloat tex[2];
GLfloat normal[3];
+ GLfloat padding[7];
//GLubyte padding[4]; // Pads the struct out to 64 bytes for performance increase
} Vertex;
@@ -60,7 +61,6 @@ private:
GLuint _vBufferID = 7;
GLuint _iBufferID = 8;
- GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
Vertex* _varray;
diff --git a/include/openspace/rendering/planets/renderableplanet.h b/include/openspace/rendering/planets/renderableplanet.h
index 2ad096fdc2..a725337cbd 100644
--- a/include/openspace/rendering/planets/renderableplanet.h
+++ b/include/openspace/rendering/planets/renderableplanet.h
@@ -32,8 +32,12 @@
#include
// ghoul includes
-#include
-#include
+namespace ghoul {
+ namespace opengl {
+ class ProgramObject;
+ class Texture;
+ }
+}
namespace openspace {
diff --git a/include/openspace/rendering/planets/simplespheregeometry.h b/include/openspace/rendering/planets/simplespheregeometry.h
index e1a4f1e4cd..2bbc012261 100644
--- a/include/openspace/rendering/planets/simplespheregeometry.h
+++ b/include/openspace/rendering/planets/simplespheregeometry.h
@@ -28,11 +28,11 @@
#include
#include
#include
-#include
namespace openspace {
class RenderablePlanet;
+class PowerScaledSphere;
namespace planetgeometry {
diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h
index e56f8745dc..b19c501490 100644
--- a/include/openspace/rendering/renderable.h
+++ b/include/openspace/rendering/renderable.h
@@ -28,22 +28,25 @@
// openspace
#include
#include
-#include
#include
-#include
-
-// ghoul
-#include
// Forward declare to minimize dependencies
namespace ghoul {
namespace opengl {
class ProgramObject;
+ class Texture;
}
+ class Dictionary;
}
namespace openspace {
+// Forward declare to minimize dependencies
+struct RenderData;
+struct UpdateData;
+class Camera;
+class PowerScaledCoordinate;
+
class Renderable : public properties::PropertyOwner {
public:
static Renderable* createFromDictionary(const ghoul::Dictionary& dictionary);
@@ -68,7 +71,7 @@ public:
protected:
std::string findPath(const std::string& path);
- void setPscUniforms(ghoul::opengl::ProgramObject* program, const Camera* camera, const psc& position);
+ void setPscUniforms(ghoul::opengl::ProgramObject* program, const Camera* camera, const PowerScaledCoordinate& position);
private:
properties::BoolProperty _enabled;
diff --git a/include/openspace/rendering/renderableephemeris.h b/include/openspace/rendering/renderableephemeris.h
deleted file mode 100644
index d3cde1477a..0000000000
--- a/include/openspace/rendering/renderableephemeris.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*****************************************************************************************
-* *
-* OpenSpace *
-* *
-* Copyright (c) 2014 *
-* *
-* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
-* software and associated documentation files (the "Software"), to deal in the Software *
-* without restriction, including without limitation the rights to use, copy, modify, *
-* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
-* permit persons to whom the Software is furnished to do so, subject to the following *
-* conditions: *
-* *
-* The above copyright notice and this permission notice shall be included in all copies *
-* or substantial portions of the Software. *
-* *
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
-* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
-* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
-* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
-* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
-* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
-****************************************************************************************/
-
-#ifndef __RENDERABLEEPHEMERIS_H__
-#define __RENDERABLEEPHEMERIS_H__
-
-// open space includes
-#include
-
-#include
-
-// ghoul includes
-#include
-#include
-//#include
-
-namespace openspace {
-class RenderableEphemeris : public Renderable{
-public:
- RenderableEphemeris(const ghoul::Dictionary& dictionary);
- ~RenderableEphemeris();
-
- bool initialize() override;
- bool deinitialize() override;
-
- bool isReady() const override;
-
- void render(const RenderData& data) override;
- void update(const UpdateData& data) override;
- private:
- properties::StringProperty _colorTexturePath; // not used now, will be later though.
-
- ghoul::opengl::ProgramObject* _programObject;
- ghoul::opengl::Texture* _texture;
- void loadTexture();
-
- typedef struct {
- GLfloat location[4];
- GLfloat velocity[4];
- GLubyte padding[32]; // Pads the struct out to 64 bytes for performance increase
- } Vertex;
-
- GLuint _vaoID = 6;
- GLuint _vBufferID = 7;
- GLuint _iBufferID = 8;
-
- void nextIndex();
-
-
- GLenum _mode;
- unsigned int _isize;
- unsigned int _vsize;
-
- Vertex* _varray;
- int* _iarray;
-
- //Vertex* batchArray;
- bool* _updated;
-
- psc _pscpos, _pscvel;
-
- std::vector> _intervals;
- double _increment;
- // etc...
- int _index[2];
- int _prev[2];
- int _delta;
- double _time = 0;
- double _previousTime = 0;
-};
-}
-#endif
\ No newline at end of file
diff --git a/include/openspace/rendering/renderablefieldlines.h b/include/openspace/rendering/renderablefieldlines.h
index 580ae96d74..eb6a4cb1fd 100644
--- a/include/openspace/rendering/renderablefieldlines.h
+++ b/include/openspace/rendering/renderablefieldlines.h
@@ -55,6 +55,7 @@ private:
ghoul::opengl::ProgramObject* _shader;
GLuint _fieldlineVAO;
+ GLuint _vertexPositionBuffer;
std::vector _lineStart;
std::vector _lineCount;
diff --git a/include/openspace/rendering/renderablefov.h b/include/openspace/rendering/renderablefov.h
index 0b30db6e5d..15f1a48f9d 100644
--- a/include/openspace/rendering/renderablefov.h
+++ b/include/openspace/rendering/renderablefov.h
@@ -22,19 +22,14 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
-#ifndef __RenderableFov_H__
-#define __RenderableFov_H__
+#ifndef __RENDERABLEFOV_H__
+#define __RENDERABLEFOV_H__
// open space includes
#include
-
#include
-#include
-
-// ghoul includes
-#include
-#include
-//#include
+#include
+#include
namespace openspace {
class RenderableFov : public Renderable{
@@ -53,123 +48,54 @@ public:
properties::StringProperty _colorTexturePath;
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::Texture* _texture;
- openspace::SceneGraphNode* _targetNode;
-
void loadTexture();
- void allocateData();
- void insertPoint(std::vector& arr, psc& p, glm::vec4& c);
- void fovProjection(bool H[], std::vector bounds);
-
- psc orthogonalProjection(glm::dvec3 camvec);
- psc checkForIntercept(glm::dvec3 ray);
- psc pscInterpolate(psc p0, psc p1, float t);
- psc sphericalInterpolate(glm::dvec3 p0, glm::dvec3 p1, float t);
-
- glm::dvec3 interpolate(glm::dvec3 p0, glm::dvec3 p1, float t);
- glm::dvec3 bisection(glm::dvec3 p1, glm::dvec3 p2, double tolerance);
-
- double distanceBetweenPoints(psc p1, psc p2);
- // instance variables
- int _nrInserted = 0;
- int _isteps;
- bool _rebuild = false;
- bool _interceptTag[5];
- bool _withinFOV;
- psc _projectionBounds[4];
- psc _interceptVector;
+ void fullYearSweep();
+ // modfile reads
// spice
- std::string _spacecraft;
+ std::string _target;
std::string _observer;
std::string _frame;
- std::string _instrumentID;
- std::string _method;
- std::string _aberrationCorrection;
- std::string _fovTarget;
-
- glm::dvec3 ipoint, ivec;
- glm::dvec3 _previousHalf;
+ // color
glm::vec3 _c;
double _r, _g, _b;
+ // orbit relational data
+ double _tropic;
+ double _ratio;
+ double _day;
- // GPU stuff
- GLuint _vaoID[2] ;
- GLuint _vboID[2] ;
- GLuint _iboID[2];
- GLenum _mode;
- unsigned int _isize[2];
- unsigned int _vsize[2];
- unsigned int _vtotal[2];
- unsigned int _stride[2];
- std::vector _varray1;
- std::vector _varray2;
- int* _iarray1[2];
+ // need to write robust method for vbo id selection
+ // (right now galactic grid has to be present) (why though?) solve later...
+ GLuint _vaoID ;
+ GLuint _vBufferID ;
+ GLuint _iBufferID;
void updateData();
void sendToGPU();
glm::dmat3 _stateMatrix;
- // time
+ unsigned int _isize;
+ unsigned int _vsize;
+ unsigned int _vtotal;
+ unsigned int _stride;
+
+ double _startTrail;
+
+ //Vertex* _varray;
+ std::vector _varray;
+ std::vector _iarray;
+
+ bool _once = false;
+
+ //used for update of trail
+ psc _pscpos, _pscvel;
+ double _increment;
double _time = 0;
double _oldTime = 0;
+
int _delta = 0;
+ int _dtprogress = 0;
};
}
-#endif
-// Scrap stuff i need to keep for now (michal)
-
-
-/* // idk how we will compute the aberrated state.
-double RenderableFov::computeTargetLocalTime(PowerScaledScalar d){
-double c = 299792456.075; // m/s
-double dt = ( (d[0]*pow(10, d[1])) / c );
-double t_local = _time - dt*86400;
-
-std::string localTime;
-std::string currentTime;
-
-openspace::SpiceManager::ref().getDateFromET(t_local, localTime);
-openspace::SpiceManager::ref().getDateFromET(_time , currentTime);
-
-std::cout << "time at jupiter : " << localTime << "\time at NH" << currentTime << std::endl;
-return t_local;
-}*/
-
-/*
-psc RenderableFov::sphericalInterpolate(glm::dvec3 p0, glm::dvec3 p1, float t){
-double targetEt, lt;
-glm::dvec3 ip, iv;
-psc targetPos;
-SpiceManager::ref().getTargetPosition("JUPITER", _spacecraft, _frame, _aberrationCorrection, _time, targetPos, lt);
-
-openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
-_frame, _method, _aberrationCorrection, _time, targetEt, p0, ip, iv);
-psc psc0 = PowerScaledCoordinate::CreatePowerScaledCoordinate(iv[0], iv[1], iv[2]);
-openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
-_frame, _method, _aberrationCorrection, _time, targetEt, p1, ip, iv);
-psc psc1 = PowerScaledCoordinate::CreatePowerScaledCoordinate(iv[0], iv[1], iv[2]);
-psc0[3] += 3;
-psc1[3] += 3;
-
-psc0 -= targetPos;
-psc1 -= targetPos;
-
-double angle = psc0.angle(psc1);
-
-std::cout << angle << std::endl;
-
-double sin_a = sin(angle); // opt
-double l[2] = { sin((1.f - t)*angle) / sin_a, sin((t)*angle) / sin_a };
-
-std::cout << l[0] << " " << l[1] << std::endl;
-
-float s = ((t-1)*psc0[3] + (t)*psc1[3]);
-float x = (l[0]*psc0[0] + l[1]*psc1[0]);
-float y = (l[0]*psc0[1] + l[1]*psc1[1]);
-float z = (l[0]*psc0[2] + l[1]*psc1[2]);
-
-psc interpolated = PowerScaledCoordinate::PowerScaledCoordinate(x, y, z, 10);
-return interpolated;
-}
-*/
+#endif
\ No newline at end of file
diff --git a/include/openspace/rendering/renderablepath.h b/include/openspace/rendering/renderablepath.h
index 3dd6febb53..b116f0f40a 100644
--- a/include/openspace/rendering/renderablepath.h
+++ b/include/openspace/rendering/renderablepath.h
@@ -29,6 +29,7 @@
#include
#include
+#include
// ghoul includes
#include
@@ -49,11 +50,9 @@ namespace openspace {
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
- properties::StringProperty _colorTexturePath;
ghoul::opengl::ProgramObject* _programObject;
- ghoul::opengl::Texture* _texture;
void loadTexture();
- void fullYearSweep();
+ bool fullYearSweep();
// modfile reads
// spice
@@ -72,7 +71,6 @@ namespace openspace {
void nextIndex();
- GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
unsigned int _vtotal;
@@ -80,7 +78,7 @@ namespace openspace {
//Vertex* _varray;
std::vector _varray;
- int* _iarray;
+ std::vector _iarray;
//used for update of trail
psc _pscpos, _pscvel;
diff --git a/include/openspace/rendering/renderableplane.h b/include/openspace/rendering/renderableplane.h
index 52bc9356a2..4b90b9577a 100644
--- a/include/openspace/rendering/renderableplane.h
+++ b/include/openspace/rendering/renderableplane.h
@@ -67,6 +67,7 @@ private:
ghoul::opengl::ProgramObject* _shader;
ghoul::opengl::Texture* _texture;
GLuint _quad;
+ GLuint _vertexPositionBuffer;
};
} // namespace openspace
diff --git a/include/openspace/rendering/renderabletrail.h b/include/openspace/rendering/renderabletrail.h
index aa399d229f..201ba32539 100644
--- a/include/openspace/rendering/renderabletrail.h
+++ b/include/openspace/rendering/renderabletrail.h
@@ -27,8 +27,8 @@
// open space includes
#include
-
#include
+#include
// ghoul includes
#include
@@ -55,6 +55,8 @@ public:
void loadTexture();
void fullYearSweep();
+ bool _successfullDictionaryFetch;
+
// modfile reads
// spice
std::string _target;
@@ -87,7 +89,7 @@ public:
//Vertex* _varray;
std::vector _varray;
- int* _iarray;
+ std::vector _iarray;
//bool _once = false;
double lightTime;
diff --git a/include/openspace/rendering/renderablevolume.h b/include/openspace/rendering/renderablevolume.h
index f72bab9cfb..4e1839c938 100644
--- a/include/openspace/rendering/renderablevolume.h
+++ b/include/openspace/rendering/renderablevolume.h
@@ -22,8 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
-#ifndef RENDERABLEVOLUME_H
-#define RENDERABLEVOLUME_H
+#ifndef __RENDERABLEVOLUME_H__
+#define __RENDERABLEVOLUME_H__
// open space includes
#include
diff --git a/include/openspace/rendering/renderablevolumegl.h b/include/openspace/rendering/renderablevolumegl.h
index df7cb2673a..3b15c18edc 100644
--- a/include/openspace/rendering/renderablevolumegl.h
+++ b/include/openspace/rendering/renderablevolumegl.h
@@ -70,12 +70,12 @@ private:
ghoul::opengl::Texture* _volume;
ghoul::opengl::Texture* _transferFunction;
- GLuint _boxArray;
+ GLuint _boxArray;
+ GLuint _vertexPositionBuffer;
ghoul::opengl::ProgramObject *_boxProgram;
glm::vec3 _boxScaling;
psc _pscOffset;
float _w;
- GLint _MVPLocation, _modelTransformLocation, _typeLocation;
bool _updateTransferfunction;
int _id;
diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h
index 10cce4f07a..366a83548f 100644
--- a/include/openspace/rendering/renderengine.h
+++ b/include/openspace/rendering/renderengine.h
@@ -65,6 +65,8 @@ public:
void takeScreenshot();
void toggleVisualizeABuffer(bool b);
+ void toggleInfoText(bool b);
+
void setPerformanceMeasurements(bool performanceMeasurements);
bool doesPerformanceMeasurements() const;
diff --git a/include/openspace/rendering/stars/renderableconstellationbounds.h b/include/openspace/rendering/stars/renderableconstellationbounds.h
index 1735e627f8..d82d5425ee 100644
--- a/include/openspace/rendering/stars/renderableconstellationbounds.h
+++ b/include/openspace/rendering/stars/renderableconstellationbounds.h
@@ -53,6 +53,7 @@ namespace openspace {
class RenderableConstellationBounds : public Renderable {
public:
RenderableConstellationBounds(const ghoul::Dictionary& dictionary);
+ ~RenderableConstellationBounds();
bool initialize() override;
bool deinitialize() override;
diff --git a/include/openspace/rendering/stars/renderablestars.h b/include/openspace/rendering/stars/renderablestars.h
index 87f027bf46..c94ce523b4 100644
--- a/include/openspace/rendering/stars/renderablestars.h
+++ b/include/openspace/rendering/stars/renderablestars.h
@@ -35,8 +35,9 @@
namespace openspace {
class RenderableStars : public Renderable {
-public:
+public:
RenderableStars(const ghoul::Dictionary& dictionary);
+ ~RenderableStars();
bool initialize() override;
bool deinitialize() override;
diff --git a/include/openspace/scenegraph/scenegraph.h b/include/openspace/scenegraph/scenegraph.h
index b111b048f9..a2419bdca8 100644
--- a/include/openspace/scenegraph/scenegraph.h
+++ b/include/openspace/scenegraph/scenegraph.h
@@ -122,6 +122,21 @@ private:
std::mutex _programUpdateLock;
std::set _programsToUpdate;
std::vector _programs;
+
+ typedef std::map NodeMap;
+ typedef std::multimap DependencyMap;
+ typedef std::vector LoadedList;
+
+ struct LoadMaps {
+ NodeMap nodes;
+ DependencyMap dependencies;
+ LoadedList loadedNodes;
+ };
+
+ void loadModules(const std::string& directory, const ghoul::Dictionary& dictionary);
+ void loadModule(LoadMaps& m,const std::string& modulePath);
+ void loadNodes(const std::string& parentName, LoadMaps& m);
+ void loadNode(const ghoul::Dictionary& dictionary);
};
} // namespace openspace
diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h
index 6a5c687d73..71d3765c3a 100644
--- a/include/openspace/scripting/scriptengine.h
+++ b/include/openspace/scripting/scriptengine.h
@@ -50,8 +50,9 @@ public:
bool operator<(const LuaLibrary& rhs) const;
};
-
+
ScriptEngine();
+ ~ScriptEngine();
bool initialize();
void deinitialize();
diff --git a/include/openspace/util/powerscaledsphere.h b/include/openspace/util/powerscaledsphere.h
index cf17f8ef19..a89ea773e5 100644
--- a/include/openspace/util/powerscaledsphere.h
+++ b/include/openspace/util/powerscaledsphere.h
@@ -30,7 +30,6 @@
#include
#include
-
namespace openspace {
class PowerScaledSphere {
@@ -56,7 +55,6 @@ private:
GLuint _vBufferID;
GLuint _iBufferID;
- GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
Vertex* _varray;
diff --git a/shaders/constellationbounds_fs.glsl b/shaders/modules/constellationbounds/constellationbounds_fs.glsl
similarity index 100%
rename from shaders/constellationbounds_fs.glsl
rename to shaders/modules/constellationbounds/constellationbounds_fs.glsl
diff --git a/shaders/constellationbounds_vs.glsl b/shaders/modules/constellationbounds/constellationbounds_vs.glsl
similarity index 100%
rename from shaders/constellationbounds_vs.glsl
rename to shaders/modules/constellationbounds/constellationbounds_vs.glsl
diff --git a/shaders/star_fs.glsl b/shaders/modules/stars/star_fs.glsl
similarity index 100%
rename from shaders/star_fs.glsl
rename to shaders/modules/stars/star_fs.glsl
diff --git a/shaders/star_ge.glsl b/shaders/modules/stars/star_ge.glsl
similarity index 100%
rename from shaders/star_ge.glsl
rename to shaders/modules/stars/star_ge.glsl
diff --git a/shaders/star_vs.glsl b/shaders/modules/stars/star_vs.glsl
similarity index 100%
rename from shaders/star_vs.glsl
rename to shaders/modules/stars/star_vs.glsl
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f4bf6dc4f6..e1a36a3bef 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -149,8 +149,10 @@ include_directories("${HEADER_ROOT_DIR}")
add_executable(OpenSpace ${SOURCE_ROOT_DIR}/main.cpp ${OPENSPACE_HEADER} ${OPENSPACE_SOURCE})
target_link_libraries(OpenSpace ${DEPENDENT_LIBS})
-# cotire(OpenSpace)
-#GhoulCopySharedLibraries(OpenSpace)
+if (NOT UNIX)
+ cotire(OpenSpace)
+endif ()
+GhoulCopySharedLibraries(OpenSpace)
add_subdirectory(tests)
diff --git a/src/abuffer/abuffer.cpp b/src/abuffer/abuffer.cpp
index cec43f97ef..b48b57fbab 100644
--- a/src/abuffer/abuffer.cpp
+++ b/src/abuffer/abuffer.cpp
@@ -52,7 +52,12 @@ namespace {
namespace openspace {
-ABuffer::ABuffer() : _validShader(false), _resolveShader(nullptr) {
+ABuffer::ABuffer()
+ : _validShader(false)
+ , _resolveShader(nullptr)
+ , _volumeStepFactor(0.0f)
+{
+
updateDimensions();
}
diff --git a/src/abuffer/abufferSingleLinked.cpp b/src/abuffer/abufferSingleLinked.cpp
index ebf22e9c8a..50c7a0f6a6 100644
--- a/src/abuffer/abufferSingleLinked.cpp
+++ b/src/abuffer/abufferSingleLinked.cpp
@@ -46,15 +46,15 @@ namespace {
namespace openspace {
-ABufferSingleLinked::ABufferSingleLinked(): _data(0), _anchorPointerTexture(0),
- _anchorPointerTextureInitializer(0), _atomicCounterBuffer(0), _fragmentBuffer(0),
- _fragmentTexture(0)
+ABufferSingleLinked::ABufferSingleLinked()
+ : _anchorPointerTexture(0)
+ , _anchorPointerTextureInitializer(0)
+ , _atomicCounterBuffer(0)
+ , _fragmentBuffer(0)
+ , _fragmentTexture(0)
{}
ABufferSingleLinked::~ABufferSingleLinked() {
- if(_data != 0)
- delete _data;
-
glDeleteTextures(1,&_anchorPointerTexture);
glDeleteTextures(1,&_fragmentTexture);
glDeleteBuffers(1,&_anchorPointerTextureInitializer);
@@ -86,7 +86,7 @@ bool ABufferSingleLinked::reinitializeInternal() {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _anchorPointerTextureInitializer);
glBufferData(GL_PIXEL_UNPACK_BUFFER, _totalPixels * sizeof(GLuint), NULL, GL_STATIC_DRAW);
- _data = (GLuint*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
+ GLuint* _data = (GLuint*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
memset(_data, 0x00, _totalPixels * sizeof(GLuint));
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
diff --git a/src/engine/gui.cpp b/src/engine/gui.cpp
index 13d5db2168..5de3254b65 100644
--- a/src/engine/gui.cpp
+++ b/src/engine/gui.cpp
@@ -38,6 +38,7 @@
#include
#include
#include
+#include
#include
#include
@@ -161,6 +162,29 @@ void renderOptionProperty(Property* prop, const std::string& ownerName) {
p->set(value);
}
+void renderSelectionProperty(Property* prop, const std::string& ownerName) {
+ SelectionProperty* p = static_cast(prop);
+ std::string name = p->guiName();
+
+ if (ImGui::CollapsingHeader((ownerName + "." + name).c_str())) {
+ const std::vector& options = p->options();
+ std::vector newSelectedIndices;
+
+ std::vector selectedIndices = p->value();
+
+ for (int i = 0; i < options.size(); ++i) {
+ std::string description = options[i].description;
+ bool selected = std::find(selectedIndices.begin(), selectedIndices.end(), i) != selectedIndices.end();
+ ImGui::Checkbox(description.c_str(), &selected);
+
+ if (selected)
+ newSelectedIndices.push_back(i);
+ }
+
+ p->setValue(std::move(newSelectedIndices));
+ }
+}
+
void renderIntProperty(Property* prop, const std::string& ownerName) {
IntProperty* p = static_cast(prop);
std::string name = p->guiName();
@@ -313,7 +337,8 @@ void GUI::initializeGL() {
}
void GUI::deinitializeGL() {
- delete _program;
+ if(_program)
+ delete _program;
_program = nullptr;
if (vao) glDeleteVertexArrays(1, &vao);
@@ -405,6 +430,8 @@ void GUI::registerProperty(properties::Property* prop) {
_optionProperty.insert(prop);
else if (className == "TriggerProperty")
_triggerProperty.insert(prop);
+ else if (className == "SelectionProperty")
+ _selectionProperty.insert(prop);
else {
LWARNING("Class name '" << className << "' not handled in GUI generation");
return;
@@ -484,6 +511,10 @@ void GUI::renderPropertyWindow() {
continue;
}
+ if (_selectionProperty.find(prop) != _selectionProperty.end()) {
+ renderSelectionProperty(prop, p.first);
+ continue;
+ }
}
}
}
diff --git a/src/engine/logfactory.cpp b/src/engine/logfactory.cpp
index ba7fffec09..0af5126a13 100644
--- a/src/engine/logfactory.cpp
+++ b/src/engine/logfactory.cpp
@@ -26,6 +26,7 @@
#include
#include
+#include
namespace {
const std::string _loggerCat = "LogFactory";
@@ -59,6 +60,7 @@ ghoul::logging::Log* LogFactory::createLog(const ghoul::Dictionary& dictionary)
<< keyFilename << "'");
return nullptr;
}
+ filename = absPath(filename);
bool append = true;
dictionary.getValue(keyAppend, append);
diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp
index 3c14cfd78f..97cec8b9b4 100644
--- a/src/engine/openspaceengine.cpp
+++ b/src/engine/openspaceengine.cpp
@@ -90,6 +90,13 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName)
ghoul::systemcapabilities::SystemCapabilities::initialize();
}
+OpenSpaceEngine::~OpenSpaceEngine() {
+ _gui.deinitializeGL();
+ if(_syncBuffer)
+ delete _syncBuffer;
+ _syncBuffer = nullptr;
+}
+
OpenSpaceEngine& OpenSpaceEngine::ref() {
assert(_engine);
return *_engine;
@@ -174,6 +181,9 @@ bool OpenSpaceEngine::create(int argc, char** argv,
FileSys.createCacheManager(absPath("${" + constants::configurationmanager::keyCache + "}"));
_engine->_console.loadHistory();
+ // Register the provided shader directories
+ ghoul::opengl::ShaderObject::addIncludePath("${SHADERS}");
+
_engine->_syncBuffer = new SyncBuffer(1024);
// Determining SGCT configuration file
@@ -198,6 +208,7 @@ bool OpenSpaceEngine::create(int argc, char** argv,
}
void OpenSpaceEngine::destroy() {
+
delete _engine;
ghoul::systemcapabilities::SystemCapabilities::deinitialize();
FactoryManager::deinitialize();
@@ -214,7 +225,7 @@ bool OpenSpaceEngine::initialize() {
clearAllWindows();
// Detect and log OpenCL and OpenGL versions and available devices
- SysCap.addComponent(new ghoul::systemcapabilities::CPUCapabilitiesComponent);
+ SysCap.addComponent(new ghoul::systemcapabilities::GeneralCapabilitiesComponent);
SysCap.addComponent(new ghoul::systemcapabilities::OpenGLCapabilitiesComponent);
SysCap.detectCapabilities();
SysCap.logCapabilities();
diff --git a/src/properties/property.cpp b/src/properties/property.cpp
index 48a326f807..6f2f8d2792 100644
--- a/src/properties/property.cpp
+++ b/src/properties/property.cpp
@@ -34,7 +34,7 @@ namespace properties {
namespace {
const std::string _loggerCat = "Property";
const std::string _metaDataKeyGuiName = "guiName";
- const std::string _metaDataKeyGroup = "group";
+ const std::string _metaDataKeyGroup = "Group";
const std::string _metaDataKeyVisible = "isVisible";
const std::string _metaDataKeyReadOnly = "isReadOnly";
@@ -45,7 +45,11 @@ const std::string Property::ViewOptions::Color = "color";
const std::string Property::ViewOptions::LightPosition = "lightPosition";
const std::string Property::ViewOptions::PowerScaledCoordinate = "powerScaledCoordinate";
const std::string Property::ViewOptions::PowerScaledScalar = "powerScaledScalar";
-
+
+const std::string Property::IdentifierKey = "Identifier";
+const std::string Property::NameKey = "Name";
+const std::string Property::TypeKey = "Type";
+const std::string Property::MetaDataKey = "MetaData";
Property::Property(std::string identifier, std::string guiName)
: _identifier(std::move(identifier))
@@ -105,6 +109,10 @@ std::string Property::guiName() const {
return std::move(result);
}
+std::string Property::description() const {
+ return "return {" + generateBaseDescription() + "}";
+}
+
void Property::setGroupIdentifier(std::string groupId) {
_metaData.setValue(_metaDataKeyGroup, std::move(groupId));
}
@@ -133,7 +141,6 @@ const ghoul::Dictionary& Property::metaData() const {
void Property::onChange(std::function callback) {
_onChangeCallback = std::move(callback);
-
}
PropertyOwner* Property::owner() const
@@ -151,5 +158,30 @@ void Property::notifyListener() {
_onChangeCallback();
}
+std::string Property::generateBaseDescription() const {
+ return
+ TypeKey + " = \"" + className() + "\", " +
+ IdentifierKey + " = \"" + identifier() + "\", " +
+ NameKey + " = \"" + guiName() + "\", " +
+ generateMetaDataDescription() + ", " +
+ generateAdditionalDescription();
+}
+
+std::string Property::generateMetaDataDescription() const {
+ bool isVisible, isReadOnly;
+ _metaData.getValue(_metaDataKeyVisible, isVisible);
+ _metaData.getValue(_metaDataKeyReadOnly, isReadOnly);
+
+ return
+ MetaDataKey + " = {" +
+ _metaDataKeyGroup + " = '" + groupIdentifier() + "'," +
+ _metaDataKeyVisible + " = " + (isVisible ? "true" : "false") + "," +
+ _metaDataKeyReadOnly +" = " + (isReadOnly ? "true" : "false") + "}";
+}
+
+std::string Property::generateAdditionalDescription() const {
+ return "";
+}
+
} // namespace properties
} // namespace openspace
diff --git a/src/properties/selectionproperty.cpp b/src/properties/selectionproperty.cpp
index 5e0ca70193..6faaf8e915 100644
--- a/src/properties/selectionproperty.cpp
+++ b/src/properties/selectionproperty.cpp
@@ -51,10 +51,10 @@ void SelectionProperty::addOption(Option option) {
const std::vector& SelectionProperty::options() const {
return _options;
}
-
-void SelectionProperty::setValue(std::vector value) {
- _values = std::move(value);
-}
+//
+//void SelectionProperty::setValue(std::vector value) {
+// _values = std::move(value);
+//}
template <>
std::string PropertyDelegate>>::className() {
diff --git a/src/rendering/model/renderablemodel.cpp b/src/rendering/model/renderablemodel.cpp
index 963b95d14b..e4506143cc 100644
--- a/src/rendering/model/renderablemodel.cpp
+++ b/src/rendering/model/renderablemodel.cpp
@@ -57,15 +57,12 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
, _geometry(nullptr)
{
std::string name;
- bool success = dictionary.getValue(constants::scenegraphnode::keyName, name);
- assert(success);
-
std::string path;
- success = dictionary.getValue(constants::scenegraph::keyPathModule, path);
- assert(success);
+ dictionary.getValue(constants::scenegraphnode::keyName, name);
+ dictionary.getValue(constants::scenegraph::keyPathModule, path);
ghoul::Dictionary geometryDictionary;
- success = dictionary.getValue(
+ bool success = dictionary.getValue(
constants::renderablemodel::keyGeometry, geometryDictionary);
if (success) {
geometryDictionary.setValue(constants::scenegraphnode::keyName, name);
@@ -78,16 +75,13 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
if (success)
_colorTexturePath = path + "/" + texturePath;
- if (_geometry != nullptr)
addPropertySubOwner(_geometry);
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderableModel::loadTexture, this));
- bool b1 = dictionary.getValue(keySource, _source);
- bool b2 = dictionary.getValue(keyDestination, _destination);
- assert(b1 == true);
- assert(b2 == true);
+ dictionary.getValue(keySource, _source);
+ dictionary.getValue(keyDestination, _destination);
}
@@ -96,7 +90,10 @@ RenderableModel::~RenderableModel(){
}
bool RenderableModel::isReady() const {
- return _programObject != nullptr;
+ bool ready = true;
+ ready &= (_programObject != nullptr);
+ ready &= (_texture != nullptr);
+ return ready;
}
bool RenderableModel::initialize(){
@@ -106,39 +103,35 @@ bool RenderableModel::initialize(){
&= OsEng.ref().configurationManager().getValue("pscShader", _programObject);
loadTexture();
- completeSuccess &= (_texture != nullptr);
- if (_geometry != nullptr)
+ completeSuccess &= (_texture != nullptr);
completeSuccess &= _geometry->initialize(this);
+ completeSuccess &= !_source.empty();
+ completeSuccess &= !_destination.empty();
return completeSuccess;
}
bool RenderableModel::deinitialize(){
-
- if (_geometry != nullptr){
+ if (_geometry) {
_geometry->deinitialize();
delete _geometry;
- _geometry = nullptr;
}
- delete _texture;
+ if (_texture)
+ delete _texture;
+
+ _geometry = nullptr;
_texture = nullptr;
return true;
}
void RenderableModel::render(const RenderData& data)
{
- if (!_programObject) return;
- if (!_texture) return;
-
// activate shader
_programObject->activate();
-
// scale the planet to appropriate size since the planet is a unit sphere
glm::mat4 transform = glm::mat4(1);
- glm::mat4 roty = glm::rotate(transform, 90.f, glm::vec3(0, 1, 0));
- glm::mat4 scale = glm::scale(transform, glm::vec3(1, -1, 1));
glm::mat4 tmp = glm::mat4(1);
for (int i = 0; i < 3; i++){
@@ -146,6 +139,7 @@ void RenderableModel::render(const RenderData& data)
tmp[i][j] = _stateMatrix[i][j];
}
}
+
transform *= tmp;
//glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
@@ -162,8 +156,7 @@ void RenderableModel::render(const RenderData& data)
unit.activate();
_texture->bind();
_programObject->setUniform("texture1", unit);
-
- if (_geometry != nullptr)
+
_geometry->render();
// disable shader
@@ -171,6 +164,10 @@ void RenderableModel::render(const RenderData& data)
}
void RenderableModel::update(const UpdateData& data){
+#ifndef NDEBUG
+ if (_source.empty() || _destination.empty())
+ return;
+#endif
// set spice-orientation in accordance to timestamp
openspace::SpiceManager::ref().getPositionTransformMatrix(_source, _destination, data.time, _stateMatrix);
@@ -181,7 +178,7 @@ void RenderableModel::loadTexture()
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
- _texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
+ _texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
diff --git a/src/rendering/model/wavefrontgeometry.cpp b/src/rendering/model/wavefrontgeometry.cpp
index 965194c0db..c118a31402 100644
--- a/src/rendering/model/wavefrontgeometry.cpp
+++ b/src/rendering/model/wavefrontgeometry.cpp
@@ -37,7 +37,6 @@ namespace modelgeometry {
WavefrontGeometry::WavefrontGeometry(const ghoul::Dictionary& dictionary)
: ModelGeometry()
- , _mode(GL_TRIANGLES)
, _isize(0)
, _vsize(0)
, _varray(nullptr)
@@ -48,7 +47,6 @@ WavefrontGeometry::WavefrontGeometry(const ghoul::Dictionary& dictionary)
// The name is passed down from the SceneGraphNode
std::string name;
bool success = dictionary.getValue(keyName, name);
- assert(success);
std::string file;
success = dictionary.getValue(constants::modelgeometry::keyObjFile, file);
@@ -115,9 +113,9 @@ void WavefrontGeometry::loadObj(const char *filename){
_vsize = indicesSize;
// float arrays
- float *tempVertexArray = new float[vertexSize];
- float *tempVertexNormalArray = new float[vertexNormalSize];
- float *tempVertexTextureArray = new float[vertexTextureSize];
+ float* tempVertexArray = new float[vertexSize];
+ float* tempVertexNormalArray = new float[vertexNormalSize];
+ float* tempVertexTextureArray = new float[vertexTextureSize];
_varray = new Vertex[_vsize];
// int arrays
@@ -268,8 +266,10 @@ bool WavefrontGeometry::initialize(RenderableModel* parent){
}
void WavefrontGeometry::deinitialize(){
- delete[] _varray;
- delete[] _iarray;
+ if (_varray)
+ delete[] _varray;
+ if (_iarray)
+ delete[] _iarray;
glDeleteBuffers(1, &_vBufferID);
glDeleteBuffers(1, &_iBufferID);
@@ -281,7 +281,7 @@ void WavefrontGeometry::render(){
// render
glBindVertexArray(_vaoID); // select first VAO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
- glDrawElements(_mode, _isize, GL_UNSIGNED_INT, 0);
+ glDrawElements(GL_TRIANGLES, _isize, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
}
diff --git a/src/rendering/planets/renderableplanet.cpp b/src/rendering/planets/renderableplanet.cpp
index 3b945dfb98..d8777f468a 100644
--- a/src/rendering/planets/renderableplanet.cpp
+++ b/src/rendering/planets/renderableplanet.cpp
@@ -25,16 +25,18 @@
// open space includes
#include
#include
-#include
-
-#include
-#include
-#include
-
#include
#include
-
+#include
#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
#include
namespace {
@@ -52,11 +54,13 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
{
std::string name;
bool success = dictionary.getValue(constants::scenegraphnode::keyName, name);
- assert(success);
+ ghoul_assert(success,
+ "RenderablePlanet need the '" <initialize(this);
+ _geometry->initialize(this);
- return completeSuccess;
+ return isReady();
}
bool RenderablePlanet::deinitialize() {
- _geometry->deinitialize();
- delete _geometry;
+ if(_geometry) {
+ _geometry->deinitialize();
+ delete _geometry;
+ }
+ if(_texture)
+ delete _texture;
+
_geometry = nullptr;
- delete _texture;
_texture = nullptr;
return true;
}
bool RenderablePlanet::isReady() const {
- return (_geometry != nullptr);
+ bool ready = true;
+ ready &= (_programObject != nullptr);
+ ready &= (_texture != nullptr);
+ ready &= (_geometry != nullptr);
+ return ready;
}
void RenderablePlanet::render(const RenderData& data)
{
- if (!_programObject) return;
- if (!_texture) return;
-
// activate shader
_programObject->activate();
@@ -167,7 +175,7 @@ void RenderablePlanet::loadTexture()
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
- _texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
+ _texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
diff --git a/src/rendering/planets/simplespheregeometry.cpp b/src/rendering/planets/simplespheregeometry.cpp
index 2169af250a..d57ce7de9d 100644
--- a/src/rendering/planets/simplespheregeometry.cpp
+++ b/src/rendering/planets/simplespheregeometry.cpp
@@ -24,6 +24,7 @@
#include
#include
+#include
namespace {
const std::string _loggerCat = "SimpleSphereGeometry";
@@ -93,7 +94,8 @@ bool SimpleSphereGeometry::initialize(RenderablePlanet* parent)
void SimpleSphereGeometry::deinitialize()
{
- delete _planet;
+ if (_planet)
+ delete _planet;
_planet = nullptr;
}
@@ -109,7 +111,9 @@ void SimpleSphereGeometry::createSphere()
PowerScaledScalar planetSize(_radius);
_parent->setBoundingSphere(planetSize);
- delete _planet;
+ if(_planet)
+ delete _planet;
+
_planet = new PowerScaledSphere(planetSize, _segments);
_planet->initialize();
}
diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp
index 9260a617a8..2a7269eb3c 100644
--- a/src/rendering/renderable.cpp
+++ b/src/rendering/renderable.cpp
@@ -26,9 +26,13 @@
#include
#include
#include
+#include
+// ghoul
+#include
#include
#include
+#include
namespace {
const std::string _loggerCat = "Renderable";
@@ -66,9 +70,19 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary)
: _enabled("enabled", "Is Enabled", true)
{
setName("renderable");
-
+#ifndef NDEBUG
+ std::string name;
+ ghoul_assert(dictionary.getValue(constants::scenegraphnode::keyName, name),
+ "Scenegraphnode need to specify '" << constants::scenegraphnode::keyName
+ << "' because renderables is going to use this for debugging!");
+#endif
// get path if available
- const bool success = dictionary.getValue(constants::scenegraph::keyPathModule, _relativePath);
+ bool success = dictionary.getValue(constants::scenegraph::keyPathModule, _relativePath);
+#ifndef NDEBUG
+ ghoul_assert(success,
+ "Scenegraphnode need to specify '" << constants::scenegraph::keyPathModule
+ << "' because renderables is going to use this for debugging!");
+#endif
if (success)
_relativePath += ghoul::filesystem::FileSystem::PathSeparator;
@@ -107,7 +121,11 @@ std::string Renderable::findPath(const std::string& path) {
return "";
}
-void Renderable::setPscUniforms(ghoul::opengl::ProgramObject* program, const Camera* camera, const psc& position) {
+void Renderable::setPscUniforms(
+ ghoul::opengl::ProgramObject* program,
+ const Camera* camera,
+ const PowerScaledCoordinate& position)
+{
program->setUniform("campos", camera->position().vec4());
program->setUniform("objpos", position.vec4());
program->setUniform("camrot", camera->viewRotationMatrix());
diff --git a/src/rendering/renderableephemeris.cpp b/src/rendering/renderableephemeris.cpp
deleted file mode 100644
index a7b31be463..0000000000
--- a/src/rendering/renderableephemeris.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-/*****************************************************************************************
-* *
-* OpenSpace *
-* *
-* Copyright (c) 2014 *
-* *
-* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
-* software and associated documentation files (the "Software"), to deal in the Software *
-* without restriction, including without limitation the rights to use, copy, modify, *
-* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
-* permit persons to whom the Software is furnished to do so, subject to the following *
-* conditions: *
-* *
-* The above copyright notice and this permission notice shall be included in all copies *
-* or substantial portions of the Software. *
-* *
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
-* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
-* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
-* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
-* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
-* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
-****************************************************************************************/
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-#include // std::move
-
-
-namespace {
- const std::string _loggerCat = "RenderableEphemeris";
-}
-
-namespace openspace{
-RenderableEphemeris::RenderableEphemeris(const ghoul::Dictionary& dictionary)
- : Renderable(dictionary)
- , _colorTexturePath("colorTexture", "Color Texture")
- , _programObject(nullptr)
- , _texture(nullptr)
- , _vaoID(0)
- , _vBufferID(0)
- , _iBufferID(0)
- , _mode(GL_LINES){
-
-
- double lightTime = 0.0;
- double planetYear = 31536000;
- SpiceManager::ref().getETfromDate("2005 nov 01 00:00:00", _time);
- // -------------------------------------- ^ this has to be simulation start-time, not passed in here though --
-
- double et = _time - planetYear;
-
- int segments = 365; // note to self: code not look nice. cleanup for clarity later.
- int indx = 0;
- psc pscpos, pscvel;
-
- _isize = (segments)*2;
- _vsize = (segments)*2;
- _varray = new Vertex[_vsize];
- _iarray = new int[_isize];
-
- _updated = new bool[_vsize];
- std::fill(_updated, _updated + _vsize, false);
-
- static_assert(sizeof(Vertex) == 64, "The size of the Vertex needs to be 64 for performance");
-
- // get first position, ephemeris start-point
- SpiceManager::ref().getTargetState("EARTH", "SUN", "GALACTIC", "LT+S", et, pscpos, pscvel, lightTime);
-
- memcpy(_varray[indx].location, glm::value_ptr(pscpos.vec4()), 4 * sizeof(double));
- memcpy(_varray[indx].velocity, glm::value_ptr(glm::vec4(1, 1, 0, 1)), 4 * sizeof(double));
-
- _intervals.push_back(std::pair(indx, et));
-
- _iarray[indx] = indx;
- indx++;
-
- _increment = planetYear / segments;
- for (int i = 0; i < segments; i++){
- et += _increment;
- SpiceManager::ref().getTargetState("EARTH", "SUN", "GALACTIC", "LT+S", et, pscpos, pscvel, lightTime);
- for (int k = 0; k < 2; k++){
- if (i == segments - 1 && k == 1) { // do copy first to last
- break;
- }
- memcpy(_varray[indx].location, glm::value_ptr(pscpos.vec4()), 4 * sizeof(double));
- memcpy(_varray[indx].velocity, glm::value_ptr(glm::vec4(1, 1, 0, 1)), 4 * sizeof(double));
-
- _intervals.push_back(std::pair(indx, et));
-
- _iarray[indx] = indx;
- _index[k] = indx;
- indx++;
- }
- }
- _delta = _vsize;
-
- /// testing std::move()
- int array1[10] = { 10, 9, 8 , 7, 6, 5, 4, 3, 2 , 1 };
-
- int size = sizeof(array1)/(sizeof(int));
- std::cout << "before : ";
- for (int i = 0; i < 10; i++){
- std::cout << array1[i] << " ";
- }
- for (int i = size-1; i != 0; i--){
- array1[i] = std::move(array1[i-1]);
- if (i == 1){
- array1[0] = 11;
- }
- }
- std::cout << "after : ";
- for (int i = 0; i < 10; i++){
- std::cout << array1[i] << " ";
- }
- std::cout << std::endl;
-
-}
-
-RenderableEphemeris::~RenderableEphemeris(){
- deinitialize();
-}
-
-bool RenderableEphemeris::isReady() const {
- return _programObject != nullptr;
-}
-
-bool RenderableEphemeris::initialize(){
- bool completeSuccess = true;
- if (_programObject == nullptr)
- completeSuccess
- &= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
-
- loadTexture();
- completeSuccess &= (_texture != nullptr);
-
- // Initialize and upload to graphics card
- glGenVertexArrays(1, &_vaoID);
- glGenBuffers(1, &_vBufferID);
- glGenBuffers(1, &_iBufferID);
-
- glBindVertexArray(_vaoID);
-
- glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
- glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(Vertex), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
- glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(Vertex), _varray);
-
- glEnableVertexAttribArray(0);
- glEnableVertexAttribArray(1);
- glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, location)));
- glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, velocity)));
-
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
-
- glBindVertexArray(0);
-
- return completeSuccess;
-}
-
-bool RenderableEphemeris::deinitialize(){
- delete _texture;
- _texture = nullptr;
- return true;
-}
-
-void RenderableEphemeris::nextIndex(){
-
- if (_previousTime != _time){
- int skip = _index[1] - _prev[1];
-
- _prev[0] = _index[0];
- _prev[1] = _index[1];
-
- double t = _time - 31536000;
- // Better optimization:
-
- int x = (_index[0] > _index[1]) ? _index[0] : _index[1];
- if (x >= _vsize - 1 || skip + x > _vsize ) x = 1;
-
- for (; x < _vsize; x++){
- double t1 = _intervals[x - 1].second;
- double t2 = _intervals[x].second;
-
- if (t1 != t2 && t >= t1 && t <= t2){
- _index[0] = (x - 2 < 0) ? _vsize - 1 : x - 2;
- _index[1] = x - 1;
- break;
- }
- }
- }
- _previousTime = _time;
-}
-
-
-void RenderableEphemeris::render(const RenderData& data){
- assert(_programObject);
- _programObject->activate();
-
-
- // setup the data to the shader
- //_programObject->setUniform("objectVelocity", pscvel.vec4());
-
- _programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
- _programObject->setUniform("ModelTransform", glm::mat4(1));
- setPscUniforms(_programObject, &data.camera, data.position);
-
- nextIndex();
-
-
- for (int i = 0; i < _vsize; i++){
- _varray[i].velocity[0] -= 0.00008;
- _varray[i].velocity[1] -= 0.00006;
- _varray[i].velocity[2] -= 0.00004;
- }
-
- if (_delta > 0){
- int i = _index[0];
- int j = _index[1];
-
- while (i != _prev[0]){
- if (_updated[i] == false && _updated[j] == false){
-
- _updated[i] = true;
- _updated[j] = true;
-
- _intervals[i].second += 31536000; // not the cleanest solution but works. need dt
- _intervals[j].second += 31536000;
-
- // DEBUGGING COLOR CODING
- memcpy(_varray[i].velocity, glm::value_ptr(glm::vec4(0, 0, 1, 1)), 4 * sizeof(double)); // blue if updated
- memcpy(_varray[j].velocity, glm::value_ptr(glm::vec4(0, 0, 1, 1)), 4 * sizeof(double));
-
- }
- i = (i - 2 < 0) ? _vsize - 1 : i - 2;
- j = (j - 1 < 0) ? _vsize - 1 : j - 2;
-
- std::cout << i << " " << j << std::endl;
- }
- }
- /*
- if (_updated[_index[1]] == false && _updated[_index[0]] == false){
-
- _updated[_index[0]] = true;
- _updated[_index[1]] = true;
-
- _intervals[_index[0]].second = _time;
- _intervals[_index[1]].second = _time;
-
- memcpy(_varray[_index[0]].location, glm::value_ptr(_pscpos.vec4()), 4 * sizeof(double));
- memcpy(_varray[_index[1]].location, glm::value_ptr(_pscpos.vec4()), 4 * sizeof(double));
-
- // memcpy(_varray[_index[0]].velocity, glm::value_ptr(glm::vec4(1, 1, 1, 1)), 4 * sizeof(double));
- // memcpy(_varray[_index[1]].velocity, glm::value_ptr(glm::vec4(1, 1, 1, 1)), 4 * sizeof(double));
-
- // DEBUGGING COLOR CODING
-
- memcpy(_varray[_index[0]].velocity, glm::value_ptr(glm::vec4(0, 0, 1, 1)), 4 * sizeof(double)); // blue if updated
- memcpy(_varray[_index[1]].velocity, glm::value_ptr(glm::vec4(0, 0, 1, 1)), 4 * sizeof(double));
-
- memcpy(_varray[_index[2]].velocity, glm::value_ptr(glm::vec4(1, 0, 0, 1)), 4 * sizeof(double)); // red
- memcpy(_varray[_index[3]].velocity, glm::value_ptr(glm::vec4(1, 0, 0, 1)), 4 * sizeof(double));
-
- _updated[_index[2]] = false;
- _updated[_index[3]] = false;
- }
- */
-
-
- glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
- glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(Vertex), _varray);
-
-
- //psc pointPos(_varray[_index].location[0], _varray[_index].location[1], _varray[_index].location[2], _varray[_index].location[3]);
- //std::cout << "dist, indx : " << distance(_pscpos, pointPos) << ", " << _index << std::endl;
-
-
- glBindVertexArray(_vaoID);
- glDrawArrays(_mode, 0, GL_UNSIGNED_INT);
- glBindVertexArray(0);
-
- glPointSize(2.f);
-
- glBindVertexArray(_vaoID);
- glDrawArrays(GL_POINTS, 0, GL_UNSIGNED_INT);
- glBindVertexArray(0);
-
- _programObject->deactivate();
-}
-
-void RenderableEphemeris::update(const UpdateData& data){
- double lightTime;
- _time = data.time;
-
- SpiceManager::ref().getTargetState("EARTH", "SUN", "GALACTIC", "LT+S", data.time, _pscpos, _pscvel, lightTime);
-}
-
-void RenderableEphemeris::loadTexture()
-{
- delete _texture;
- _texture = nullptr;
- if (_colorTexturePath.value() != "") {
- _texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
- if (_texture) {
- LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
- _texture->uploadTexture();
- }
- }
-}
-
-
-}
\ No newline at end of file
diff --git a/src/rendering/renderablefieldlines.cpp b/src/rendering/renderablefieldlines.cpp
index 20d627c626..755a78178d 100644
--- a/src/rendering/renderablefieldlines.cpp
+++ b/src/rendering/renderablefieldlines.cpp
@@ -29,6 +29,7 @@
#include
#include
+#include
namespace {
const std::string _loggerCat = "RenderableFieldlines";
@@ -43,15 +44,15 @@ namespace openspace {
RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _fieldlineVAO(0)
+ , _vertexPositionBuffer(0)
, _shader(nullptr)
{
std::string name;
- bool success = dictionary.getValue(constants::scenegraphnode::keyName, name);
- assert(success);
+ dictionary.getValue(constants::scenegraphnode::keyName, name);
// Read fieldlines module into dictionary
ghoul::Dictionary fieldlines;
- success = dictionary.getValue(keyFieldlines, fieldlines);
+ bool success = dictionary.getValue(keyFieldlines, fieldlines);
if (!success) {
LERROR("RenderableFieldlines '" << name << "' did not contain a '" <<
keyFieldlines << "' key");
@@ -86,6 +87,7 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
}
RenderableFieldlines::~RenderableFieldlines() {
+ deinitialize();
}
bool RenderableFieldlines::isReady() const {
@@ -93,8 +95,14 @@ bool RenderableFieldlines::isReady() const {
}
bool RenderableFieldlines::initialize() {
- assert(_filenames.size() != 0);
- assert(_hintsDictionaries.size() != 0);
+ if(_filenames.size() == 0) {
+ LWARNING("No proper filenames provided, cannot initialize!");
+ return false;
+ }
+
+ ghoul_assert(_hintsDictionaries.size() != _filenames.size(),
+ "The dictionary sizes should match, "
+ << _hintsDictionaries.size() << " != " << _filenames.size());
int prevEnd = 0;
std::vector vertexData;
@@ -115,11 +123,10 @@ bool RenderableFieldlines::initialize() {
LDEBUG("Number of vertices : " << vertexData.size());
// ------ FIELDLINES -----------------
- GLuint vertexPositionBuffer;
glGenVertexArrays(1, &_fieldlineVAO); // generate array
glBindVertexArray(_fieldlineVAO); // bind array
- glGenBuffers(1, &vertexPositionBuffer); // generate buffer
- glBindBuffer(GL_ARRAY_BUFFER, vertexPositionBuffer); // bind buffer
+ glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
+ glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
glBufferData(GL_ARRAY_BUFFER, vertexData.size()*sizeof(LinePoint), &vertexData.front(), GL_STATIC_DRAW);
// Vertex positions
@@ -136,18 +143,19 @@ bool RenderableFieldlines::initialize() {
glBindVertexArray(0); //unbind array
OsEng.ref().configurationManager().getValue("FieldlineProgram", _shader);
- assert(_shader);
- return true;
+ return isReady();
}
bool RenderableFieldlines::deinitialize() {
+ glDeleteVertexArrays(1, &_fieldlineVAO);
+ _fieldlineVAO = 0;
+ glDeleteBuffers(1, &_vertexPositionBuffer);
+ _vertexPositionBuffer = 0;
return true;
}
void RenderableFieldlines::render(const RenderData& data) {
- if (!_shader)
- return;
_shader->activate();
_shader->setUniform("modelViewProjection", data.camera.viewProjectionMatrix());
@@ -158,8 +166,8 @@ void RenderableFieldlines::render(const RenderData& data) {
// ------ DRAW FIELDLINES -----------------
glBindVertexArray(_fieldlineVAO);
glMultiDrawArrays(GL_LINE_STRIP_ADJACENCY, &_lineStart[0], &_lineCount[0], _lineStart.size());
-
glBindVertexArray(0);
+
_shader->deactivate();
}
diff --git a/src/rendering/renderablefov.cpp b/src/rendering/renderablefov.cpp
index 7c5041f313..1b3507ded7 100644
--- a/src/rendering/renderablefov.cpp
+++ b/src/rendering/renderablefov.cpp
@@ -1,498 +1,242 @@
/*****************************************************************************************
-* *
-* OpenSpace *
-* *
-* Copyright (c) 2014 *
-* *
-* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
-* software and associated documentation files (the "Software"), to deal in the Software *
-* without restriction, including without limitation the rights to use, copy, modify, *
-* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
-* permit persons to whom the Software is furnished to do so, subject to the following *
-* conditions: *
-* *
-* The above copyright notice and this permission notice shall be included in all copies *
-* or substantial portions of the Software. *
-* *
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
-* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
-* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
-* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
-* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
-* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
-****************************************************************************************/
+ * *
+ * OpenSpace *
+ * *
+ * Copyright (c) 2014 *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this *
+ * software and associated documentation files (the "Software"), to deal in the Software *
+ * without restriction, including without limitation the rights to use, copy, modify, *
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
+ * permit persons to whom the Software is furnished to do so, subject to the following *
+ * conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included in all copies *
+ * or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ ****************************************************************************************/
#include
#include
#include
#include
-#include
+#include
#include
-#include
-
#include
#include
-#include
-#include
+#include
namespace {
- const std::string _loggerCat = "RenderableFov";
- //constants
- const std::string keyBody = "Body";
- const std::string keyFrame = "Frame";
- const std::string keyPathModule = "ModulePath";
- const std::string keyColor = "RGB";
- const std::string keyInstrument = "Instrument.Name";
- const std::string keyInstrumentMethod = "Instrument.Method";
- const std::string keyInstrumentAberration = "Instrument.Aberration";
-
-
+ const std::string _loggerCat = "RenderableFov";
+ //constants
+ 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";
}
+
//#define DEBUG
namespace openspace{
- // colors, move later
- glm::vec4 origin(0);
- glm::vec4 col_gray(0.3, 0.3, 0.3, 1);
- glm::vec4 col_start(1.00, 0.89, 0.00, 1);
- glm::vec4 col_end(1.00, 0.29, 0.00, 1);
- glm::vec4 col_sq(1.00, 0.29, 0.00, 1);
+RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
+ : Renderable(dictionary)
+ , _colorTexturePath("colorTexture", "Color Texture")
+ , _programObject(nullptr)
+ , _texture(nullptr)
+ , _vaoID(0)
+ , _vBufferID(0)
+ , _iBufferID(0)
+{
+ // @TODO Uncomment when used again, do not depend on assert in constructor --jonasstrandstedt
+ //dictionary.getValue(keyBody, _target);
+ //dictionary.getValue(keyObserver, _observer);
+ //dictionary.getValue(keyFrame, _frame);
- glm::vec4 col_proj(1, 1, 1, 1);
-
- RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
- : Renderable(dictionary)
- , _colorTexturePath("colorTexture", "Color Texture")
- , _programObject(nullptr)
- , _texture(nullptr)
- , _mode(GL_LINES){
-
- assert(dictionary.getValue(keyBody , _spacecraft));
- assert(dictionary.getValue(keyFrame , _frame));
- assert(dictionary.getValue(keyInstrument , _instrumentID));
- assert(dictionary.getValue(keyInstrumentMethod , _method));
- assert(dictionary.getValue(keyInstrumentAberration , _aberrationCorrection));
+ if (!dictionary.getValue(keyColor, _c)){
+ _c = glm::vec3(0.0);
+ }else{
+ _r = 1 / _c[0];
+ _g = 1 / _c[1];
+ _b = 1 / _c[2];
+ }
}
-void RenderableFov::allocateData(){
+void RenderableFov::fullYearSweep(){
+
int points = 8;
- _stride[0] = points;
- _isize[0] = points;
- _iarray1[0] = new int[_isize[0]];
+ _stride = 8;
+ _isize = points;
+ _iarray.clear();
+
for (int i = 0; i < points; i++){
for (int j = 0; j < 4; j++){
- _varray1.push_back(0); // pos
+ _varray.push_back(0); // pos
}
for (int j = 0; j < 4; j++){
- _varray1.push_back(0); // col
+ _varray.push_back(0); // col
}
- _iarray1[0][i] = i;
+ _iarray.push_back(i);
}
- _stride[0] = 8;
- _vsize[0] = _varray1.size();
- _vtotal[0] = static_cast(_vsize[0] / _stride[0]);
-
- // allocate second vbo data
- int cornerPoints = 5;
- _isize[1] = cornerPoints;
- _iarray1[1] = new int[_isize[1]];
- for (int i = 0; i < _isize[1]; i++){
- _iarray1[1][i] = i;
- }
- _varray2.resize(40);
- _vsize[1] = 40;
- _vtotal[1] = 5;
- _isteps = 5;
+ _stride = 8;
+ _vsize = _varray.size();
+ _vtotal = static_cast(_vsize / _stride);
}
RenderableFov::~RenderableFov(){
deinitialize();
}
+bool RenderableFov::isReady() const {
+ bool ready = true;
+ ready &= (_programObject != nullptr);
+
+ return ready;
+}
+
+void RenderableFov::sendToGPU(){
+ // Initialize and upload to graphics card
+ glGenVertexArrays(1, &_vaoID);
+ glGenBuffers(1, &_vBufferID);
+ glGenBuffers(1, &_iBufferID);
+
+ glBindVertexArray(_vaoID);
+ glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
+ glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
+ glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
+
+ GLsizei st = sizeof(GLfloat) * _stride;
+
+ glEnableVertexAttribArray(0);
+ glEnableVertexAttribArray(1);
+ glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
+ glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray.data(), GL_STATIC_DRAW);
+
+ glBindVertexArray(0);
+}
+
bool RenderableFov::initialize(){
bool completeSuccess = true;
if (_programObject == nullptr)
completeSuccess &= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
+
+ SpiceManager::ref().getETfromDate("2007 feb 26 20:00:00", _startTrail);
- allocateData();
- sendToGPU();
+ fullYearSweep();
+ sendToGPU();
return completeSuccess;
}
bool RenderableFov::deinitialize(){
- delete _texture;
+ if (_texture)
+ delete _texture;
_texture = nullptr;
+
+ glDeleteVertexArrays(1, &_vaoID);
+ glDeleteBuffers(1, &_vBufferID);
+ glDeleteBuffers(1, &_iBufferID);
+
return true;
}
-bool RenderableFov::isReady() const {
- return _programObject != nullptr;
-}
-
-void RenderableFov::sendToGPU(){
- // Initialize and upload to graphics card
- glGenVertexArrays(1, &_vaoID[0]);
- glGenBuffers(1, &_vboID[0]);
- glGenBuffers(1, &_iboID[0]);
-
- glBindVertexArray(_vaoID[0]);
- glBindBuffer(GL_ARRAY_BUFFER, _vboID[0]);
- glBufferData(GL_ARRAY_BUFFER, _vsize[0] * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
- glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[0] * sizeof(GLfloat), &_varray1[0]);
-
- GLsizei st = sizeof(GLfloat) * _stride[0];
-
- glEnableVertexAttribArray(0);
- glEnableVertexAttribArray(1);
- glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
- glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iboID[0]);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize[0] * sizeof(int), _iarray1, GL_STATIC_DRAW);
- glBindVertexArray(0);
-
- // second vbo
- glGenVertexArrays(1, &_vaoID[1]);
- glGenBuffers(1, &_vboID[1]);
- glGenBuffers(1, &_iboID[1]);
-
- glBindVertexArray(_vaoID[1]);
- glBindBuffer(GL_ARRAY_BUFFER, _vboID[1]);
- glBufferData(GL_ARRAY_BUFFER, _vsize[1] * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
- glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[1] * sizeof(GLfloat), &_varray2[0]);
-
- glEnableVertexAttribArray(0);
- glEnableVertexAttribArray(1);
- glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
- glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iboID[1]);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize[1] * sizeof(int), _iarray1[1], GL_STATIC_DRAW);
- glBindVertexArray(0);
-}
-// various helper methods
-
-void RenderableFov::insertPoint(std::vector& arr, psc& p, glm::vec4& c){
- for (int i = 0; i < 4; i++){
- arr.push_back(p[i]);
- }
- for (int i = 0; i < 4; i++){
- arr.push_back(c[i]);
- }
- _nrInserted++;
-}
-double RenderableFov::distanceBetweenPoints(psc p1, psc p2){
- PowerScaledScalar dist = (p1 - p2).length();
- return dist[0] * pow(10, dist[1]);
-}
-
-psc RenderableFov::pscInterpolate(psc p0, psc p1, float t){
- assert(t >= 0 && t <= 1);
- float t2 = (1.f - t);
- return PowerScaledCoordinate::PowerScaledCoordinate(t2*p0[0] + t*p1[0],
- t2*p0[1] + t*p1[1],
- t2*p0[2] + t*p1[2],
- t2*p0[3] + t*p1[3]);
-}
-glm::dvec3 RenderableFov::interpolate(glm::dvec3 p0, glm::dvec3 p1, float t){
- assert(t >= 0 && t <= 1);
- float t2 = (1.f - t);
- return glm::dvec3(p0.x*t2 + p1.x*t, p0.y*t2 + p1.y*t, p0.z*t2 + p1.z*t);
-}
-// This method is the current bottleneck.
-psc RenderableFov::checkForIntercept(glm::dvec3 ray){
- double targetEt;
- bool intercepted = openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
- _frame, _method, _aberrationCorrection,
- _time, targetEt, ray, ipoint, ivec);
- _interceptVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(ivec[0], ivec[1], ivec[2]);
- _interceptVector[3] += 3;
-
- return _interceptVector;
-}
-// Orthogonal projection next to planets surface, can also be optimized.
-psc RenderableFov::orthogonalProjection(glm::dvec3 vecFov){
- glm::dvec3 vecToTarget;
- double lt;
- SpiceManager::ref().getTargetPosition(_fovTarget, _spacecraft, _frame, _aberrationCorrection, _time, vecToTarget, lt);
- openspace::SpiceManager::ref().frameConversion(vecFov, _instrumentID, _frame, _time);
- glm::dvec3 p = openspace::SpiceManager::ref().orthogonalProjection(vecToTarget, vecFov);
-
- psc projection = PowerScaledCoordinate::CreatePowerScaledCoordinate(p[0], p[1], p[2]);
- projection[3] += 3;
-
- return projection;
-}
-// Bisection method, simple recurtion
-glm::dvec3 RenderableFov::bisection(glm::dvec3 p1, glm::dvec3 p2, double tolerance){
- //check if point is on surface
- double targetEt;
- glm::dvec3 half = interpolate(p1, p2, 0.5f);
- bool intercepted = openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
- _frame, _method, _aberrationCorrection,
- _time, targetEt, half, ipoint, ivec);
- if (glm::distance(_previousHalf, half) < tolerance){
- _previousHalf = glm::dvec3(0);
- return half;
- }
- _previousHalf = half;
- //recursive search
- if (intercepted == false){
- return bisection(p1, half, tolerance);
- }else{
- return bisection(half, p2, tolerance);
- }
-}
-
-/*
- README:
- There are 4 different cases as each boundary vector can either have detected
- an intercept or is outside of the planets surface. When no such intercepts are
- detected the algorithm performs an orthogonal projection to 'clip' the current
- fov vector next to the planets surface. If two or more intercepts are detected
- the algorithm continues with the bisection method O(logn) for points [Pn, Pn+1]
- to locate the point Pb where the orthogonal plane meets the planets surface
- (within ~20 iterations this will narrow down to centimeter resolution).
- Upon finding Pb a linear interpolation is performed for [Pn, Pb], at this stage
- the points are located on a straight line between the surface intercept and the
- surface-bound fov-corner. In order to correctly place these points on the
- targets surface, each consecutive point is queried for a surface intercept and
- thereby moved to the hull.
-*/
-void RenderableFov::fovProjection(bool H[], std::vector bounds){
- _nrInserted = 0;
- _varray2.clear();// empty the array
-
- double t;
- double tolerance = 0.0000001; // very low tolerance factor
-
- glm::dvec3 mid;
- glm::dvec3 interpolated;
- glm::dvec3 current;
- glm::dvec3 next;
-
- for (int i = 0; i < 4; i++){
- int k = (i + 1 > 3) ? 0 : i + 1;
- current = bounds[i];
- next = bounds[k];
- if (H[i] == false){ // If point is non-interceptive, project it.
- insertPoint(_varray2, orthogonalProjection(current), glm::vec4(1));
- }
- if (H[i] == true && H[i + 1] == false){ // current point is interceptive, next is not
- // find outer most point for interpolation
- mid = bisection(current, next, tolerance);
- for (int j = 1; j <= _isteps; j++){
- t = ((double)j / _isteps);
- // TODO: change the interpolate scheme to place points not on a straight line but instead
- // using either slerp or some other viable method (goal: eliminate checkForIntercept -method)
- interpolated = interpolate(current, mid, t);
- _interceptVector = (j < _isteps) ? checkForIntercept(interpolated) : orthogonalProjection(interpolated);
- insertPoint(_varray2, _interceptVector, col_sq);
- }
- }
- if (H[i] == false && H[i+1] == true){ // current point is non-interceptive, next is
- mid = bisection(next, current, tolerance);
- for (int j = 1; j <= _isteps; j++){
- t = ((double)j / _isteps);
- interpolated = interpolate(mid, next, t);
- _interceptVector = (j > 1) ? checkForIntercept(interpolated) : orthogonalProjection(interpolated);
- insertPoint(_varray2, _interceptVector, col_sq);
- }
- }
- if (H[i] == true && H[i + 1] == true){ // both points intercept
- for (int j = 0; j <= _isteps; j++){
- t = ((double)j / _isteps);
- interpolated = interpolate(current, next, t);
- _interceptVector = checkForIntercept(interpolated);
- insertPoint(_varray2, _interceptVector, col_sq);
- }
- }
- }
- // only if new points are inserted are we interested in rebuilding the
- // vbo. Note that this can be optimized but is left as is for now.
- if (_nrInserted == 0){
- _rebuild = false;
- }else{
- _rebuild = true;
- //update size etc;
- _vtotal[1] = _nrInserted;
- _isize[1] = _nrInserted;
- _vsize[1] = _varray2.size();
- _iarray1[1] = new int[_isize[1]];
- for (int i = 0; i < _isize[1]; i++)
- _iarray1[1][i] = i;
- }
-
-}
-
void RenderableFov::updateData(){
- glBindBuffer(GL_ARRAY_BUFFER, _vboID[0]);
- glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[0] * sizeof(GLfloat), &_varray1[0]);
-
- if (!_rebuild){
- glBindBuffer(GL_ARRAY_BUFFER, _vboID[1]);
- glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[1] * sizeof(GLfloat), &_varray2[0]);
- }else{
- glBindVertexArray(_vaoID[1]);
- glBindBuffer(GL_ARRAY_BUFFER, _vboID[1]);
- glBufferData(GL_ARRAY_BUFFER, _vsize[1] * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
- glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[1] * sizeof(GLfloat), &_varray2[0]);
-
- GLsizei st = sizeof(GLfloat) * _stride[0];
-
- glEnableVertexAttribArray(0);
- glEnableVertexAttribArray(1);
- glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
- glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iboID[1]);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize[1] * sizeof(int), _iarray1[1], GL_STATIC_DRAW);
- glBindVertexArray(0);
- }
+ glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
}
void RenderableFov::render(const RenderData& data){
- assert(_programObject);
_programObject->activate();
+
// fetch data
+ glm::mat4 tmat = glm::mat4(1);
+
glm::mat4 transform(1);
glm::mat4 tmp = glm::mat4(1);
+ glm::mat4 rot = glm::rotate(transform, 90.f, glm::vec3(0, 1, 0));
+
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
tmp[i][j] = _stateMatrix[i][j];
}
}
-
+ transform = tmp*rot;
+
// setup the data to the shader
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(_programObject, &data.camera, data.position);
- // update only when time progresses.
- if (_oldTime != _time){
- std::string shape, instrument;
- std::vector bounds;
- glm::dvec3 boresight;
-
- // fetch data for specific instrument (shape, boresight, bounds etc)
- bool found = openspace::SpiceManager::ref().getFieldOfView(_instrumentID, shape, instrument, boresight, bounds);
- if (!found) LERROR("Could not locate instrument"); // fixlater
- float size = 4 * sizeof(float);
- int indx = 0;
+ //boresight vector
+ std::string shape, name;
+ shape.resize(32);
+ name.resize(32);
+ std::vector bounds;
+ glm::dvec3 boresight;
- // set target based on visibility to specific instrument,
- // from here on the _fovTarget is the target for all spice functions.
- std::string potential[5] = { "Jupiter", "Io", "Europa", "Ganymede", "Callisto" };
- _fovTarget = potential[0]; //default
- for (int i = 0; i < 5; i++){
- _withinFOV = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i],
- _spacecraft, _method,
- _aberrationCorrection, _time);
- if (_withinFOV){
- _fovTarget = potential[i];
- break;
- }
- }
-
- //somehow get target in there.
- //_targetNode = sceneGraphNode(_fovTarget);
- /*std::vector properties = _targetNode->subOwners();
- for (auto & element : properties) {
- std::cout << element->name() << std::endl;
- }*/
- //std::cout << _targetNode->renderable.hasProperty("PlanetGeometry") << std::endl;
+ bool found = openspace::SpiceManager::ref().getFieldOfView("NH_LORRI", shape, name, boresight, bounds);
+ float size = 4 * sizeof(float);
+ float *begin = &_varray[0];
- // for each FOV vector
- for (int i = 0; i < 4; i++){
- double targetEpoch;
- // compute surface intercept
- _interceptTag[i] = openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
- _frame, _method, _aberrationCorrection,
- _time, targetEpoch, bounds[i], ipoint, ivec);
- // if not found, use the orthogonal projected point
- if (!_interceptTag[i]) _projectionBounds[i] = orthogonalProjection(bounds[i]);
-
+ glm::vec4 origin(0);
+ glm::vec4 col_start(1.00, 0.89, 0.00, 1);
+ glm::vec4 col_end(1.00, 0.29, 0.00, 1);
+ glm::vec4 bsight_t(boresight[0], boresight[1], boresight[2], data.position[3]-3);
- // VBO1 : draw vectors representing outer points of FOV.
- if (_interceptTag[i]){
- _interceptVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(ivec[0], ivec[1], ivec[2]);
- _interceptVector[3] += 3;
- // INTERCEPTIONS
- memcpy(&_varray1[indx], glm::value_ptr(origin), size);
- indx += 4;
- memcpy(&_varray1[indx], glm::value_ptr(col_start), size);
- indx += 4;
- memcpy(&_varray1[indx], glm::value_ptr(_interceptVector.vec4()), size);
- indx += 4;
- memcpy(&_varray1[indx], glm::value_ptr(col_end), size);
- indx += 4;
- }
- else if (_withinFOV){
- // FOV LARGER THAN OBJECT
- memcpy(&_varray1[indx], glm::value_ptr(origin), size);
- indx += 4;
- memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0,0,1,1)), size);
- indx += 4;
- memcpy(&_varray1[indx], glm::value_ptr(_projectionBounds[i].vec4()), size);
- indx += 4;
- memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0, 0.5, 0.7, 1)), size);
- indx += 4;
- }else{
- glm::vec4 corner(bounds[i][0], bounds[i][1], bounds[i][2], data.position[3]);
- corner = tmp*corner;
- // "INFINITE" FOV
- memcpy(&_varray1[indx], glm::value_ptr(origin), size);
- indx += 4;
- memcpy(&_varray1[indx], glm::value_ptr(col_gray), size);
- indx += 4;
- memcpy(&_varray1[indx], glm::value_ptr(corner), size);
- indx += 4;
- memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
- indx += 4;
- }
- }
- _interceptTag[4] = _interceptTag[0]; // 0 & 5 same point
- // Draw surface square!
- fovProjection(_interceptTag, bounds);
- updateData();
- }
- _oldTime = _time;
-
- glLineWidth(1.f);
- glBindVertexArray(_vaoID[0]);
- glDrawArrays(_mode, 0, _vtotal[0]);
+ float sc = 2.2;
+ glm::vec4 corner1(bounds[0][0], bounds[0][1], bounds[0][2], data.position[3]-sc);
+ memcpy(begin, glm::value_ptr(origin), size);
+ memcpy(begin + 4, glm::value_ptr(col_start), size);
+ memcpy(begin + 8, glm::value_ptr(corner1), size);
+ memcpy(begin + 12, glm::value_ptr(col_end), size);
+
+ glm::vec4 corner2(bounds[1][0], bounds[1][1], bounds[1][2], data.position[3]-sc);
+ memcpy(begin + 16, glm::value_ptr(origin), size);
+ memcpy(begin + 20, glm::value_ptr(col_start), size);
+ memcpy(begin + 24, glm::value_ptr(corner2), size);
+ memcpy(begin + 28, glm::value_ptr(col_end), size);
+
+ glm::vec4 corner3(bounds[2][0], bounds[2][1], bounds[2][2], data.position[3]-sc);
+ memcpy(begin + 32, glm::value_ptr(origin), size);
+ memcpy(begin + 36, glm::value_ptr(col_start), size);
+ memcpy(begin + 40, glm::value_ptr(corner3), size);
+ memcpy(begin + 44, glm::value_ptr(col_end), size);
+
+ glm::vec4 corner4(bounds[3][0], bounds[3][1], bounds[3][2], data.position[3]-sc);
+ memcpy(begin + 48, glm::value_ptr(origin), size);
+ memcpy(begin + 52, glm::value_ptr(col_start), size);
+ memcpy(begin + 56, glm::value_ptr(corner4), size);
+ memcpy(begin + 60, glm::value_ptr(col_end), size);
+
+ updateData();
+
+ glBindVertexArray(_vaoID);
+ glDrawArrays(GL_LINE_STRIP, 0, _vtotal);
glBindVertexArray(0);
- //render points
- glPointSize(2.f);
- glBindVertexArray(_vaoID[0]);
- glDrawArrays(GL_POINTS, 0, _vtotal[0]);
- glBindVertexArray(0);
-
- //second vbo
- glLineWidth(2.f);
- glBindVertexArray(_vaoID[1]);
- glDrawArrays(GL_LINE_LOOP, 0, _vtotal[1]);
- glBindVertexArray(0);
-
- /*glPointSize(5.f);
- glBindVertexArray(_vaoID2);
- glDrawArrays(GL_POINTS, 0, _vtotal2);
- glBindVertexArray(0);
- */
_programObject->deactivate();
}
void RenderableFov::update(const UpdateData& data){
+
double lightTime;
_time = data.time;
_delta = data.delta;
- openspace::SpiceManager::ref().getPositionTransformMatrix(_instrumentID, _frame, data.time, _stateMatrix);
+
+ openspace::SpiceManager::ref().getPositionTransformMatrix("NH_SPACECRAFT", "GALACTIC", data.time, _stateMatrix);
}
void RenderableFov::loadTexture()
@@ -500,7 +244,7 @@ void RenderableFov::loadTexture()
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
- _texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
+ _texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
diff --git a/src/rendering/renderablepath.cpp b/src/rendering/renderablepath.cpp
index bc39784d85..9513f9c783 100644
--- a/src/rendering/renderablepath.cpp
+++ b/src/rendering/renderablepath.cpp
@@ -45,193 +45,209 @@ namespace {
}
#define DEBUG
namespace openspace{
- RenderablePath::RenderablePath(const ghoul::Dictionary& dictionary)
- : Renderable(dictionary)
- , _colorTexturePath("colorTexture", "Color Texture")
- , _programObject(nullptr)
- , _texture(nullptr)
- , _vaoID(0)
- , _vBufferID(0)
- , _iBufferID(0)
- , _mode(GL_LINE_STRIP){
+RenderablePath::RenderablePath(const ghoul::Dictionary& dictionary)
+ : Renderable(dictionary)
+ , _programObject(nullptr)
+ , _vaoID(0)
+ , _vBufferID(0)
+ , _iBufferID(0)
+{
- assert(dictionary.getValue(keyBody, _target));
- assert(dictionary.getValue(keyObserver, _observer));
- assert(dictionary.getValue(keyFrame, _frame));
- /*assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic));
- assert(dictionary.getValue(keyEarthOrbitRatio, _ratio));
- assert(dictionary.getValue(keyDayLength, _day));//not used now, will be though.
- // values in modfiles set from here*/
- // http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html
+ dictionary.getValue(keyBody, _target);
+ dictionary.getValue(keyObserver, _observer);
+ dictionary.getValue(keyFrame, _frame);
- //white is default col
- if (!dictionary.getValue(keyColor, _c)){
- _c = glm::vec3(0.0);
- }
- else{
- _r = 1 / _c[0];
- _g = 1 / _c[1];
- _b = 1 / _c[2];
- }
+ // not used now, will be though.
+ // dictionary.getValue(keyTropicalOrbitPeriod, _tropic);
+ // dictionary.getValue(keyEarthOrbitRatio, _ratio);
+ // dictionary.getValue(keyDayLength, _day);
+
+ // values in modfiles set from here
+ // http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html
+
+ // white is default col
+ if (!dictionary.getValue(keyColor, _c)){
+ _c = glm::vec3(0.0);
}
- void RenderablePath::fullYearSweep(){
- double lightTime = 0.0;
- SpiceManager::ref().getETfromDate("2006 jan 20 19:00:00", _time);
+ else{
+ _r = 1 / _c[0];
+ _g = 1 / _c[1];
+ _b = 1 / _c[2];
+ }
+}
+bool RenderablePath::fullYearSweep(){
+ double lightTime = 0.0;
+ SpiceManager::ref().getETfromDate("2006 jan 20 19:00:00", _time);
- // -------------------------------------- ^ this has to be simulation start-time, not passed in here though --
- double et2 = 0;
- //SpiceManager::ref().getETfromDate("2008 apr 01 00:00:00", et2);
- //psc nhpos, nhvel;
- //SpiceManager::ref().getTargetState("NEW HORIZONS", "SUN", "J2000", "LT+S", et2, _pscpos, _pscvel, lightTime);
+ std::cout << _time << std::endl;
- double et = _time;
- int segments = 200000;
- _increment = 86400;
+ // -------------------------------------- ^ this has to be simulation start-time, not passed in here though --
+ //SpiceManager::ref().getETfromDate("2008 apr 01 00:00:00", et2);
+ //psc nhpos, nhvel;
+ //SpiceManager::ref().getTargetState("NEW HORIZONS", "SUN", "J2000", "LT+S", et2, _pscpos, _pscvel, lightTime);
- _isize = (segments + 2);
- _vsize = (segments + 2);
- _iarray = new int[_isize];
+ double et = _time;
+ int segments = 200000;
+ _increment = 86400;
- int indx = 0;
- for (int i = 0; i < segments + 1; i++){
- SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", et, _pscpos, _pscvel, lightTime);
- if (_pscpos[0] != 0 && _pscpos[1] != 0 && _pscpos[2] != 0 && _pscpos[3] != 1){
- _pscpos[3] += 3;
- _varray.push_back(_pscpos[0]);
- _varray.push_back(_pscpos[1]);
- _varray.push_back(_pscpos[2]);
- _varray.push_back(_pscpos[3]);
+ _isize = (segments + 2);
+ _vsize = (segments + 2);
+ _iarray.clear();
+
+ int indx = 0;
+ for (int i = 0; i < segments + 1; i++){
+ std::cout << i << std::endl;
+ bool gotData = SpiceManager::ref().getTargetPosition(_target, _observer, _frame, "LT+S", et, _pscpos, lightTime);
+
+#ifndef NDEBUG
+ if (!gotData) {
+ LERROR("Could not fetch data from spice!");
+ return false;
+ }
+#endif
+
+ if (_pscpos[0] != 0 && _pscpos[1] != 0 && _pscpos[2] != 0 && _pscpos[3] != 1){
+ _pscpos[3] += 3;
+ _varray.push_back(_pscpos[0]);
+ _varray.push_back(_pscpos[1]);
+ _varray.push_back(_pscpos[2]);
+ _varray.push_back(_pscpos[3]);
#ifndef DEBUG
- _varray.push_back(1.f - ((double)i / _tropic * _r));
- _varray.push_back(1.f - ((double)i / _tropic * _g));
- _varray.push_back(1.f - ((double)i / _tropic * _b));
- _varray.push_back(1.f - ((double)i / _tropic));
+ _varray.push_back(1.f - ((double)i / _tropic * _r));
+ _varray.push_back(1.f - ((double)i / _tropic * _g));
+ _varray.push_back(1.f - ((double)i / _tropic * _b));
+ _varray.push_back(1.f - ((double)i / _tropic));
#else
- _varray.push_back(1.f);
- _varray.push_back(1.f);
- _varray.push_back(1.f);
- _varray.push_back(0.5f);
+ _varray.push_back(1.f);
+ _varray.push_back(1.f);
+ _varray.push_back(1.f);
+ _varray.push_back(0.5f);
#endif
- indx++;
- _iarray[indx] = indx;
- }
- else{
- std::string date;
- SpiceManager::ref().getDateFromET(et, date);
- std::cout << "STOPPED AT: " << date << std::endl;
- break;
- }
- et += _increment;
+ indx++;
+ _iarray.push_back(indx);
}
- _stride = 8;
- _vsize = _varray.size();
- _vtotal = static_cast(_vsize / _stride);
- }
-
- RenderablePath::~RenderablePath(){
- deinitialize();
- }
-
- bool RenderablePath::isReady() const {
- return _programObject != nullptr;
- }
-
- bool RenderablePath::initialize(){
- bool completeSuccess = true;
- if (_programObject == nullptr)
- completeSuccess
- &= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
-
- //TEXTURES DISABLED FOR NOW
- //loadTexture();
- completeSuccess &= (_texture != nullptr);
-
- fullYearSweep();
-
- // Initialize and upload to graphics card
- glGenVertexArrays(1, &_vaoID);
- glGenBuffers(1, &_vBufferID);
- glGenBuffers(1, &_iBufferID);
-
- glBindVertexArray(_vaoID);
- glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
- glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
- glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
-
- GLsizei st = sizeof(GLfloat) * _stride;
-
- glEnableVertexAttribArray(0);
- glEnableVertexAttribArray(1);
- glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
- glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
-
- glBindVertexArray(0);
-
- return completeSuccess;
- }
-
- bool RenderablePath::deinitialize(){
- delete _texture;
- _texture = nullptr;
- return true;
- }
-
- void RenderablePath::render(const RenderData& data){
- assert(_programObject);
- _programObject->activate();
-
- // fetch data
- psc currentPosition = data.position;
- psc campos = data.camera.position();
- glm::mat4 camrot = data.camera.viewRotationMatrix();
- // PowerScaledScalar scaling = camera->scaling();
- PowerScaledScalar scaling = glm::vec2(1, -6);
-
- glm::mat4 transform = glm::mat4(1);
-
- // setup the data to the shader
- //_programObject->setUniform("objectVelocity", pscvel.vec4());
- _programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
- _programObject->setUniform("ModelTransform", transform);
- setPscUniforms(_programObject, &data.camera, data.position);
-
- /* glBindVertexArray(_vaoID);
- glDrawArrays(_mode, 0, _vtotal);
- glBindVertexArray(0);
- */
- glPointSize(2.f);
-
- glBindVertexArray(_vaoID);
- glDrawArrays(GL_POINTS, 0, _vtotal);
- glBindVertexArray(0);
-
- _programObject->deactivate();
- }
-
- void RenderablePath::update(const UpdateData& data){
- double lightTime;
- _time = data.time;
- _delta = data.delta;
- int newhorizons = 0;
-
- SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", data.time, _pscpos, _pscvel, lightTime);
- }
-
-
- void RenderablePath::loadTexture()
- {
- delete _texture;
- _texture = nullptr;
- if (_colorTexturePath.value() != "") {
- _texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
- if (_texture) {
- LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
- _texture->uploadTexture();
- }
+ else{
+ std::string date;
+ SpiceManager::ref().getDateFromET(et, date);
+ std::cout << "STOPPED AT: " << date << std::endl;
+ break;
}
+ et += _increment;
}
+ _stride = 8;
+ _vsize = _varray.size();
+ _vtotal = static_cast(_vsize / _stride);
+ return true;
+}
+
+RenderablePath::~RenderablePath(){
+ deinitialize();
+}
+
+bool RenderablePath::isReady() const {
+ bool ready = true;
+ ready &= (_programObject != nullptr);
+ return ready;
+}
+
+
+bool RenderablePath::initialize(){
+
+ if (_target.empty() || _observer.empty() || _frame.empty()) {
+ LERROR("The following keys need to be set in the Dictionary. Cannot initialize!");
+ LERROR(keyBody << ": " << _target);
+ LERROR(keyObserver << ": " << _observer);
+ LERROR(keyFrame << ": " << _frame);
+ return false;
+ }
+ // Does checking if can fetch spice data (debug mode only)
+ if (!fullYearSweep())
+ return false;
+
+ // If the programobject is fetched after the string checking, then
+ // the isReady function will properly reflect the state of this object
+ // -- jonasstrandstedt
+ bool completeSuccess = true;
+ if (_programObject == nullptr)
+ completeSuccess
+ &= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
+
+ // Initialize and upload to graphics card
+ glGenVertexArrays(1, &_vaoID);
+ glGenBuffers(1, &_vBufferID);
+ glGenBuffers(1, &_iBufferID);
+
+ glBindVertexArray(_vaoID);
+ glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
+ glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
+ glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
+
+ GLsizei st = sizeof(GLfloat) * _stride;
+
+ glEnableVertexAttribArray(0);
+ glEnableVertexAttribArray(1);
+ glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
+ glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray.data(), GL_STATIC_DRAW);
+
+ glBindVertexArray(0);
+
+ return completeSuccess;
+}
+
+bool RenderablePath::deinitialize(){
+ glDeleteVertexArrays(1, &_vaoID);
+ glDeleteBuffers(1, &_vBufferID);
+ glDeleteBuffers(1, &_iBufferID);
+ return true;
+}
+
+void RenderablePath::render(const RenderData& data){
+ _programObject->activate();
+
+ // fetch data
+ psc currentPosition = data.position;
+ psc campos = data.camera.position();
+ glm::mat4 camrot = data.camera.viewRotationMatrix();
+ // PowerScaledScalar scaling = camera->scaling();
+ //PowerScaledScalar scaling = glm::vec2(1, -6);
+
+ glm::mat4 transform = glm::mat4(1);
+
+ // setup the data to the shader
+ //_programObject->setUniform("objectVelocity", pscvel.vec4());
+ _programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
+ _programObject->setUniform("ModelTransform", transform);
+ setPscUniforms(_programObject, &data.camera, data.position);
+
+/* glBindVertexArray(_vaoID);
+ glDrawArrays(GL_LINE_STRIP, 0, _vtotal);
+ glBindVertexArray(0);
+*/
+ glPointSize(2.f);
+
+ glBindVertexArray(_vaoID);
+ glDrawArrays(GL_POINTS, 0, _vtotal);
+ glBindVertexArray(0);
+
+ _programObject->deactivate();
+}
+
+void RenderablePath::update(const UpdateData& data){
+#ifndef NDEBUG
+ if (_target.empty() || _observer.empty() || _frame.empty())
+ return;
+#endif
+ double lightTime;
+
+ _time = data.time;
+ _delta = data.delta;
+
+ SpiceManager::ref().getTargetState(_target, _observer, _frame, "LT+S", data.time, _pscpos, _pscvel, lightTime);
+}
+
+
}
\ No newline at end of file
diff --git a/src/rendering/renderableplane.cpp b/src/rendering/renderableplane.cpp
index a091581580..a1b60246ff 100644
--- a/src/rendering/renderableplane.cpp
+++ b/src/rendering/renderableplane.cpp
@@ -53,6 +53,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
, _shader(nullptr)
, _texture(nullptr)
, _quad(0)
+ , _vertexPositionBuffer(0)
{
dictionary.getValue("Size", _size);
@@ -87,7 +88,6 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
if (success)
_texturePath = findPath(texturePath);
-
addProperty(_texturePath);
_texturePath.onChange(std::bind(&RenderablePlane::loadTexture, this));
@@ -95,10 +95,16 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
}
RenderablePlane::~RenderablePlane() {
+ deinitialize();
}
bool RenderablePlane::isReady() const {
- return _shader != nullptr;
+ bool ready = true;
+ if (!_shader)
+ ready &= false;
+ if(!_texture)
+ ready &= false;
+ return ready;
}
bool RenderablePlane::initialize() {
@@ -108,8 +114,6 @@ bool RenderablePlane::initialize() {
// ============================
const GLfloat size = _size[0];
const GLfloat w = _size[1];
- LDEBUG("size:" << size);
- LDEBUG("w:" << w);
const GLfloat vertex_data[] = { // square of two triangles (sigh)
// x y z w s t
-size, -size, 0.0f, w, 0,1,
@@ -120,11 +124,10 @@ bool RenderablePlane::initialize() {
size, size, 0.0f, w, 1, 0,
};
- GLuint vertexPositionBuffer;
glGenVertexArrays(1, &_quad); // generate array
glBindVertexArray(_quad); // bind array
- glGenBuffers(1, &vertexPositionBuffer); // generate buffer
- glBindBuffer(GL_ARRAY_BUFFER, vertexPositionBuffer); // bind buffer
+ glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
+ glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast(0));
@@ -133,25 +136,23 @@ bool RenderablePlane::initialize() {
OsEng.ref().configurationManager().getValue("PlaneProgram", _shader);
- if (!_shader)
- return false;
-
loadTexture();
- return true;
+ return isReady();
}
bool RenderablePlane::deinitialize() {
+ glDeleteVertexArrays(1, &_quad);
+ _quad = 0;
+ glDeleteBuffers(1, &_vertexPositionBuffer);
+ _vertexPositionBuffer = 0;
+ if(_texture)
+ delete _texture;
return true;
}
void RenderablePlane::render(const RenderData& data) {
- if (!_shader)
- return;
- if (!_texture)
- return;
-
glm::mat4 transform = glm::mat4(1.0);
if (_billboard)
transform = glm::inverse(data.camera.viewRotationMatrix());
@@ -183,7 +184,7 @@ void RenderablePlane::loadTexture()
LDEBUG("loadTexture");
if (_texturePath.value() != "") {
LDEBUG("loadTexture2");
- ghoul::opengl::Texture* texture = ghoul::io::TextureReader::loadTexture(absPath(_texturePath));
+ ghoul::opengl::Texture* texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath));
if (texture) {
LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'");
texture->uploadTexture();
diff --git a/src/rendering/renderablesphericalgrid.cpp b/src/rendering/renderablesphericalgrid.cpp
index 92f9a5c1a4..46d0f29188 100644
--- a/src/rendering/renderablesphericalgrid.cpp
+++ b/src/rendering/renderablesphericalgrid.cpp
@@ -138,13 +138,28 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
RenderableSphericalGrid::~RenderableSphericalGrid(){
deinitialize();
+
+ // Delete not done in deinitialize because new is done in constructor
+ delete[] _varray;
+ delete[] _iarray;
}
bool RenderableSphericalGrid::isReady() const {
- return _gridProgram != nullptr;
+ bool ready = true;
+ ready &= (_gridProgram != nullptr);
+ return ready;
}
bool RenderableSphericalGrid::deinitialize(){
+ glDeleteVertexArrays(1,&_vaoID);
+ _vaoID = 0;
+
+ glDeleteBuffers(1,&_vBufferID);
+ _vBufferID = 0;
+
+ glDeleteBuffers(1,&_iBufferID);
+ _iBufferID = 0;
+
return true;
}
@@ -182,7 +197,6 @@ bool RenderableSphericalGrid::initialize(){
}
void RenderableSphericalGrid::render(const RenderData& data){
- assert(_gridProgram);
_gridProgram->activate();
glm::mat4 transform;
@@ -211,8 +225,8 @@ void RenderableSphericalGrid::render(const RenderData& data){
glBindVertexArray(0);
_gridProgram->deactivate();
-
}
+
void RenderableSphericalGrid::update(const UpdateData& data){
openspace::SpiceManager::ref().getPositionTransformMatrix("IAU_JUPITER", "GALACTIC", data.time, _parentMatrix);
diff --git a/src/rendering/renderabletrail.cpp b/src/rendering/renderabletrail.cpp
index 66833ce878..7c73b06497 100644
--- a/src/rendering/renderabletrail.cpp
+++ b/src/rendering/renderabletrail.cpp
@@ -22,6 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include
+
+#include
#include
#include
@@ -53,24 +55,27 @@ namespace {
}
//#define DEBUG
namespace openspace{
- RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
- : Renderable(dictionary)
- , _colorTexturePath("colorTexture", "Color Texture")
- , _programObject(nullptr)
- , _texture(nullptr)
- , _vaoID(0)
- , _vBufferID(0)
- , _iBufferID(0)
- , _mode(GL_LINE_STRIP){
+RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
+ : Renderable(dictionary)
+ , _colorTexturePath("colorTexture", "Color Texture")
+ , _programObject(nullptr)
+ , _texture(nullptr)
+ , _vaoID(0)
+ , _vBufferID(0)
+ , _iBufferID(0)
+ , _mode(GL_LINE_STRIP)
+{
- assert(dictionary.getValue(keyBody , _target));
- assert(dictionary.getValue(keyObserver , _observer));
- assert(dictionary.getValue(keyFrame , _frame));
- assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic));
- assert(dictionary.getValue(keyEarthOrbitRatio , _ratio));
- assert(dictionary.getValue(keyDayLength , _day));//not used now, will be though.
- // values in modfiles set from here
- // http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html
+ _successfullDictionaryFetch = true;
+ _successfullDictionaryFetch &= dictionary.getValue(keyBody, _target);
+ _successfullDictionaryFetch &= dictionary.getValue(keyObserver, _observer);
+ _successfullDictionaryFetch &= dictionary.getValue(keyFrame, _frame);
+ _successfullDictionaryFetch &= dictionary.getValue(keyTropicalOrbitPeriod, _tropic);
+ _successfullDictionaryFetch &= dictionary.getValue(keyEarthOrbitRatio, _ratio);
+ _successfullDictionaryFetch &= dictionary.getValue(keyDayLength, _day);
+
+ // values in modfiles set from here
+ // http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html
//white is default col
@@ -101,15 +106,11 @@ void RenderableTrail::fullYearSweep(){
_isize = (segments + 2);
_vsize = (segments + 2);
- _iarray = new int[_isize];
-
+ _iarray.clear();
+ //_iarray = new int[_isize];
+
for (int i = 0; i < segments+2; i++){
- /*if (_target == "NEW HORIZONS"){
- SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", _startTrail, _pscpos, _pscvel, lightTime);
- }
- else{*/
- SpiceManager::ref().getTargetState(_target, _observer, _frame, "NONE", et, _pscpos, _pscvel, lightTime);
- //}
+ SpiceManager::ref().getTargetState(_target, _observer, _frame, "LT+S", et, _pscpos, _pscvel, lightTime);
_pscpos[3] += 3;
for (int k = 0; k < 4; k++)
@@ -127,7 +128,8 @@ void RenderableTrail::fullYearSweep(){
_varray.push_back(1.f );
_varray.push_back(1.f );
#endif
- _iarray[i] = i;
+ //_iarray[i] = i;
+ _iarray.push_back(i);
if (i != 0) //very first point needs to be alllocated twice.
et -= _increment;
}
@@ -141,7 +143,9 @@ RenderableTrail::~RenderableTrail(){
}
bool RenderableTrail::isReady() const {
- return _programObject != nullptr;
+ bool ready = true;
+ ready &= (_programObject != nullptr);
+ return ready;
}
void RenderableTrail::sendToGPU(){
@@ -163,12 +167,25 @@ void RenderableTrail::sendToGPU(){
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray.data(), GL_STATIC_DRAW);
glBindVertexArray(0);
}
+
bool RenderableTrail::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);
+ LERROR(keyTropicalOrbitPeriod << ": " << _tropic);
+ LERROR(keyEarthOrbitRatio << ": " << _ratio);
+ LERROR(keyDayLength << ": " << _day);
+ return false;
+ }
+
bool completeSuccess = true;
if (_programObject == nullptr)
completeSuccess
@@ -178,8 +195,8 @@ bool RenderableTrail::initialize(){
//loadTexture();
completeSuccess &= (_texture != nullptr);
- _startTrail;
- SpiceManager::ref().getETfromDate("2007 feb 25 14:03:57.000", _startTrail);
+ // SpiceManager::ref().getETfromDate("2006 Aug 22 17:00:00", _startTrail);
+ SpiceManager::ref().getETfromDate("2007 feb 26 17:30:00", _startTrail);
_dtEt = _startTrail;
fullYearSweep();
@@ -189,15 +206,41 @@ bool RenderableTrail::initialize(){
}
bool RenderableTrail::deinitialize(){
- delete _texture;
+ if (_texture)
+ delete _texture;
_texture = nullptr;
+
+ glDeleteVertexArrays(1, &_vaoID);
+ glDeleteBuffers(1, &_vBufferID);
+ glDeleteBuffers(1, &_iBufferID);
return true;
}
+// Tried interpolation but then realised this still gives straight lines (latenight thing).
+// Not allowed Splines so therefore - query spice for each point (bah...)
+// From psc paper:
+/*
+psc pscInterpolate(psc p0, psc p1, float t){
+ assert(t >= 0 && t <= 1);
+
+ float s = (1.f - t)*p0[3] + t*p1[3];
+
+ float x = ((1.f - t)*p0[0] + t*p1[0]);
+ float y = ((1.f - t)*p0[1] + t*p1[1]);
+ float z = ((1.f - t)*p0[2] + t*p1[2]);
+
+ return PowerScaledCoordinate::PowerScaledCoordinate(x,y,z,s);
+}
+*/
+
void RenderableTrail::updateTrail(){
+#ifndef NDEBUG
+ if (!_successfullDictionaryFetch)
+ return;
+#endif
int m = _stride;
float *begin = &_varray[0];
- float *end = &_varray[_vsize - 1] + 1;
+ //float *end = &_varray[_vsize - 1] + 1;
// update only when time progresses
if (_oldTime != _time){
@@ -218,7 +261,7 @@ void RenderableTrail::updateTrail(){
// keep track of progression
_dtEt += _increment;
}
- //add current position
+ //add earths current position
memcpy(&_varray[0], glm::value_ptr(_pscpos.vec4()), 4 * sizeof(float));
_varray[4] = 1.f;
_varray[5] = 1.f;
@@ -236,7 +279,6 @@ void RenderableTrail::updateTrail(){
}
void RenderableTrail::render(const RenderData& data){
- assert(_programObject);
_programObject->activate();
// fetch data
@@ -270,7 +312,7 @@ void RenderableTrail::render(const RenderData& data){
void RenderableTrail::update(const UpdateData& data){
_time = data.time;
_delta = data.delta;
-
+
SpiceManager::ref().getTargetState(_target, _observer, _frame, "NONE", data.time, _pscpos, _pscvel, lightTime);
_pscpos[3] += 3; // KM to M
@@ -281,7 +323,7 @@ void RenderableTrail::loadTexture()
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
- _texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
+ _texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
diff --git a/src/rendering/renderablevolume.cpp b/src/rendering/renderablevolume.cpp
index fd4618d4f5..4f409281f1 100644
--- a/src/rendering/renderablevolume.cpp
+++ b/src/rendering/renderablevolume.cpp
@@ -294,7 +294,7 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string
// check if not a txt based texture
if ( ! hasExtension(filepath, "txt")) {
- ghoul::opengl::Texture* t = ghoul::io::TextureReader::loadTexture(f);
+ ghoul::opengl::Texture* t = ghoul::io::TextureReader::ref().loadTexture(f);
t->setWrapping(wrappingmode);
return t;
}
diff --git a/src/rendering/renderablevolumegl.cpp b/src/rendering/renderablevolumegl.cpp
index dd9df47c1b..2b343d44b3 100644
--- a/src/rendering/renderablevolumegl.cpp
+++ b/src/rendering/renderablevolumegl.cpp
@@ -50,6 +50,8 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
: RenderableVolume(dictionary)
, _transferFunctionName("")
, _volumeName("")
+ , _boxArray(0)
+ , _vertexPositionBuffer(0)
, _boxScaling(1.0, 1.0, 1.0)
, _w(0.f)
, _updateTransferfunction(false)
@@ -159,21 +161,18 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary)
RenderableVolumeGL::~RenderableVolumeGL() {
deinitialize();
- if(_volume)
- delete _volume;
- if(_transferFunctionFile)
- delete _transferFunctionFile;
- if(_transferFunction)
- delete _transferFunction;
}
bool RenderableVolumeGL::isReady() const {
- // @TODO needs a proper isReady definition --abock
- return true;
+ bool ready = true;
+ ready &= (_boxProgram != nullptr);
+ ready &= (_volume != nullptr);
+ ready &= (_transferFunction != nullptr);
+ return ready;
}
bool RenderableVolumeGL::initialize() {
- // TODO: fix volume an transferfunction names
+ // @TODO fix volume and transferfunction names --jonasstrandstedt
if(_filename != "") {
_volume = loadVolume(_filename, _hintsDictionary);
_volume->uploadTexture();
@@ -195,9 +194,6 @@ bool RenderableVolumeGL::initialize() {
_id = OsEng.renderEngine().abuffer()->addSamplerfile(_samplerFilename);
OsEng.configurationManager().getValue("RaycastProgram", _boxProgram);
- _MVPLocation = _boxProgram->uniformLocation("modelViewProjection");
- _modelTransformLocation = _boxProgram->uniformLocation("modelTransform");
- _typeLocation = _boxProgram->uniformLocation("volumeType");
// ============================
// GEOMETRY (box)
@@ -247,20 +243,33 @@ bool RenderableVolumeGL::initialize() {
size, -size, -size, _w,
size, -size, size, _w,
};
- GLuint vertexPositionBuffer;
+
glGenVertexArrays(1, &_boxArray); // generate array
glBindVertexArray(_boxArray); // bind array
- glGenBuffers(1, &vertexPositionBuffer); // generate buffer
- glBindBuffer(GL_ARRAY_BUFFER, vertexPositionBuffer); // bind buffer
+ glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
+ glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*4, reinterpret_cast(0));
glEnableVertexAttribArray(0);
- return true;
+ return isReady();
}
bool RenderableVolumeGL::deinitialize() {
- return true;
+ if (_volume)
+ delete _volume;
+ if (_transferFunctionFile)
+ delete _transferFunctionFile;
+ if (_transferFunction)
+ delete _transferFunction;
+ _volume = nullptr;
+ _transferFunctionFile = nullptr;
+ _transferFunction = nullptr;
+
+ glDeleteVertexArrays(1, &_boxArray);
+ glGenBuffers(1, &_vertexPositionBuffer);
+
+ return true;
}
void RenderableVolumeGL::render(const RenderData& data) {
@@ -287,7 +296,7 @@ void RenderableVolumeGL::render(const RenderData& data) {
currentPosition += _pscOffset; // Move box to model barycenter
_boxProgram->activate();
- _boxProgram->setUniform(_typeLocation, _id);
+ _boxProgram->setUniform("volumeType", _id);
_boxProgram->setUniform("modelViewProjection", data.camera.viewProjectionMatrix());
_boxProgram->setUniform("modelTransform", transform);
setPscUniforms(_boxProgram, &data.camera, currentPosition);
diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp
index 929efbd4c4..fd049ce3d9 100644
--- a/src/rendering/renderengine.cpp
+++ b/src/rendering/renderengine.cpp
@@ -107,6 +107,22 @@ int visualizeABuffer(lua_State* L) {
return 0;
}
+/**
+* \ingroup LuaScripts
+* visualizeABuffer(bool):
+* Toggle the visualization of the ABuffer
+*/
+int showRenderInformation(lua_State* L) {
+ int nArguments = lua_gettop(L);
+ if (nArguments != 1)
+ return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
+
+ const int type = lua_type(L, -1);
+ bool b = lua_toboolean(L, -1) != 0;
+ OsEng.renderEngine().toggleInfoText(b);
+ return 0;
+}
+
/**
* \ingroup LuaScripts
* visualizeABuffer(bool):
@@ -142,6 +158,14 @@ RenderEngine::RenderEngine()
RenderEngine::~RenderEngine()
{
+ if(_abuffer)
+ delete _abuffer;
+ _abuffer = nullptr;
+
+ if(_sceneGraph)
+ delete _sceneGraph;
+ _sceneGraph = nullptr;
+
delete _mainCamera;
if (_visualizer)
delete _visualizer;
@@ -162,13 +186,13 @@ bool RenderEngine::initialize()
OsEng.interactionHandler().setCamera(_mainCamera);
#ifdef GHOUL_USE_DEVIL
- ghoul::io::TextureReader::addReader(new ghoul::io::impl::TextureReaderDevIL);
+ ghoul::io::TextureReader::ref().addReader(new ghoul::io::impl::TextureReaderDevIL);
#endif // GHOUL_USE_DEVIL
#ifdef GHOUL_USE_FREEIMAGE
- ghoul::io::TextureReader::addReader(new ghoul::io::impl::TextureReaderFreeImage);
+ ghoul::io::TextureReader::ref().addReader(new ghoul::io::impl::TextureReaderFreeImage);
#endif // GHOUL_USE_FREEIMAGE
- ghoul::io::TextureReader::addReader(new ghoul::io::impl::TextureReaderCMAP);
+ ghoul::io::TextureReader::ref().addReader(new ghoul::io::impl::TextureReaderCMAP);
#if ABUFFER_IMPLEMENTATION == ABUFFER_FRAMEBUFFER
_abuffer = new ABufferFramebuffer();
@@ -498,6 +522,11 @@ void RenderEngine::toggleVisualizeABuffer(bool b) {
_visualizer->updateData(_d);
}
+
+void RenderEngine::toggleInfoText(bool b) {
+ _showInfo = b;
+}
+
SceneGraph* RenderEngine::sceneGraph()
{
// TODO custom assert (ticket #5)
@@ -586,6 +615,12 @@ scripting::ScriptEngine::LuaLibrary RenderEngine::luaLibrary() {
"bool",
"Toggles the visualization of the ABuffer"
},
+ {
+ "showRenderInformation",
+ &luascriptfunctions::showRenderInformation,
+ "bool",
+ "Toggles the showing of render information on-screen text"
+ },
{
"setPerformanceMeasurement",
&luascriptfunctions::setPerformanceMeasurement,
diff --git a/src/rendering/stars/renderableconstellationbounds.cpp b/src/rendering/stars/renderableconstellationbounds.cpp
index 4053ae44ac..7c0d85bd30 100644
--- a/src/rendering/stars/renderableconstellationbounds.cpp
+++ b/src/rendering/stars/renderableconstellationbounds.cpp
@@ -22,10 +22,15 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
+// openspace
#include
-
#include
+#include
+
+// ghoul
#include
+
+// std
#include
#define _USE_MATH_DEFINES
#include
@@ -82,10 +87,14 @@ RenderableConstellationBounds::RenderableConstellationBounds(
);
}
+RenderableConstellationBounds::~RenderableConstellationBounds() {
+ deinitialize();
+}
+
bool RenderableConstellationBounds::initialize() {
_program = ghoul::opengl::ProgramObject::Build("ConstellationBounds",
- "${SHADERS}/constellationbounds_vs.glsl",
- "${SHADERS}/constellationbounds_fs.glsl");
+ "${SHADERS}/modules/constellationbounds/constellationbounds_vs.glsl",
+ "${SHADERS}/modules/constellationbounds/constellationbounds_fs.glsl");
if (!_program)
return false;
_program->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ this->_programIsDirty = true; });
@@ -138,7 +147,7 @@ bool RenderableConstellationBounds::deinitialize() {
}
bool RenderableConstellationBounds::isReady() const {
- return (_vao != 0) && (_vbo != 0);
+ return (_vao != 0) && (_vbo != 0) && (_program != nullptr);
}
void RenderableConstellationBounds::render(const RenderData& data) {
diff --git a/src/rendering/stars/renderablestars.cpp b/src/rendering/stars/renderablestars.cpp
index 2f96dc7a79..4999fa468e 100644
--- a/src/rendering/stars/renderablestars.cpp
+++ b/src/rendering/stars/renderablestars.cpp
@@ -25,6 +25,7 @@
#include
#include
+#include
#include
#include
@@ -121,6 +122,10 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
_colorTexturePath.onChange([&]{ _colorTextureIsDirty = true; });
}
+RenderableStars::~RenderableStars() {
+ deinitialize();
+}
+
bool RenderableStars::isReady() const {
return (_program != nullptr) && (_fullData.size() > 0);
}
@@ -129,12 +134,9 @@ bool RenderableStars::initialize() {
bool completeSuccess = true;
_program = ghoul::opengl::ProgramObject::Build("Star",
- "${SHADERS}/star_vs.glsl",
- "${SHADERS}/star_fs.glsl",
- "${SHADERS}/star_ge.glsl");
- //_program = ghoul::opengl::ProgramObject::Build("Star",
- // "${SHADERS}/star_vs.glsl",
- // "${SHADERS}/star_fs.glsl");
+ "${SHADERS}/modules/stars/star_vs.glsl",
+ "${SHADERS}/modules/stars/star_fs.glsl",
+ "${SHADERS}/modules/stars/star_ge.glsl");
if (!_program)
return false;
_program->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; });
@@ -153,7 +155,8 @@ bool RenderableStars::deinitialize() {
delete _pointSpreadFunctionTexture;
_pointSpreadFunctionTexture = nullptr;
- delete _program;
+ if(_program)
+ delete _program;
_program = nullptr;
return true;
}
@@ -295,7 +298,7 @@ void RenderableStars::update(const UpdateData& data) {
delete _pointSpreadFunctionTexture;
_pointSpreadFunctionTexture = nullptr;
if (_pointSpreadFunctionTexturePath.value() != "") {
- _pointSpreadFunctionTexture = ghoul::io::TextureReader::loadTexture(absPath(_pointSpreadFunctionTexturePath));
+ _pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture(absPath(_pointSpreadFunctionTexturePath));
if (_pointSpreadFunctionTexture) {
LDEBUG("Loaded texture from '" << absPath(_pointSpreadFunctionTexturePath) << "'");
_pointSpreadFunctionTexture->uploadTexture();
@@ -309,7 +312,7 @@ void RenderableStars::update(const UpdateData& data) {
delete _colorTexture;
_colorTexture = nullptr;
if (_colorTexturePath.value() != "") {
- _colorTexture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
+ _colorTexture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_colorTexture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_colorTexture->uploadTexture();
diff --git a/src/scenegraph/scenegraph.cpp b/src/scenegraph/scenegraph.cpp
index 01da4f50d6..41fe7c642b 100644
--- a/src/scenegraph/scenegraph.cpp
+++ b/src/scenegraph/scenegraph.cpp
@@ -299,9 +299,6 @@ void SceneGraph::scheduleLoadSceneFile(const std::string& sceneDescriptionFilePa
}
void SceneGraph::clearSceneGraph() {
- for (SceneGraphNode* node : _nodes)
- node->deinitialize();
-
// deallocate the scene graph. Recursive deallocation will occur
delete _root;
_root = nullptr;
@@ -344,10 +341,6 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
std::string moduleDirectory(".");
dictionary.getValue(constants::scenegraph::keyPathScene, moduleDirectory);
- std::string commonDirectory(_defaultCommonDirectory);
- dictionary.getValue(constants::scenegraph::keyCommonFolder, commonDirectory);
- FileSys.registerPathToken(_commonModuleToken, commonDirectory);
-
// The scene path could either be an absolute or relative path to the description
// paths directory
std::string&& relativeCandidate = sceneDescriptionDirectory +
@@ -364,19 +357,8 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
return false;
}
- LDEBUG("Loading common module folder '" << commonDirectory << "'");
- loadModule(FileSys.pathByAppendingComponent(moduleDirectory, commonDirectory));
-
- Dictionary moduleDictionary;
- if (dictionary.getValue(constants::scenegraph::keyModules, moduleDictionary)) {
- std::vector keys = moduleDictionary.keys();
- std::sort(keys.begin(), keys.end());
- for (const std::string& key : keys) {
- std::string moduleFolder;
- if (moduleDictionary.getValue(key, moduleFolder))
- loadModule(FileSys.pathByAppendingComponent(moduleDirectory, moduleFolder));
- }
- }
+ // Load the modules/scenegraph nodes
+ loadModules(moduleDirectory, dictionary);
// TODO: Make it less hard-coded and more flexible when nodes are not found
Dictionary cameraDictionary;
@@ -477,6 +459,105 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
return true;
}
+void SceneGraph::loadModules(
+ const std::string& directory,
+ const ghoul::Dictionary& dictionary)
+{
+ // Struct containing dependencies and nodes
+ LoadMaps m;
+
+ // Get the common directory
+ std::string commonDirectory(_defaultCommonDirectory);
+ dictionary.getValue(constants::scenegraph::keyCommonFolder, commonDirectory);
+ FileSys.registerPathToken(_commonModuleToken, commonDirectory);
+
+ LDEBUG("Loading common module folder '" << commonDirectory << "'");
+
+ // Load common modules into LoadMaps struct
+ loadModule(m,FileSys.pathByAppendingComponent(directory, commonDirectory));
+
+ // Load the rest of the modules into LoadMaps struct
+ ghoul::Dictionary moduleDictionary;
+ if (dictionary.getValue(constants::scenegraph::keyModules, moduleDictionary)) {
+ std::vector keys = moduleDictionary.keys();
+ std::sort(keys.begin(), keys.end());
+ for (const std::string& key : keys) {
+ std::string moduleFolder;
+ if (moduleDictionary.getValue(key, moduleFolder)) {
+ loadModule(m,FileSys.pathByAppendingComponent(directory, moduleFolder));
+ }
+ }
+ }
+
+ // Load and construct scenegraphnodes from LoadMaps struct
+ loadNodes(SceneGraphNode::RootNodeName, m);
+
+ // Remove loaded nodes from dependency list
+ for(const auto& name: m.loadedNodes) {
+ m.dependencies.erase(name);
+ }
+
+ // Check to see what dependencies are not resolved.
+ for(auto& node: m.dependencies) {
+ LWARNING(
+ "'" << node.second << "'' not loaded, parent '"
+ << node.first << "' not defined!");
+ }
+}
+
+void SceneGraph::loadModule(LoadMaps& m,const std::string& modulePath) {
+ auto pos = modulePath.find_last_of(ghoul::filesystem::FileSystem::PathSeparator);
+ if (pos == modulePath.npos) {
+ LERROR("Bad format for module path: " << modulePath);
+ return;
+ }
+
+ std::string fullModule = modulePath + modulePath.substr(pos) + _moduleExtension;
+ LDEBUG("Loading nodes from: " << fullModule);
+
+ ghoul::Dictionary moduleDictionary;
+ ghoul::lua::loadDictionaryFromFile(fullModule, moduleDictionary);
+ std::vector keys = moduleDictionary.keys();
+ for (const std::string& key : keys) {
+ if (!moduleDictionary.hasValue(key)) {
+ LERROR("SceneGraphElement '" << key << "' is not a table in module '"
+ << fullModule << "'");
+ continue;
+ }
+
+ ghoul::Dictionary element;
+ std::string nodeName;
+ std::string parentName;
+
+ moduleDictionary.getValue(key, element);
+ element.setValue(constants::scenegraph::keyPathModule, modulePath);
+
+ element.getValue(constants::scenegraphnode::keyName, nodeName);
+ element.getValue(constants::scenegraphnode::keyParentName, parentName);
+
+ m.nodes[nodeName] = element;
+ m.dependencies.emplace(parentName,nodeName);
+ }
+}
+
+void SceneGraph::loadNodes(const std::string& parentName, LoadMaps& m) {
+ auto eqRange = m.dependencies.equal_range(parentName);
+ for (auto it = eqRange.first; it != eqRange.second; ++it) {
+ auto node = m.nodes.find((*it).second);
+ loadNode(node->second);
+ loadNodes((*it).second, m);
+ }
+ m.loadedNodes.emplace_back(parentName);
+}
+
+void SceneGraph::loadNode(const ghoul::Dictionary& dictionary) {
+ SceneGraphNode* node = SceneGraphNode::createFromDictionary(dictionary);
+ if(node) {
+ _allNodes.emplace(node->name(), node);
+ _nodes.push_back(node);
+ }
+}
+
void SceneGraph::loadModule(const std::string& modulePath)
{
auto pos = modulePath.find_last_of(ghoul::filesystem::FileSystem::PathSeparator);
diff --git a/src/scenegraph/scenegraphnode.cpp b/src/scenegraph/scenegraphnode.cpp
index e83d8acc2d..092dc9ffbb 100644
--- a/src/scenegraph/scenegraphnode.cpp
+++ b/src/scenegraph/scenegraphnode.cpp
@@ -153,9 +153,11 @@ bool SceneGraphNode::deinitialize()
{
LDEBUG("Deinitialize: " << name());
- delete _renderable;
+ if(_renderable)
+ delete _renderable;
_renderable = nullptr;
- delete _ephemeris;
+ if(_ephemeris)
+ delete _ephemeris;
_ephemeris = nullptr;
// deallocate the child nodes and delete them, iterate c++11 style
diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp
index 767016ec69..ecf18a9aa8 100644
--- a/src/scripting/scriptengine.cpp
+++ b/src/scripting/scriptengine.cpp
@@ -182,6 +182,10 @@ ScriptEngine::ScriptEngine()
{
}
+ScriptEngine::~ScriptEngine() {
+ deinitialize();
+}
+
bool ScriptEngine::initialize() {
LDEBUG("Adding base functions");
addBaseLibrary();
diff --git a/src/util/factorymanager.cpp b/src/util/factorymanager.cpp
index 1b5efaf030..b219a47cb1 100644
--- a/src/util/factorymanager.cpp
+++ b/src/util/factorymanager.cpp
@@ -48,12 +48,6 @@
// std
#include
-#include
-#include
-#include
-
-
-
namespace openspace {
FactoryManager* FactoryManager::_manager = nullptr;
@@ -68,20 +62,10 @@ void FactoryManager::initialize()
// TODO: This has to be moved into a sort of module structure (ab)
// Add Renderables
_manager->addFactory(new ghoul::TemplateFactory);
-
- //TODELETE
- _manager->factory()->registerClass(
- "RenderablePlanetProjection");
- _manager->factory()->registerClass(
- "RenderablePlanet");
- _manager->factory()->registerClass(
- "RenderableStars");
_manager->factory()->registerClass("RenderablePlanet");
_manager->factory()->registerClass("RenderableStars");
_manager->factory()->registerClass
("RenderableConstellationBounds");
- /*_manager->factory()->registerClass(
- "RenderableEphemeris");*/
//will replace ephemeris class soon...
_manager->factory()->registerClass(
"RenderablePath");
@@ -109,12 +93,6 @@ void FactoryManager::initialize()
_manager->addFactory(new ghoul::TemplateFactory);
_manager->factory()
->registerClass("SimpleSphere");
-
- // Add PlanetGeometryProjection
- _manager->addFactory(new ghoul::TemplateFactory);
- _manager->factory()
- ->registerClass("SimpleSphereProjection");
-
// Add ModelGeometry
_manager->addFactory(new ghoul::TemplateFactory);
diff --git a/src/util/powerscaledsphere.cpp b/src/util/powerscaledsphere.cpp
index 50ea2af28c..e89e347f78 100644
--- a/src/util/powerscaledsphere.cpp
+++ b/src/util/powerscaledsphere.cpp
@@ -40,7 +40,6 @@ PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segmen
: _vaoID(0)
, _vBufferID(0)
, _iBufferID(0)
- , _mode(GL_TRIANGLES)
, _isize(6 * segments * segments)
, _vsize((segments + 1) * (segments + 1))
, _varray(new Vertex[_vsize])
@@ -128,8 +127,13 @@ PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segmen
PowerScaledSphere::~PowerScaledSphere()
{
- delete[] _varray;
- delete[] _iarray;
+ if (_varray)
+ delete[] _varray;
+ if (_iarray)
+ delete[] _iarray;
+
+ _varray = 0;
+ _iarray = 0;
glDeleteBuffers(1, &_vBufferID);
glDeleteBuffers(1, &_iBufferID);
@@ -188,7 +192,7 @@ void PowerScaledSphere::render()
{
glBindVertexArray(_vaoID); // select first VAO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
- glDrawElements(_mode, _isize, GL_UNSIGNED_INT, 0);
+ glDrawElements(GL_TRIANGLES, _isize, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
}