diff --git a/config/sgct/single.xml b/config/sgct/single.xml index 87e59f7b28..3ec20dd5db 100644 --- a/config/sgct/single.xml +++ b/config/sgct/single.xml @@ -8,7 +8,7 @@ - + diff --git a/include/openspace/interaction/interactionhandler.h b/include/openspace/interaction/interactionhandler.h index b8505beda2..80b867dd91 100644 --- a/include/openspace/interaction/interactionhandler.h +++ b/include/openspace/interaction/interactionhandler.h @@ -11,6 +11,8 @@ #include #include #include +#include +#include namespace openspace { @@ -56,6 +58,8 @@ public: void mouseButtonCallback(int key, int action); void mousePositionCallback(int x, int y); void mouseScrollWheelCallback(int pos); + + void addKeyCallback(int key, std::function f); private: glm::vec3 mapToTrackball(glm::vec2 mousePos); @@ -77,6 +81,8 @@ private: // for locking and unlocking std::mutex cameraGuard_; + + std::multimap > _keyCallbacks; }; diff --git a/include/openspace/rendering/renderablevolumegl.h b/include/openspace/rendering/renderablevolumegl.h index f7b82028fc..dce4c1942b 100644 --- a/include/openspace/rendering/renderablevolumegl.h +++ b/include/openspace/rendering/renderablevolumegl.h @@ -68,6 +68,7 @@ private: GLuint _boxArray; ghoul::opengl::ProgramObject *_boxProgram; glm::vec3 _boxScaling, _boxOffset; + float _w; GLint _MVPLocation, _modelTransformLocation, _typeLocation; bool _updateTransferfunction; diff --git a/include/openspace/scenegraph/scenegraphnode.h b/include/openspace/scenegraph/scenegraphnode.h index 9a8b847d97..531ca23089 100644 --- a/include/openspace/scenegraph/scenegraphnode.h +++ b/include/openspace/scenegraph/scenegraphnode.h @@ -90,6 +90,7 @@ private: // renderable Renderable* _renderable; bool _renderableVisible; + bool _renderableToggle; // bounding sphere bool _boundingSphereVisible; diff --git a/openspace-data b/openspace-data index 73b2b86788..2642f7b929 160000 --- a/openspace-data +++ b/openspace-data @@ -1 +1 @@ -Subproject commit 73b2b86788038628721898e08a367588069afbac +Subproject commit 2642f7b929d2fb6573f81ecec5d2823ef5506092 diff --git a/shaders/ABuffer/abufferResolveFragment.glsl b/shaders/ABuffer/abufferResolveFragment.glsl index 63b89cf709..1eb46ac089 100644 --- a/shaders/ABuffer/abufferResolveFragment.glsl +++ b/shaders/ABuffer/abufferResolveFragment.glsl @@ -30,9 +30,10 @@ #pragma openspace insert SETTINGS #define MAX_FRAGMENTS 16 -#define SHOWFUNC -#define JITTERING -#define SHOWENLIL +// #define SHOWFUNC +// #define JITTERING +#define SAMPLEFIRSTVOLUME +// #define COLORNORMALIZATION #define PSCDEPTH 1 #define ZDEPTH 2 @@ -59,7 +60,8 @@ const float samplingRate = 1.0; // uniform int SCREEN_WIDTH; // uniform int SCREEN_HEIGHT; -uniform float ALPHA_LIMIT = 0.95; +uniform float ALPHA_LIMIT = 0.99; +uniform float EPSILON = 0.01; in vec2 texCoord; out vec4 color; @@ -81,7 +83,9 @@ vec3 CartesianToSpherical(vec3 _cartesian) { theta = phi = 0.0; } else { theta = acos(cartesian.z/r) / M_PI; - phi = (M_PI + atan(cartesian.y, cartesian.x)) / (2.0*M_PI); + // float diff = -.0f; + phi = (M_PI + atan(cartesian.y, cartesian.x)) / (2.0*M_PI ); + // phi = (M_PI+radians(diff) + atan(cartesian.y, cartesian.x)) / (2.0*M_PI+radians(diff) ); // phi = (M_PI + atan(cartesian.x, cartesian.y)) / (2.0*M_PI); } // r *= 0.57735026919; @@ -142,6 +146,27 @@ void blendGeometry(inout vec4 color, ABufferStruct_t frag) { } */ +float volumeRaycastingDistance(in int id, in ABufferStruct_t startFrag, in ABufferStruct_t endFrag) { +#if ZTYPE == ZDEPTH + const float S1 = volume_zlength[id].x; + const float S2 = volume_zlength[id].y; + const float L = S1 - S2; + // const float z1 = globz(_z_(startFrag)); + // const float z2 = globz(_z_(endFrag)); + const float z1 = _z_(startFrag); + const float z2 = _z_(endFrag); + return ((z1 - S1) / L - (z2 - S1) / L) * volume_length[id]; +#elif ZTYPE == PSCDEPTH + const float L = volume_zlength[id]; + const vec4 p1 = _pos_(startFrag); + const vec4 p2 = _pos_(endFrag); + const float dist = pscLength(p1, p2); + // const float z1 = _z_(startFrag); + // const float z2 = _z_(endFrag); + return (dist / L) * volume_length[id]; +#endif +} + float globz(float z) { return z; // return log(2.0*z-1.0); @@ -183,59 +208,81 @@ vec4 calculate_final_color(uint frag_count) { #if MAX_VOLUMES > 0 if(currentVolumeBitmask > 0) { + int volbit = currentVolumeBitmask; + int endbittype = int(_type_(endFrag)); + if(endbittype > 0) + volbit = volbit ^ (1 << (endbittype-1)); + + // int volID = type -1; + // int volID = type-1; + int volID; + // TODO: Fix this non-working normalization for volumes with different stepsize - // float myMaxSteps = 0.0000001; - // for(int v = 0; v < MAX_VOLUMES; ++v) { - // if((currentVolumeBitmask & (1 << v)) > 0) { - // myMaxSteps = max(myMaxSteps, volume_length[v]/volumeStepSize[v]); - // } - // } + float myMaxSteps = 0.0000001; + float vlength; + for(int v = 0; v < MAX_VOLUMES; ++v) { + if((currentVolumeBitmask & (1 << v)) > 0) { + + // float l = volume_length[v]/volumeStepSize[v]; + // if(myMaxSteps < l) { + // myMaxSteps = l; + // volID = v; + // } + float l = volumeRaycastingDistance(v, startFrag, endFrag); + // myMaxSteps = max(myMaxSteps, L/volumeStepSizeOriginal[v]); + myMaxSteps = max(myMaxSteps, l/volumeStepSizeOriginal[v]); + + // if((volbit & (1 << v)) > 0) + // volID = v; + // if(volbit == 0) + // volID = v; + // if(type - 1 != v && type == endbittype) + // volID = v; + + // if(volID < 0) volID = v; + // volID = v; + } + } // for(int v = 0; v < MAX_VOLUMES; ++v) { // if((currentVolumeBitmask & (1 << v)) > 0) { // float aaa = volume_length[v]/myMaxSteps; // volumeStepSize[v] = volumeStepSizeOriginal[v]*vec3(aaa); // } // } - - - int volID = type -1; -#if ZTYPE == ZDEPTH - const float S1 = volume_zlength[volID].x; - const float S2 = volume_zlength[volID].y; - const float L = S1 - S2; - const float z1 = globz(_z_(startFrag)); - const float z2 = globz(_z_(endFrag)); - // const float z1 = _z_(startFrag); - // const float z2 = _z_(endFrag); - const float l = ((z1 - S1) / L - (z2 - S1) / L) * volume_length[volID]; - int max_iterations = int(l / volumeStepSize[volID]); -#elif ZTYPE == PSCDEPTH - const float L = volume_zlength[volID]; - const vec4 p1 = _pos_(startFrag); - const vec4 p2 = _pos_(endFrag); - const float dist = pscLength(p1, p2); - // const float z1 = _z_(startFrag); - // const float z2 = _z_(endFrag); - const float l = (dist / L) * volume_length[volID]; - int max_iterations = int(l / volumeStepSize[volID]); -#endif - - - - - // MIP - // vec4 tmp, color = vec4(0); - // while(p < l && iterations < LOOP_LIMIT) { - // tmp = texture(volume, volume_position[volID]); - // color = max(color, tmp); - // p+= stepSize; - // volume_position[volID] += direction*stepSize; - // ++iterations; + // float myMaxSteps = stepSize; + // for(int v = 0; v < MAX_VOLUMES; ++v) { + // if((currentVolumeBitmask & (1 << v)) > 0) { + // myMaxSteps = min(myMaxSteps, volumeStepSize[v]); + // } // } - // vec4 volume_color = vec4(color.r,color.r,color.r,color.r*2.0); - // if(volume_color.a < 0.1) volume_color = vec4(0.0,0.0,0.0,0.0); - // final_color = blend(final_color, volume_color); - + + for(int v = 0; v < MAX_VOLUMES; ++v) { + if((currentVolumeBitmask & (1 << v)) > 0) { + // float aaa = myMaxSteps; + float l = volumeRaycastingDistance(v, startFrag, endFrag); + float aaa = l/myMaxSteps; + // float aaa = volume_length[v]/myMaxSteps; + // volumeStepSize[v] = volumeStepSizeOriginal[v]*vec3(aaa); + // float aaa = volume_length[v]/volumeStepSizeOriginal[v]; + volumeStepSize[v] = aaa; + + // if(vlength >= volume_length[v]) { + // // vlength = volume_length[v]; + // const float S1 = volume_zlength[v].x; + // const float S2 = volume_zlength[v].y; + // const float L = S1 - S2; + // vlength = volume_length[v]; + // vlength = L; + // volID = v; + // } + // if(volID < 0) volID = v; + volID = v; + } + } + + + float l = volumeRaycastingDistance(volID, startFrag, endFrag); + int max_iterations = int(l / volumeStepSize[volID]); // TransferFunction vec4 color = vec4(0); @@ -296,8 +343,10 @@ vec4 calculate_final_color(uint frag_count) { // final_color = vec4(1.0,1.0,1.0,1.0); // } - // final_color.rgb = final_color.rgb * final_color.a; - // final_color.a = 1.0; +#ifdef COLORNORMALIZATION + final_color.rgb = final_color.rgb * final_color.a; + final_color.a = 1.0; +#endif return final_color; diff --git a/src/abuffer/abuffer.cpp b/src/abuffer/abuffer.cpp index 274aa9859e..42a7367721 100644 --- a/src/abuffer/abuffer.cpp +++ b/src/abuffer/abuffer.cpp @@ -314,7 +314,7 @@ std::string ABuffer::openspaceSamplerCalls() { if(found1 != std::string::npos && found2 != std::string::npos) { std::string functionName = _samplers.at(i).substr(found1, found2 - found1); if(i == 0) - samplercalls += "#ifdef SHOWENLIL\n"; + samplercalls += "#ifdef SAMPLEFIRSTVOLUME\n"; samplercalls += "if((currentVolumeBitmask & (1 << " + std::to_string(i) + ")) == "+std::to_string(1 << i)+") {\n"; samplercalls += " vec4 c = " + functionName + "(final_color,volume_position[" + std::to_string(i) + "]);\n"; // samplercalls += " if(c.a < 0.1) { \n"; @@ -325,6 +325,7 @@ std::string ABuffer::openspaceSamplerCalls() { // samplercalls += " volumeStepSize[" + std::to_string(i) + "] = volumeStepSizeOriginal[" + std::to_string(i) + "]; \n"; // samplercalls += " //c = " + functionName + "(final_color,volume_position[" + std::to_string(i) + "]);\n"; // samplercalls += " } \n"; + samplercalls += " if(c.a > EPSILON)\n"; samplercalls += " blendStep(final_color, c, volumeStepSize[" + std::to_string(i) + "]);\n"; // samplercalls += " blendStep(final_color, c, stepSize);\n"; // samplercalls += " float aaa = volume_length[i]/myMaxSteps;\n"; @@ -358,7 +359,7 @@ std::string ABuffer::openspaceTransferFunction() { for(int i = 0; i < _transferFunctions.size(); ++i) { tf += "if( gl_FragCoord.y > SCREEN_HEIGHTf-showfunc_size*"+std::to_string(i+1)+ " && gl_FragCoord.y < SCREEN_HEIGHTf-showfunc_size*"+std::to_string(i)+") {\n"; - tf += " float normalizedIntensity = gl_FragCoord.x / SCREEN_WIDTHf ;\n"; + tf += " float normalizedIntensity = gl_FragCoord.x / (SCREEN_WIDTHf-1) ;\n"; tf += " vec4 tfc = texture("+ _transferFunctions.at(i).first +", normalizedIntensity);\n"; tf += " final_color = tfc;\n"; tf += " float cmpf = SCREEN_HEIGHTf-showfunc_size*"+std::to_string(i+1)+" + tfc.a*showfunc_size;\n"; diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index 5a4dc136f0..9443a1f286 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -390,6 +390,14 @@ void InteractionHandler::keyboardCallback(int key, int action) { getCamera()->setCameraDirection(glm::vec3(0.0, 0.0, -1.0)); } */ + // std::pair >::iterator, std::multimap >::iterator> ret; + if(action == SGCT_PRESS) { + auto ret = _keyCallbacks.equal_range(key); + for (auto it=ret.first; it!=ret.second; ++it) + it->second(); + } + + } void InteractionHandler::mouseButtonCallback(int key, int action) { @@ -428,5 +436,10 @@ void InteractionHandler::mouseScrollWheelCallback(int pos) { } } +void InteractionHandler::addKeyCallback(int key, std::function f) { + //std::map > > _keyCallbacks; + + _keyCallbacks.insert(std::make_pair(key, f)); +} } // namespace openspace diff --git a/src/rendering/renderablevolume.cpp b/src/rendering/renderablevolume.cpp index e7463558cd..7ecaf4274f 100644 --- a/src/rendering/renderablevolume.cpp +++ b/src/rendering/renderablevolume.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -81,6 +82,7 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume( const std::string& filepath, const ghoul::Dictionary& hintsDictionary) { + if( ! FileSys.fileExists(filepath)) { LWARNING("Could not load volume, could not find '" << filepath << "'"); return nullptr; @@ -92,6 +94,9 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume( return rawReader.read(filepath); } else if(hasExtension(filepath, "cdf")) { + ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear; + ghoul::opengl::Texture::WrappingMode wrappingmode = ghoul::opengl::Texture::WrappingMode::ClampToEdge; + glm::size3_t dimensions(1,1,1); double tempValue; if (hintsDictionary.hasKey("Dimensions.1") && @@ -158,9 +163,7 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume( } fclose(file); - ghoul::opengl::Texture* t = new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::Red, GL_RED, GL_FLOAT, ghoul::opengl::Texture::FilterMode::Linear, ghoul::opengl::Texture::WrappingMode::ClampToBorder); - t->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToBorder); - return t; + return new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::Red, GL_RED, GL_FLOAT, filtermode, wrappingmode); } KameleonWrapper::Model model; @@ -183,9 +186,7 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume( fwrite(data, sizeof(float), length, file); fclose(file); } - ghoul::opengl::Texture* t = new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::Red, GL_RED, GL_FLOAT, ghoul::opengl::Texture::FilterMode::Linear, ghoul::opengl::Texture::WrappingMode::ClampToBorder); - t->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToBorder); - return t; + return new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::Red, GL_RED, GL_FLOAT, filtermode, wrappingmode); } else if (hintsDictionary.hasKey("Variables")) { std::string xVariable, yVariable, zVariable; bool xVar, yVar, zVar; @@ -205,9 +206,7 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume( fclose(file); } - ghoul::opengl::Texture* t = new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::RGBA, GL_RGBA, GL_FLOAT); - t->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToBorder); - return t; + return new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::RGBA, GL_RGBA, GL_FLOAT, filtermode, wrappingmode); } } else { @@ -236,6 +235,7 @@ glm::vec3 RenderableVolume::getVolumeOffset( model = KameleonWrapper::Model::BATSRUS; } else if (modelString == "ENLIL") { model = KameleonWrapper::Model::ENLIL; + return glm::vec3(0); } else { LWARNING("Hints does not specify a valid 'Model'"); return glm::vec3(0); @@ -313,11 +313,14 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string if ( ! FileSys.fileExists(f)) { return nullptr; } + ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear; + ghoul::opengl::Texture::WrappingMode wrappingmode = ghoul::opengl::Texture::WrappingMode::ClampToEdge; + // check if not a txt based texture if ( ! hasExtension(filepath, "txt")) { ghoul::opengl::Texture* t = ghoul::opengl::loadTexture(f); - t->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToBorder); + t->setWrapping(wrappingmode); return t; } @@ -346,7 +349,7 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string auto widthValidator = [](size_t in) { if(in > 0) return in; return static_cast(1); }; auto upperLowerValidator = [](float in) { return glm::clamp(in, 0.0f, 1.0f); }; - auto intensityValidator = [](float in) { if(in > 0.0f) return in; return 1.0f; }; + auto intensityValidator = [](float in) { return glm::clamp(in, 0.0f, 1.0f); }; std::string line; while (std::getline(in, line)) { @@ -381,15 +384,26 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string if (mappingKeys.size() < 1) { return nullptr; } + + // for(auto key: mappingKeys) { + // glm::vec4 rgba = key.color; + // LDEBUG("i: " << key.position << ", rgba: (" << rgba[0] << ", " << rgba[1] << ", " << rgba[2] << ", " << rgba[3] << ")"); + // } + // LDEBUG("insert...."); - mappingKeys.insert(mappingKeys.begin(), {lower}); - mappingKeys.push_back({upper}); - - - for(auto key: mappingKeys) { - glm::vec4 rgba = key.color; -// LDEBUG("i: " << key.position << ", rgba: (" << rgba[0] << ", " << rgba[1] << ", " << rgba[2] << ", " << rgba[3] << ")"); + if (mappingKeys.front().position > lower){ + mappingKeys.insert(mappingKeys.begin(), {lower,mappingKeys.front().color}); } + + if (mappingKeys.back().position < upper){ + mappingKeys.push_back({upper,mappingKeys.back().color}); + } + + + // for(auto key: mappingKeys) { + // glm::vec4 rgba = key.color; + // LDEBUG("i: " << key.position << ", rgba: (" << rgba[0] << ", " << rgba[1] << ", " << rgba[2] << ", " << rgba[3] << ")"); + // } // allocate new float array with zeros float* transferFunction = new float[width*4](); @@ -448,18 +462,25 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string //LDEBUG("["<< position <<"] " << value); } - // LDEBUG(weight << ", (" << - // transferFunction[4*i+0] << ", " << - // transferFunction[4*i+1] << ", " << - // transferFunction[4*i+2] << ", " << - // transferFunction[4*i+3] << ")"); + // LDEBUG(std::fixed << std::setw(10) << std::left << std::setprecision(8) << weight << ", (" << + // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+0] << ", " << + // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+1] << ", " << + // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+2] << ", " << + // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+3] << ")"); } - ghoul::opengl::Texture* t = new ghoul::opengl::Texture(transferFunction, + // for (int i = 0; i <= width; ++i) { + + // LDEBUG(std::fixed << "(" << + // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+0] << ", " << + // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+1] << ", " << + // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+2] << ", " << + // std::setw(10) << std::left << std::setprecision(8) << transferFunction[4*i+3] << ")"); + // } + + return new ghoul::opengl::Texture(transferFunction, glm::size3_t(width,1,1),ghoul::opengl::Texture::Format::RGBA, - GL_RGBA, GL_FLOAT, ghoul::opengl::Texture::FilterMode::Linear, - ghoul::opengl::Texture::WrappingMode::ClampToBorder); - return t; + GL_RGBA, GL_FLOAT,filtermode, wrappingmode); } } // namespace openspace diff --git a/src/rendering/renderablevolumegl.cpp b/src/rendering/renderablevolumegl.cpp index ed0e62a719..9e4bca99a0 100644 --- a/src/rendering/renderablevolumegl.cpp +++ b/src/rendering/renderablevolumegl.cpp @@ -92,8 +92,11 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary): _boxScaling[1] = tempValue; } if(dictionary.hasKey("BoxScaling.3") && dictionary.getValue("BoxScaling.3", tempValue)) { - if(tempValue > 0.0) - _boxScaling[2] = tempValue; + if(tempValue > 0.0) + _boxScaling[2] = tempValue; + } + if(dictionary.hasKey("BoxScaling.4") && dictionary.getValue("BoxScaling.4", tempValue)) { + _w = tempValue; } _volumeName = ""; @@ -103,7 +106,7 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary): if (dictionary.hasKey("TransferFunctionName")) dictionary.getValue("TransferFunctionName", _transferFunctionName); - setBoundingSphere(PowerScaledScalar::CreatePSS(glm::length(_boxScaling))); + setBoundingSphere(PowerScaledScalar::CreatePSS(glm::length(_boxScaling)*pow(10,_w))); } RenderableVolumeGL::~RenderableVolumeGL() { @@ -160,47 +163,47 @@ bool RenderableVolumeGL::initialize() { const GLfloat size = 0.5f; const GLfloat vertex_data[] = { // square of two triangles (sigh) // x, y, z, s, - -size, -size, size, 0.0f, - size, size, size, 0.0f, - -size, size, size, 0.0f, - -size, -size, size, 0.0f, - size, -size, size, 0.0f, - size, size, size, 0.0f, + -size, -size, size, _w, + size, size, size, _w, + -size, size, size, _w, + -size, -size, size, _w, + size, -size, size, _w, + size, size, size, _w, - -size, -size, -size, 0.0f, - size, size, -size, 0.0f, - -size, size, -size, 0.0f, - -size, -size, -size, 0.0f, - size, -size, -size, 0.0f, - size, size, -size, 0.0f, + -size, -size, -size, _w, + size, size, -size, _w, + -size, size, -size, _w, + -size, -size, -size, _w, + size, -size, -size, _w, + size, size, -size, _w, - size, -size, -size, 0.0f, - size, size, size, 0.0f, - size, -size, size, 0.0f, - size, -size, -size, 0.0f, - size, size, -size, 0.0f, - size, size, size, 0.0f, + size, -size, -size, _w, + size, size, size, _w, + size, -size, size, _w, + size, -size, -size, _w, + size, size, -size, _w, + size, size, size, _w, - -size, -size, -size, 0.0f, - -size, size, size, 0.0f, - -size, -size, size, 0.0f, - -size, -size, -size, 0.0f, - -size, size, -size, 0.0f, - -size, size, size, 0.0f, + -size, -size, -size, _w, + -size, size, size, _w, + -size, -size, size, _w, + -size, -size, -size, _w, + -size, size, -size, _w, + -size, size, size, _w, - -size, size, -size, 0.0f, - size, size, size, 0.0f, - -size, size, size, 0.0f, - -size, size, -size, 0.0f, - size, size, -size, 0.0f, - size, size, size, 0.0f, + -size, size, -size, _w, + size, size, size, _w, + -size, size, size, _w, + -size, size, -size, _w, + size, size, -size, _w, + size, size, size, _w, - -size, -size, -size, 0.0f, - size, -size, size, 0.0f, - -size, -size, size, 0.0f, - -size, -size, -size, 0.0f, - size, -size, -size, 0.0f, - size, -size, size, 0.0f, + -size, -size, -size, _w, + size, -size, size, _w, + -size, -size, size, _w, + -size, -size, -size, _w, + size, -size, -size, _w, + size, -size, size, _w, }; GLuint vertexPositionBuffer; glGenVertexArrays(1, &_boxArray); // generate array diff --git a/src/scenegraph/scenegraphnode.cpp b/src/scenegraph/scenegraphnode.cpp index 146f922a87..45f78eeb71 100644 --- a/src/scenegraph/scenegraphnode.cpp +++ b/src/scenegraph/scenegraphnode.cpp @@ -77,6 +77,25 @@ SceneGraphNode* SceneGraphNode::createFromDictionary(const ghoul::Dictionary& di } LDEBUG("Successfully create renderable for '" << result->_nodeName << "'"); } + + if (dictionary.hasKey("RenderableToggle")) { + std::string val; + dictionary.getValue("RenderableToggle", val); + + if(val.length() == 1) { + char c = std::toupper(val[0]); + int key = static_cast(c); + auto func = [result]() { + result->_renderableToggle = ! result->_renderableToggle; + }; + LERROR("Found key:" << key); + OsEng.interactionHandler().addKeyCallback(key, func); + } + + // LERROR("Found key:" << val); + // LERROR("key 1:" << static_cast('1')); + } + if (dictionary.hasKey(keyEphemeris)) { ghoul::Dictionary ephemerisDictionary; dictionary.getValue(keyEphemeris, ephemerisDictionary); @@ -116,6 +135,7 @@ SceneGraphNode::SceneGraphNode() , _ephemeris(new StaticEphemeris) , _renderable(nullptr) , _renderableVisible(false) + , _renderableToggle(true) , _boundingSphereVisible(false) { } @@ -212,7 +232,7 @@ void SceneGraphNode::render(const Camera* camera, const psc& parentPosition) if (!_boundingSphereVisible) { return; } - if (_renderableVisible) { + if (_renderableVisible && _renderableToggle) { // LDEBUG("Render"); _renderable->render(camera, thisPosition); } diff --git a/src/util/kameleonwrapper.cpp b/src/util/kameleonwrapper.cpp index 023f96a698..ce0acd5376 100644 --- a/src/util/kameleonwrapper.cpp +++ b/src/util/kameleonwrapper.cpp @@ -213,10 +213,18 @@ float* KameleonWrapper::getUniformSampledValues(const std::string& var, glm::siz dist = (dist / static_cast(bins)) * static_cast(stop); varMax = varMin + dist; + LDEBUG(var << "Min: " << varMin); + LDEBUG(var << "Max: " << varMax); for(int i = 0; i < size; ++i) { double normalizedVal = (doubleData[i]-varMin)/(varMax-varMin); data[i] = static_cast(glm::clamp(normalizedVal, 0.0, 1.0)); + if(data[i] < 0.0) { + LERROR("Datapoint " << i << " less than 0"); + } + if(data[i] > 1.0) { + LERROR("Datapoint " << i << " more than 1"); + } } // for(int i = 0; i < size; ++i) {