mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 12:39:24 -05:00
Merge branch 'develop' into feature/downloadmanager
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -523,7 +523,7 @@ void RenderableFov::render(const RenderData& data) {
|
||||
_interceptTag[bounds.size()] = _interceptTag[0];
|
||||
|
||||
|
||||
if (!(_instrumentID == "NH_LORRI")) // image plane replaces fov square
|
||||
if (!(_instrumentID == "NH_LORRI") && !(_instrumentID == "ROS_NAVCAM-A")) // image plane replaces fov square
|
||||
fovProjection(_interceptTag, bounds);
|
||||
|
||||
updateData();
|
||||
@@ -537,7 +537,11 @@ void RenderableFov::render(const RenderData& data) {
|
||||
_time,
|
||||
position,
|
||||
lt);
|
||||
|
||||
pss length = position.length();
|
||||
if (length[0] < DBL_EPSILON) {
|
||||
drawFOV = false;
|
||||
return;
|
||||
}
|
||||
//if aimed 80 deg away from target, dont draw white square
|
||||
if (glm::dot(glm::normalize(aim), glm::normalize(position.vec3())) < 0.2){
|
||||
drawFOV = false;
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace {
|
||||
const std::string KeyMoving = "Moving";
|
||||
const std::string KeyTexture = "Texture";
|
||||
const std::string KeyName = "Name";
|
||||
const std::string KeyTarget = "DefaultTarget";
|
||||
const std::string GalacticFrame = "GALACTIC";
|
||||
const double REALLY_FAR = 99999999999;
|
||||
}
|
||||
@@ -61,11 +62,14 @@ RenderablePlaneProjection::RenderablePlaneProjection(const ghoul::Dictionary& di
|
||||
, _vertexPositionBuffer(0)
|
||||
, _name("ImagePlane")
|
||||
, _previousTime(0)
|
||||
, _moving(false)
|
||||
, _hasImage(false)
|
||||
{
|
||||
dictionary.getValue(KeySpacecraft, _spacecraft);
|
||||
dictionary.getValue(KeyInstrument, _instrument);
|
||||
dictionary.getValue(KeyMoving, _moving);
|
||||
dictionary.getValue(KeyName, _name);
|
||||
dictionary.getValue(KeyTarget, _defaultTarget);
|
||||
|
||||
std::string texturePath = "";
|
||||
bool success = dictionary.getValue(KeyTexture, _texturePath);
|
||||
@@ -103,7 +107,7 @@ bool RenderablePlaneProjection::initialize() {
|
||||
if (!_shader) return false;
|
||||
}
|
||||
|
||||
setTarget("JUPITER");
|
||||
setTarget(_defaultTarget);
|
||||
loadTexture();
|
||||
return isReady();
|
||||
}
|
||||
@@ -118,7 +122,10 @@ bool RenderablePlaneProjection::deinitialize() {
|
||||
}
|
||||
|
||||
void RenderablePlaneProjection::render(const RenderData& data) {
|
||||
|
||||
bool active = ImageSequencer2::ref().instrumentActive(_instrument);
|
||||
if (!_hasImage || (_moving && !active))
|
||||
return;
|
||||
|
||||
glm::mat4 transform = glm::mat4(1.0);
|
||||
|
||||
for (int i = 0; i < 3; i++){
|
||||
@@ -151,20 +158,21 @@ void RenderablePlaneProjection::update(const UpdateData& data) {
|
||||
|
||||
double time = data.time;
|
||||
const Image img = openspace::ImageSequencer2::ref().getLatestImageForInstrument(_instrument);
|
||||
|
||||
if (img.path == "")
|
||||
return;
|
||||
else
|
||||
_hasImage = true;
|
||||
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix(_target.frame, GalacticFrame, time, _stateMatrix);
|
||||
|
||||
double timePast = 0.0;
|
||||
if (img.path != "")
|
||||
{
|
||||
timePast = abs(img.startTime - _previousTime);
|
||||
}
|
||||
double timePast = abs(img.startTime - _previousTime);
|
||||
|
||||
std::string tex = _texturePath;
|
||||
if (img.path != "" && (_moving || _planeIsDirty))
|
||||
if (_moving || _planeIsDirty)
|
||||
updatePlane(img, time);
|
||||
|
||||
else if (img.path != "" && timePast > DBL_EPSILON) {
|
||||
else if (timePast > DBL_EPSILON) {
|
||||
_previousTime = time = img.startTime;
|
||||
updatePlane(img, time);
|
||||
}
|
||||
@@ -203,10 +211,12 @@ void RenderablePlaneProjection::updatePlane(const Image img, double currentTime)
|
||||
std::vector<glm::dvec3> bounds;
|
||||
glm::dvec3 boresight;
|
||||
|
||||
std::string target = "JUPITER"; //default
|
||||
if (!_moving) {
|
||||
target = findClosestTarget(currentTime);
|
||||
}
|
||||
std::string target = _defaultTarget;
|
||||
// Turned on if the plane should be attached to the closest target,
|
||||
// rather than the target specified in img
|
||||
//if (!_moving) {
|
||||
// target = findClosestTarget(currentTime);
|
||||
//}
|
||||
if (img.path != "")
|
||||
target = img.target;
|
||||
|
||||
|
||||
@@ -87,11 +87,13 @@ private:
|
||||
GLuint _vertexPositionBuffer;
|
||||
std::string _spacecraft;
|
||||
std::string _instrument;
|
||||
std::string _defaultTarget;
|
||||
|
||||
double _previousTime;
|
||||
target _target;
|
||||
std::string _name;
|
||||
bool _moving;
|
||||
bool _hasImage;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -101,8 +101,7 @@ std::string LabelParser::decode(std::string line){
|
||||
for (auto key : _fileTranslation){
|
||||
std::size_t value = line.find(key.first);
|
||||
if (value != std::string::npos){
|
||||
std::string toTranslate = line.substr(value);
|
||||
return _fileTranslation[toTranslate]->getTranslation()[0]; //lbls always 1:1 -> single value return.
|
||||
return _fileTranslation[key.first]->getTranslation()[0]; //lbls always 1:1 -> single value return.
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user