mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 18:51:17 -06:00
Merge branch 'feature/fieldlines' into feature/ABuffer
Conflicts: src/rendering/renderablevolumegl.cpp
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <ghoul/filesystem/file.h>
|
||||
|
||||
namespace openspace {
|
||||
struct LinePoint;
|
||||
|
||||
class RenderableFieldlines : public Renderable {
|
||||
public:
|
||||
@@ -46,7 +47,7 @@ public:
|
||||
virtual void update();
|
||||
|
||||
private:
|
||||
std::vector<std::vector<glm::vec3> > getFieldlinesData(std::string filename, ghoul::Dictionary hintsDictionary);
|
||||
std::vector<std::vector<LinePoint> > getFieldlinesData(std::string filename, ghoul::Dictionary hintsDictionary);
|
||||
|
||||
std::vector<ghoul::Dictionary> _hintsDictionaries;
|
||||
std::vector<std::string> _filenames;
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
|
||||
protected:
|
||||
ghoul::opengl::Texture* loadVolume(const std::string& filepath, const ghoul::Dictionary& hintsDictionary);
|
||||
glm::vec3 getVolumeOffset(const std::string& filepath, const ghoul::Dictionary& hintsDictionary);
|
||||
ghoul::RawVolumeReader::ReadHints readHints(const ghoul::Dictionary& dictionary);
|
||||
ghoul::opengl::Texture* loadTransferFunction(const std::string& filepath);
|
||||
|
||||
|
||||
@@ -35,10 +35,6 @@
|
||||
#include <ghoul/io/rawvolumereader.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
|
||||
namespace sgct_utils {
|
||||
class SGCTBox;
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderableVolumeGL: public RenderableVolume {
|
||||
@@ -71,8 +67,7 @@ private:
|
||||
|
||||
GLuint _boxArray;
|
||||
ghoul::opengl::ProgramObject *_boxProgram;
|
||||
sgct_utils::SGCTBox* _box;
|
||||
glm::vec3 _boxScaling;
|
||||
glm::vec3 _boxScaling, _boxOffset;
|
||||
GLint _MVPLocation, _modelTransformLocation, _typeLocation;
|
||||
|
||||
bool _updateTransferfunction;
|
||||
|
||||
@@ -34,6 +34,16 @@ namespace ccmc {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct LinePoint {
|
||||
glm::vec3 position;
|
||||
glm::vec4 color;
|
||||
|
||||
LinePoint(glm::vec3 pos, glm::vec4 col) {
|
||||
position = pos;
|
||||
color = col;
|
||||
}
|
||||
};
|
||||
|
||||
class KameleonWrapper {
|
||||
public:
|
||||
|
||||
@@ -59,16 +69,16 @@ public:
|
||||
float* getUniformSampledVectorValues(const std::string& xVar, const std::string& yVar,
|
||||
const std::string& zVar, glm::size3_t outDimensions);
|
||||
|
||||
std::vector<std::vector<glm::vec3> > getClassifiedFieldLines(const std::string& xVar,
|
||||
std::vector<std::vector<LinePoint> > getClassifiedFieldLines(const std::string& xVar,
|
||||
const std::string& yVar, const std::string& zVar,
|
||||
std::vector<glm::vec3> seedPoints, float stepSize);
|
||||
|
||||
std::vector<std::vector<glm::vec3> > getFieldLines(const std::string& xVar,
|
||||
std::vector<std::vector<LinePoint> > getFieldLines(const std::string& xVar,
|
||||
const std::string& yVar, const std::string& zVar,
|
||||
std::vector<glm::vec3> seedPoints, float stepSize, glm::vec3 color);
|
||||
std::vector<glm::vec3> seedPoints, float stepSize, glm::vec4 color);
|
||||
|
||||
std::vector<std::vector<glm::vec3> > getLorentzTrajectories(std::vector<glm::vec3> seedPoints,
|
||||
glm::vec3 color, float stepsize);
|
||||
std::vector<std::vector<LinePoint> > getLorentzTrajectories(std::vector<glm::vec3> seedPoints,
|
||||
glm::vec4 color, float stepsize);
|
||||
|
||||
private:
|
||||
std::vector<glm::vec3> traceCartesianFieldline(const std::string& xVar,
|
||||
@@ -80,7 +90,7 @@ private:
|
||||
|
||||
void getGridVariables(std::string& x, std::string& y, std::string& z);
|
||||
void progressBar(int current, int end);
|
||||
glm::vec3 classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEnd);
|
||||
glm::vec4 classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEnd);
|
||||
|
||||
ccmc::Model* _model;
|
||||
Model _type;
|
||||
|
||||
@@ -53,10 +53,8 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
|
||||
if(fieldline.hasKey("Hints"))
|
||||
fieldline.getValue("Hints", hintsDictionary);
|
||||
|
||||
// TODO Vectors of filenames and dictionaries
|
||||
_filenames.push_back(file);
|
||||
_hintsDictionaries.push_back(hintsDictionary);
|
||||
|
||||
} else
|
||||
LERROR("File not found!");
|
||||
}
|
||||
@@ -72,12 +70,11 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
|
||||
if (dictionary.hasKey("Shaders")) {
|
||||
ghoul::Dictionary shaderDictionary;
|
||||
if(dictionary.getValue("Shaders", shaderDictionary)) {
|
||||
if (shaderDictionary.hasKey("VertexShader")) {
|
||||
if (shaderDictionary.hasKey("VertexShader"))
|
||||
shaderDictionary.getValue("VertexShader", vshaderpath);
|
||||
}
|
||||
if (shaderDictionary.hasKey("FragmentShader")) {
|
||||
|
||||
if (shaderDictionary.hasKey("FragmentShader"))
|
||||
shaderDictionary.getValue("FragmentShader", fshaderpath);
|
||||
}
|
||||
|
||||
vshaderpath = findPath(vshaderpath);
|
||||
fshaderpath = findPath(fshaderpath);
|
||||
@@ -95,11 +92,10 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
|
||||
dictionary.getValue("UpdateOnSave", _programUpdateOnSave);
|
||||
}
|
||||
|
||||
setBoundingSphere(PowerScaledScalar::CreatePSS(5));
|
||||
setBoundingSphere(PowerScaledScalar::CreatePSS(5)); // FIXME a non-magic number perhaps
|
||||
}
|
||||
|
||||
RenderableFieldlines::~RenderableFieldlines() {
|
||||
|
||||
}
|
||||
|
||||
bool RenderableFieldlines::initialize() {
|
||||
@@ -107,28 +103,25 @@ bool RenderableFieldlines::initialize() {
|
||||
assert(_hintsDictionaries.size() != 0);
|
||||
|
||||
int prevEnd = 0;
|
||||
std::vector<glm::vec3> vertexData;
|
||||
std::vector<std::vector<glm::vec3> > fieldlinesData;
|
||||
std::vector<LinePoint> vertexData, seedPointsData;
|
||||
std::vector<std::vector<LinePoint> > fieldlinesData;
|
||||
glm::vec4 seedPointsColor = glm::vec4(1.0, 0.5, 0.0, 1.0);
|
||||
|
||||
for (int i = 0; i < _filenames.size(); ++i) {
|
||||
fieldlinesData = getFieldlinesData(_filenames[i], _hintsDictionaries[i]);
|
||||
|
||||
for (int j = 0; j < fieldlinesData.size(); j++) {
|
||||
for (int j = 0; j < fieldlinesData.size(); ++j) {
|
||||
_lineStart.push_back(prevEnd);
|
||||
_lineCount.push_back(fieldlinesData[j].size()/2.0);
|
||||
prevEnd = prevEnd + fieldlinesData[j].size()/2.0;
|
||||
|
||||
_lineCount.push_back(fieldlinesData[j].size());
|
||||
prevEnd = prevEnd + fieldlinesData[j].size();
|
||||
vertexData.insert( vertexData.end(), fieldlinesData[j].begin(), fieldlinesData[j].end());
|
||||
}
|
||||
// Give seedpoints a color for visualizing as GL_POINTS
|
||||
for (glm::vec3 seedPoint : _seedPoints) {
|
||||
seedPointsData.push_back(LinePoint(seedPoint, seedPointsColor));
|
||||
}
|
||||
}
|
||||
LDEBUG("Number of vertices : " << vertexData.size()/2.0);
|
||||
|
||||
// Give seedpoints a color for visualizing as GL_POINTS
|
||||
std::vector<glm::vec3> seedPointsData;
|
||||
for (int i = 0; i < _seedPoints.size(); ++i) {
|
||||
seedPointsData.push_back(_seedPoints[i]);
|
||||
seedPointsData.push_back(glm::vec3(1.0, 0.5, 0.0));
|
||||
}
|
||||
LDEBUG("Number of vertices : " << vertexData.size());
|
||||
|
||||
// ------ FIELDLINES -----------------
|
||||
GLuint vertexPositionBuffer;
|
||||
@@ -136,17 +129,17 @@ bool RenderableFieldlines::initialize() {
|
||||
glBindVertexArray(_VAO); // bind array
|
||||
glGenBuffers(1, &vertexPositionBuffer); // generate buffer
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertexPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, vertexData.size()*sizeof(glm::vec3), &vertexData.front(), GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, vertexData.size()*sizeof(LinePoint), &vertexData.front(), GL_STATIC_DRAW);
|
||||
|
||||
// Vertex positions
|
||||
GLuint vertexLocation = 0;
|
||||
glEnableVertexAttribArray(vertexLocation);
|
||||
glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, 2*sizeof(glm::vec3), reinterpret_cast<void*>(0));
|
||||
glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, sizeof(LinePoint), reinterpret_cast<void*>(0));
|
||||
|
||||
// Texture coordinates
|
||||
GLuint texcoordLocation = 1;
|
||||
glEnableVertexAttribArray(texcoordLocation);
|
||||
glVertexAttribPointer(texcoordLocation, 3, GL_FLOAT, GL_FALSE, 2*sizeof(glm::vec3), (void*)(sizeof(glm::vec3)));
|
||||
glVertexAttribPointer(texcoordLocation, 4, GL_FLOAT, GL_FALSE, sizeof(LinePoint), (void*)(sizeof(glm::vec3)));
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind buffer
|
||||
glBindVertexArray(0); //unbind array
|
||||
@@ -157,15 +150,15 @@ bool RenderableFieldlines::initialize() {
|
||||
glBindVertexArray(_seedpointVAO); // bind array
|
||||
glGenBuffers(1, &seedpointPositionBuffer); // generate buffer
|
||||
glBindBuffer(GL_ARRAY_BUFFER, seedpointPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, seedPointsData.size()*sizeof(glm::vec3), &seedPointsData.front(), GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, seedPointsData.size()*sizeof(LinePoint), &seedPointsData.front(), GL_STATIC_DRAW);
|
||||
|
||||
// Vertex positions
|
||||
glEnableVertexAttribArray(vertexLocation);
|
||||
glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, 2*sizeof(glm::vec3), reinterpret_cast<void*>(0));
|
||||
glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, sizeof(LinePoint), reinterpret_cast<void*>(0));
|
||||
|
||||
// Texture coordinates
|
||||
glEnableVertexAttribArray(texcoordLocation);
|
||||
glVertexAttribPointer(texcoordLocation, 3, GL_FLOAT, GL_FALSE, 2*sizeof(glm::vec3), (void*)(sizeof(glm::vec3)));
|
||||
glVertexAttribPointer(texcoordLocation, 4, GL_FLOAT, GL_FALSE, sizeof(LinePoint), (void*)(3*sizeof(float)));
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind buffer
|
||||
glBindVertexArray(0); //unbind array
|
||||
@@ -192,7 +185,6 @@ bool RenderableFieldlines::deinitialize() {
|
||||
}
|
||||
|
||||
void RenderableFieldlines::render(const Camera* camera, const psc& thisPosition) {
|
||||
|
||||
if(_update) {
|
||||
_update = false;
|
||||
safeShaderCompilation();
|
||||
@@ -203,11 +195,8 @@ void RenderableFieldlines::render(const Camera* camera, const psc& thisPosition)
|
||||
psc relative = thisPosition-camera->position();
|
||||
|
||||
transform = transform*camTransform;
|
||||
//transform = glm::translate(transform, relative.vec3());
|
||||
transform = glm::mat4(1.0);
|
||||
// transform = glm::scale(transform, glm::vec3(0.036*0.5*0.5));
|
||||
transform = glm::scale(transform, glm::vec3(0.01));
|
||||
//transform = glm::scale(transform, glm::vec3(0.1)); // Scale to avoid depth buffer problems
|
||||
|
||||
psc currentPosition = thisPosition;
|
||||
psc campos = camera->position();
|
||||
@@ -216,7 +205,6 @@ void RenderableFieldlines::render(const Camera* camera, const psc& thisPosition)
|
||||
|
||||
// Activate shader
|
||||
_fieldlinesProgram->activate();
|
||||
//_fieldlinesProgram->setUniform("modelViewProjection", transform);
|
||||
|
||||
_fieldlinesProgram->setUniform("modelViewProjection", camera->viewProjectionMatrix());
|
||||
_fieldlinesProgram->setUniform("modelTransform", transform);
|
||||
@@ -247,15 +235,15 @@ void RenderableFieldlines::safeShaderCompilation() {
|
||||
_fieldlinesProgram->linkProgramObject();
|
||||
}
|
||||
|
||||
std::vector<std::vector<glm::vec3> > RenderableFieldlines::getFieldlinesData(std::string filename, ghoul::Dictionary hintsDictionary) {
|
||||
std::vector<std::vector<LinePoint> > RenderableFieldlines::getFieldlinesData(std::string filename, ghoul::Dictionary hintsDictionary) {
|
||||
std::string modelString;
|
||||
float stepSize = 0.5; // default if no stepsize is specified in hints
|
||||
std::string xVariable, yVariable, zVariable;
|
||||
KameleonWrapper::Model model;
|
||||
std::vector<std::vector<glm::vec3> > fieldlinesData;
|
||||
std::vector<std::vector<LinePoint> > fieldlinesData;
|
||||
|
||||
bool classification = false, lorentz = false;
|
||||
glm::vec3 fieldlineColor = glm::vec3(1.0, 1.0, 1.0); // default color if no color or classification is specified
|
||||
glm::vec4 fieldlineColor = glm::vec4(1.0, 1.0, 1.0, 1.0); // default color if no color or classification is specified
|
||||
|
||||
if (hintsDictionary.hasKey("Model") && hintsDictionary.getValue("Model", modelString)) {
|
||||
// ------ MODEL -----------------
|
||||
|
||||
@@ -79,8 +79,8 @@ RenderableVolume::~RenderableVolume() {
|
||||
|
||||
ghoul::opengl::Texture* RenderableVolume::loadVolume(
|
||||
const std::string& filepath,
|
||||
const ghoul::Dictionary& hintsDictionary)
|
||||
{
|
||||
const ghoul::Dictionary& hintsDictionary) {
|
||||
|
||||
if( ! FileSys.fileExists(filepath)) {
|
||||
LWARNING("Could not load volume, could not find '" << filepath << "'");
|
||||
return nullptr;
|
||||
@@ -174,7 +174,6 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume(
|
||||
}
|
||||
|
||||
KameleonWrapper kw(filepath, model);
|
||||
|
||||
std::string variableString;
|
||||
if (hintsDictionary.hasKey("Variable") && hintsDictionary.getValue("Variable", variableString)) {
|
||||
float* data = kw.getUniformSampledValues(variableString, dimensions);
|
||||
@@ -220,6 +219,33 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
glm::vec3 RenderableVolume::getVolumeOffset(
|
||||
const std::string& filepath,
|
||||
const ghoul::Dictionary& hintsDictionary) {
|
||||
|
||||
std::string modelString = "";
|
||||
if (hintsDictionary.hasKey("Model"))
|
||||
hintsDictionary.getValue("Model", modelString);
|
||||
|
||||
if(modelString == "") {
|
||||
LWARNING("Model not specified.");
|
||||
return glm::vec3(0);
|
||||
}
|
||||
KameleonWrapper::Model model;
|
||||
if (modelString == "BATSRUS") {
|
||||
model = KameleonWrapper::Model::BATSRUS;
|
||||
} else if (modelString == "ENLIL") {
|
||||
model = KameleonWrapper::Model::ENLIL;
|
||||
} else {
|
||||
LWARNING("Hints does not specify a valid 'Model'");
|
||||
return glm::vec3(0);
|
||||
}
|
||||
|
||||
KameleonWrapper kw(filepath, model);
|
||||
|
||||
return kw.getModelBarycenterOffset();
|
||||
}
|
||||
|
||||
ghoul::RawVolumeReader::ReadHints RenderableVolume::readHints(const ghoul::Dictionary& dictionary) {
|
||||
ghoul::RawVolumeReader::ReadHints hints;
|
||||
hints._dimensions = glm::ivec3(1, 1, 1);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <openspace/rendering/renderablevolumegl.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/kameleonwrapper.h>
|
||||
|
||||
#include <ghoul/opengl/texturereader.h>
|
||||
#include <ghoul/opencl/clworksize.h>
|
||||
@@ -34,7 +35,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <sgct.h>
|
||||
|
||||
namespace {
|
||||
std::string _loggerCat = "RenderableVolumeGL";
|
||||
@@ -43,9 +43,8 @@ namespace {
|
||||
namespace openspace {
|
||||
|
||||
RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary):
|
||||
RenderableVolume(dictionary), _box(nullptr), _boxScaling(1.0, 1.0, 1.0),
|
||||
RenderableVolume(dictionary), _boxScaling(1.0, 1.0, 1.0),
|
||||
_updateTransferfunction(false), _id(-1) {
|
||||
|
||||
|
||||
_filename = "";
|
||||
if(dictionary.hasKey("Volume")) {
|
||||
@@ -81,8 +80,7 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary):
|
||||
}
|
||||
if( _samplerFilename == "") {
|
||||
LERROR("No samplerfile!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
double tempValue;
|
||||
if(dictionary.hasKey("BoxScaling.1") && dictionary.getValue("BoxScaling.1", tempValue)) {
|
||||
@@ -116,16 +114,23 @@ RenderableVolumeGL::~RenderableVolumeGL() {
|
||||
delete _transferFunctionFile;
|
||||
if(_transferFunction)
|
||||
delete _transferFunction;
|
||||
if(_box)
|
||||
delete _box;
|
||||
}
|
||||
|
||||
bool RenderableVolumeGL::initialize() {
|
||||
// assert(_filename != "");
|
||||
// ------ VOLUME READING ----------------
|
||||
// <<<<<<< HEAD
|
||||
// =======
|
||||
// _volume = loadVolume(_filename, _hintsDictionary);
|
||||
// _volume->uploadTexture();
|
||||
// _transferFunction = loadTransferFunction(_transferFunctionPath);
|
||||
// _transferFunction->uploadTexture();
|
||||
|
||||
// >>>>>>> feature/fieldlines
|
||||
// TODO: fix volume an transferfunction names
|
||||
if(_filename != "") {
|
||||
_volume = loadVolume(_filename, _hintsDictionary);
|
||||
_boxOffset = getVolumeOffset(_filename, _hintsDictionary);
|
||||
_volume->uploadTexture();
|
||||
OsEng.renderEngine().abuffer()->addVolume(_volumeName, _volume);
|
||||
}
|
||||
@@ -144,7 +149,6 @@ bool RenderableVolumeGL::initialize() {
|
||||
// add the sampler and get the ID
|
||||
_id = OsEng.renderEngine().abuffer()->addSamplerfile(_samplerFilename);
|
||||
|
||||
_box = new sgct_utils::SGCTBox(1.0f, sgct_utils::SGCTBox::Regular);
|
||||
OsEng.configurationManager().getValue("RaycastProgram", _boxProgram);
|
||||
_MVPLocation = _boxProgram->uniformLocation("modelViewProjection");
|
||||
_modelTransformLocation = _boxProgram->uniformLocation("modelTransform");
|
||||
@@ -205,10 +209,7 @@ bool RenderableVolumeGL::initialize() {
|
||||
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<void*>(0));
|
||||
//glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*7, reinterpret_cast<void*>(0));
|
||||
glEnableVertexAttribArray(0);
|
||||
//glEnableVertexAttribArray(1);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -234,12 +235,6 @@ void RenderableVolumeGL::render(const Camera *camera, const psc &thisPosition) {
|
||||
}
|
||||
}
|
||||
|
||||
//psc relative = thisPosition-camera->position();
|
||||
|
||||
// glm::mat4 transform = camera->viewRotationMatrix();
|
||||
// transform = glm::translate(transform, relative.vec3());
|
||||
// transform = glm::translate(transform, glm::vec3(-1.1,0.0,0.0));
|
||||
// transform = glm::scale(transform, _boxScaling);
|
||||
glm::mat4 transform = glm::mat4(1.0);
|
||||
transform = glm::scale(transform, _boxScaling);
|
||||
|
||||
@@ -251,11 +246,11 @@ void RenderableVolumeGL::render(const Camera *camera, const psc &thisPosition) {
|
||||
|
||||
// psc addon(-1.1,0.0,0.0,0.0);
|
||||
// currentPosition += addon;
|
||||
psc addon(_boxOffset/100.0f); // TODO: Proper scaling/units
|
||||
currentPosition += addon; // Move box to model barycenter
|
||||
|
||||
// TODO: Use _id to identify this volume
|
||||
_boxProgram->activate();
|
||||
// _boxProgram->setUniform(_MVPLocation, camera->viewProjectionMatrix());
|
||||
// _boxProgram->setUniform(_modelTransformLocation, transform);
|
||||
_boxProgram->setUniform(_typeLocation, _id);
|
||||
|
||||
_boxProgram->setUniform("modelViewProjection", camera->viewProjectionMatrix());
|
||||
@@ -272,20 +267,15 @@ void RenderableVolumeGL::render(const Camera *camera, const psc &thisPosition) {
|
||||
glCullFace(GL_FRONT);
|
||||
glBindVertexArray(_boxArray);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6*6);
|
||||
// _box->draw();
|
||||
|
||||
// Draw frontface (now the normal cull face is is set)
|
||||
glCullFace(GL_BACK);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6*6);
|
||||
// _box->draw();
|
||||
|
||||
_boxProgram->deactivate();
|
||||
|
||||
}
|
||||
|
||||
void RenderableVolumeGL::update() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -65,12 +65,12 @@ KameleonWrapper::KameleonWrapper(const std::string& filename, Model model): _typ
|
||||
}
|
||||
|
||||
getGridVariables(_xCoordVar, _yCoordVar, _zCoordVar);
|
||||
_xMin = _model->getVariableAttribute(_xCoordVar, "actual_min").getAttributeFloat();
|
||||
_xMax = _model->getVariableAttribute(_xCoordVar, "actual_max").getAttributeFloat();
|
||||
_yMin = _model->getVariableAttribute(_yCoordVar, "actual_min").getAttributeFloat();
|
||||
_yMax = _model->getVariableAttribute(_yCoordVar, "actual_max").getAttributeFloat();
|
||||
_zMin = _model->getVariableAttribute(_zCoordVar, "actual_min").getAttributeFloat();
|
||||
_zMax = _model->getVariableAttribute(_zCoordVar, "actual_max").getAttributeFloat();
|
||||
_xMin = _model->getVariableAttribute(_xCoordVar, "actual_min").getAttributeFloat();
|
||||
_xMax = _model->getVariableAttribute(_xCoordVar, "actual_max").getAttributeFloat();
|
||||
_yMin = _model->getVariableAttribute(_yCoordVar, "actual_min").getAttributeFloat();
|
||||
_yMax = _model->getVariableAttribute(_yCoordVar, "actual_max").getAttributeFloat();
|
||||
_zMin = _model->getVariableAttribute(_zCoordVar, "actual_min").getAttributeFloat();
|
||||
_zMax = _model->getVariableAttribute(_zCoordVar, "actual_max").getAttributeFloat();
|
||||
|
||||
_lastiProgress = -1; // For progressbar
|
||||
}
|
||||
@@ -282,6 +282,7 @@ float* KameleonWrapper::getUniformSampledVectorValues(const std::string& xVar, c
|
||||
data[index + 3] = 1.0; // GL_RGB refuses to work. Workaround by doing a GL_RGBA with hardcoded alpha
|
||||
} else {
|
||||
LERROR("Only BATSRUS supported for getUniformSampledVectorValues (for now)");
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,7 +293,7 @@ float* KameleonWrapper::getUniformSampledVectorValues(const std::string& xVar, c
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<std::vector<glm::vec3> > KameleonWrapper::getClassifiedFieldLines(
|
||||
std::vector<std::vector<LinePoint> > KameleonWrapper::getClassifiedFieldLines(
|
||||
const std::string& xVar, const std::string& yVar,
|
||||
const std::string& zVar, std::vector<glm::vec3> seedPoints,
|
||||
float stepSize ) {
|
||||
@@ -301,8 +302,8 @@ std::vector<std::vector<glm::vec3> > KameleonWrapper::getClassifiedFieldLines(
|
||||
LINFO("Creating " << seedPoints.size() << " fieldlines from variables " << xVar << " " << yVar << " " << zVar);
|
||||
|
||||
std::vector<glm::vec3> fLine, bLine;
|
||||
std::vector<std::vector<glm::vec3> > fieldLines;
|
||||
glm::vec3 color;
|
||||
std::vector<std::vector<LinePoint> > fieldLines;
|
||||
glm::vec4 color;
|
||||
FieldlineEnd forwardEnd, backEnd;
|
||||
|
||||
if (_type == Model::BATSRUS) {
|
||||
@@ -316,10 +317,9 @@ std::vector<std::vector<glm::vec3> > KameleonWrapper::getClassifiedFieldLines(
|
||||
color = classifyFieldline(forwardEnd, backEnd);
|
||||
|
||||
// write colors
|
||||
std::vector<glm::vec3> line;
|
||||
std::vector<LinePoint> line;
|
||||
for (glm::vec3 position : bLine) {
|
||||
line.push_back(position);
|
||||
line.push_back(color);
|
||||
line.push_back(LinePoint(position, color));
|
||||
}
|
||||
|
||||
fieldLines.push_back(line);
|
||||
@@ -331,16 +331,16 @@ std::vector<std::vector<glm::vec3> > KameleonWrapper::getClassifiedFieldLines(
|
||||
return fieldLines;
|
||||
}
|
||||
|
||||
std::vector<std::vector<glm::vec3> > KameleonWrapper::getFieldLines(
|
||||
std::vector<std::vector<LinePoint> > KameleonWrapper::getFieldLines(
|
||||
const std::string& xVar, const std::string& yVar,
|
||||
const std::string& zVar, std::vector<glm::vec3> seedPoints,
|
||||
float stepSize, glm::vec3 color ) {
|
||||
float stepSize, glm::vec4 color ) {
|
||||
assert(_model && _interpolator);
|
||||
assert(_type == Model::ENLIL || _type == Model::BATSRUS);
|
||||
LINFO("Creating " << seedPoints.size() << " fieldlines from variables " << xVar << " " << yVar << " " << zVar);
|
||||
|
||||
std::vector<glm::vec3> fLine, bLine;
|
||||
std::vector<std::vector<glm::vec3> > fieldLines;
|
||||
std::vector<std::vector<LinePoint> > fieldLines;
|
||||
FieldlineEnd forwardEnd, backEnd;
|
||||
|
||||
if (_type == Model::BATSRUS) {
|
||||
@@ -351,10 +351,9 @@ std::vector<std::vector<glm::vec3> > KameleonWrapper::getFieldLines(
|
||||
bLine.insert(bLine.begin(), fLine.rbegin(), fLine.rend());
|
||||
|
||||
// write colors
|
||||
std::vector<glm::vec3> line;
|
||||
std::vector<LinePoint> line;
|
||||
for (glm::vec3 position : bLine) {
|
||||
line.push_back(position);
|
||||
line.push_back(color);
|
||||
line.push_back(LinePoint(position, color));
|
||||
}
|
||||
|
||||
fieldLines.push_back(line);
|
||||
@@ -366,11 +365,11 @@ std::vector<std::vector<glm::vec3> > KameleonWrapper::getFieldLines(
|
||||
return fieldLines;
|
||||
}
|
||||
|
||||
std::vector<std::vector<glm::vec3> > KameleonWrapper::getLorentzTrajectories(
|
||||
std::vector<glm::vec3> seedPoints, glm::vec3 color, float stepsize) {
|
||||
std::vector<std::vector<LinePoint> > KameleonWrapper::getLorentzTrajectories(
|
||||
std::vector<glm::vec3> seedPoints, glm::vec4 color, float stepsize) {
|
||||
LINFO("Creating " << seedPoints.size() << " Lorentz force trajectories");
|
||||
|
||||
std::vector<std::vector<glm::vec3> > trajectories;
|
||||
std::vector<std::vector<LinePoint> > trajectories;
|
||||
std::vector<glm::vec3> plusTraj, minusTraj;
|
||||
|
||||
for (auto seedPoint : seedPoints) {
|
||||
@@ -380,10 +379,9 @@ std::vector<std::vector<glm::vec3> > KameleonWrapper::getLorentzTrajectories(
|
||||
minusTraj.insert(minusTraj.begin(), plusTraj.rbegin(), plusTraj.rend());
|
||||
|
||||
// write colors
|
||||
std::vector<glm::vec3> trajectory;
|
||||
std::vector<LinePoint> trajectory;
|
||||
for (glm::vec3 position : minusTraj) {
|
||||
trajectory.push_back(position);
|
||||
trajectory.push_back(color);
|
||||
trajectory.push_back(LinePoint(position, color));
|
||||
}
|
||||
trajectories.push_back(trajectory);
|
||||
}
|
||||
@@ -391,6 +389,14 @@ std::vector<std::vector<glm::vec3> > KameleonWrapper::getLorentzTrajectories(
|
||||
return trajectories;
|
||||
}
|
||||
|
||||
glm::vec3 KameleonWrapper::getModelBarycenterOffset() {
|
||||
glm::vec3 offset;
|
||||
offset.x = _xMin+(std::abs(_xMin)+std::abs(_xMax))/2.0f;
|
||||
offset.y = _yMin+(std::abs(_yMin)+std::abs(_yMax))/2.0f;
|
||||
offset.z = _zMin+(std::abs(_zMin)+std::abs(_zMax))/2.0f;
|
||||
return offset;
|
||||
}
|
||||
|
||||
std::vector<glm::vec3> KameleonWrapper::traceCartesianFieldline(
|
||||
const std::string& xVar, const std::string& yVar,
|
||||
const std::string& zVar, glm::vec3 seedPoint,
|
||||
@@ -590,23 +596,23 @@ void KameleonWrapper::progressBar(int current, int end) {
|
||||
_lastiProgress = iprogress;
|
||||
}
|
||||
|
||||
glm::vec3 KameleonWrapper::classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEnd) {
|
||||
glm::vec3 color;
|
||||
glm::vec4 KameleonWrapper::classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEnd) {
|
||||
glm::vec4 color;
|
||||
if ( (fEnd == FieldlineEnd::NORTH || fEnd == FieldlineEnd::SOUTH)
|
||||
&& (bEnd == FieldlineEnd::NORTH || bEnd == FieldlineEnd::SOUTH)) {
|
||||
// closed
|
||||
color = glm::vec3(1.0, 0.0, 0.0);
|
||||
color = glm::vec4(1.0, 0.0, 0.0, 1.0);
|
||||
} else if ((fEnd == FieldlineEnd::OUT && bEnd == FieldlineEnd::NORTH)
|
||||
|| (bEnd == FieldlineEnd::OUT && fEnd == FieldlineEnd::NORTH)) {
|
||||
// north
|
||||
color = glm::vec3(1.0, 1.0, 0.0);
|
||||
color = glm::vec4(1.0, 1.0, 0.0, 1.0);
|
||||
} else if ((fEnd == FieldlineEnd::OUT && bEnd == FieldlineEnd::SOUTH)
|
||||
|| (bEnd == FieldlineEnd::OUT && fEnd == FieldlineEnd::SOUTH)) {
|
||||
// south
|
||||
color = glm::vec3(0.0, 1.0, 0.0);
|
||||
color = glm::vec4(0.0, 1.0, 0.0, 1.0);
|
||||
} else if (fEnd == FieldlineEnd::OUT && bEnd == FieldlineEnd::OUT) {
|
||||
// solar wind
|
||||
color = glm::vec3(0.0, 0.0, 1.0);
|
||||
color = glm::vec4(0.0, 0.0, 1.0, 1.0);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user