Merge branch 'develop' into feature/downloadmanager

This commit is contained in:
Alexander Bock
2015-06-22 13:39:54 +02:00
9 changed files with 147 additions and 99 deletions
+25 -4
View File
@@ -36,6 +36,8 @@ namespace {
const std::string keyObjFile = "ObjFile";
const int8_t CurrentCacheVersion = 3;
const std::string keyType = "Type";
const std::string keyName = "Name";
const std::string keySize = "Magnification";
}
namespace openspace {
@@ -67,12 +69,15 @@ ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary)
, _mode(GL_TRIANGLES)
{
setName("ModelGeometry");
using constants::scenegraphnode::keyName;
std::string name;
bool success = dictionary.getValue(keyName, name);
ghoul_assert(success, "Name tag was not present");
success = dictionary.getValue(keySize, _magnification);
if (!success)
_magnification = 4; // if not set, models will be 1:1000, feel free to change @AA
success = dictionary.getValue(keyObjFile, _file);
if (!success) {
LERROR("WaveFrontGeometry of '" << name << "' did not provide a key '"
@@ -95,11 +100,11 @@ void ModelGeometry::render() {
glBindVertexArray(0);
}
void ModelGeometry::changeRenderMode(const GLenum mode){
void ModelGeometry::changeRenderMode(const GLenum mode) {
_mode = mode;
}
bool ModelGeometry::initialize(RenderableModel* parent) {
bool ModelGeometry::initialize(Renderable* parent) {
_parent = parent;
PowerScaledScalar ps = PowerScaledScalar(1.0, 0.0); // will set proper bounding soon.
_parent->setBoundingSphere(ps);
@@ -138,7 +143,7 @@ void ModelGeometry::deinitialize() {
glDeleteBuffers(1, &_ibo);
}
bool ModelGeometry::loadObj(const std::string& filename){
bool ModelGeometry::loadObj(const std::string& filename) {
std::string cachedFile = "";
FileSys.cacheManager()->getCachedFile(filename, cachedFile, true);
@@ -225,5 +230,21 @@ bool ModelGeometry::loadCachedFile(const std::string& filename) {
}
}
bool ModelGeometry::getVertices(std::vector<Vertex>* vertexList) {
vertexList->clear();
for (auto v : _vertices)
vertexList->push_back(v);
return !(vertexList->empty());
}
bool ModelGeometry::getIndices(std::vector<int>* indexList) {
indexList->clear();
for (auto i : _indices)
indexList->push_back(i);
return !(indexList->empty());
}
} // namespace modelgeometry
} // namespace openspace
+57 -53
View File
@@ -1,26 +1,26 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* 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-2015 *
* *
* 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 __MODELGEOMETRY_H__
#define __MODELGEOMETRY_H__
@@ -31,43 +31,47 @@
namespace openspace {
namespace modelgeometry {
namespace modelgeometry {
class ModelGeometry : public properties::PropertyOwner {
public:
static ModelGeometry* createFromDictionary(const ghoul::Dictionary& dictionary);
class ModelGeometry : public properties::PropertyOwner {
public:
static ModelGeometry* createFromDictionary(const ghoul::Dictionary& dictionary);
ModelGeometry(const ghoul::Dictionary& dictionary);
virtual ~ModelGeometry();
virtual bool initialize(RenderableModel* parent);
virtual void deinitialize();
void render();
virtual bool loadModel(const std::string& filename) = 0;
void changeRenderMode(const GLenum mode);
struct Vertex {
GLfloat location[4];
GLfloat tex[2];
GLfloat normal[3];
};
protected:
RenderableModel* _parent;
struct Vertex {
GLfloat location[4];
GLfloat tex[2];
GLfloat normal[3];
};
ModelGeometry(const ghoul::Dictionary& dictionary);
virtual ~ModelGeometry();
virtual bool initialize(Renderable* parent);
virtual void deinitialize();
void render();
virtual bool loadModel(const std::string& filename) = 0;
void changeRenderMode(const GLenum mode);
bool getVertices(std::vector<Vertex>* vertexList);
bool getIndices(std::vector<int>* indexList);
bool loadObj(const std::string& filename);
bool loadCachedFile(const std::string& filename);
bool saveCachedFile(const std::string& filename);
GLuint _vaoID;
GLuint _vbo;
GLuint _ibo;
GLenum _mode;
protected:
Renderable* _parent;
std::vector<Vertex> _vertices;
std::vector<int> _indices;
std::string _file;
};
bool loadObj(const std::string& filename);
bool loadCachedFile(const std::string& filename);
bool saveCachedFile(const std::string& filename);
int _magnification;
} // namespace modelgeometry
GLuint _vaoID;
GLuint _vbo;
GLuint _ibo;
GLenum _mode;
std::vector<Vertex> _vertices;
std::vector<int> _indices;
std::string _file;
};
} // namespace modelgeometry
} // namespace openspace
#endif // __MODELGEOMETRY_H__
+7 -5
View File
@@ -274,7 +274,7 @@ void RenderableTrail::fullYearSweep(double time) {
double start = DBL_MIN;
double end = DBL_MAX;
if (intervalSet) {
getInterval(start, end);
intervalSet &= getInterval(start, end);
}
_increment = planetYear / _tropic;
@@ -284,10 +284,12 @@ void RenderableTrail::fullYearSweep(double time) {
psc pscPos;
_vertexArray.resize(segments+2);
for (int i = 0; i < segments+2; i++) {
//if (start > time)
// time = start;
//else if (end < time)
// time = end;
if (start > time && intervalSet) {
time = start;
}
else if (end < time && intervalSet) {
time = end;
}
SpiceManager::ref().getTargetPosition(_target, _observer, _frame, "NONE", time, pscPos, lightTime);
pscPos[3] += 3;
+13 -8
View File
@@ -43,7 +43,7 @@ WavefrontGeometry::WavefrontGeometry(const ghoul::Dictionary& dictionary)
loadObj(_file);
}
bool WavefrontGeometry::initialize(RenderableModel* parent) {
bool WavefrontGeometry::initialize(Renderable* parent) {
bool success = ModelGeometry::initialize(parent);
return success;
}
@@ -88,13 +88,18 @@ bool WavefrontGeometry::loadModel(const std::string& filename) {
// The _shapeCounts array stores for each shape, how many vertices that shape has
size_t currentPosition = 0;
size_t p = 0;
for (int i = 0; i < shapes.size(); ++i) {
for (int j = 0; j < shapes[i].mesh.positions.size() / 3; ++j) {
_vertices[j + currentPosition].location[0] = shapes[i].mesh.positions[3 * j + 0];
_vertices[j + currentPosition].location[1] = shapes[i].mesh.positions[3 * j + 1];
_vertices[j + currentPosition].location[2] = shapes[i].mesh.positions[3 * j + 2];
_vertices[j + currentPosition].location[3] = 4; // Temp size for the power scale coordinate.
// Could be defined per object as a dictionary key.
psc tmp;
for (int i = 0; i < shapes.size(); ++i) {
for (int j = 0; j < shapes[i].mesh.positions.size() / 3; ++j) {
tmp = PowerScaledCoordinate::CreatePowerScaledCoordinate(shapes[i].mesh.positions[3 * j + 0],
shapes[i].mesh.positions[3 * j + 1],
shapes[i].mesh.positions[3 * j + 2]
);
_vertices[j + currentPosition].location[0] = tmp[0];
_vertices[j + currentPosition].location[1] = tmp[1];
_vertices[j + currentPosition].location[2] = tmp[2];
_vertices[j + currentPosition].location[3] = tmp[3] + _magnification;
_vertices[j + currentPosition].normal[0] = shapes[i].mesh.normals[3 * j + 0];
_vertices[j + currentPosition].normal[1] = shapes[i].mesh.normals[3 * j + 1];
+13 -12
View File
@@ -29,22 +29,23 @@
namespace openspace {
class RenderableModel;
class RenderableModel;
class RenderableModelProjection;
namespace modelgeometry {
namespace modelgeometry {
class WavefrontGeometry : public ModelGeometry {
public:
WavefrontGeometry(const ghoul::Dictionary& dictionary);
class WavefrontGeometry : public ModelGeometry {
public:
WavefrontGeometry(const ghoul::Dictionary& dictionary);
bool initialize(RenderableModel* parent) override;
void deinitialize() override;
private:
bool loadModel(const std::string& filename);
};
bool initialize(Renderable* parent) override;
void deinitialize() override;
} // namespace modelgeometry
private:
bool loadModel(const std::string& filename);
};
} // namespace modelgeometry
} // namespace openspace
#endif // __WAVEFRONTOBJECT_H__