diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index 7d618b1f3a..790c01419b 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -77,10 +77,6 @@ public: bool hasTimeInterval(); bool getInterval(double& start, double& end); - bool hasBody(); - bool getBody(std::string& body); - void setBody(std::string& body); - void onEnabledChange(std::function callback); static void setPscUniforms(ghoul::opengl::ProgramObject& program, const Camera& camera, const PowerScaledCoordinate& position); @@ -92,8 +88,6 @@ private: PowerScaledScalar boundingSphere_; std::string _startTime; std::string _endTime; - std::string _targetBody; - bool _hasBody; bool _hasTimeInterval; }; diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 4becb16e01..0733523032 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -174,7 +174,6 @@ bool RenderableModel::deinitialize() { } void RenderableModel::render(const RenderData& data) { - _programObject->activate(); double lt; @@ -199,11 +198,7 @@ void RenderableModel::render(const RenderData& data) { _fading = _fading + 0.01f; } - - - - // Calculate variables to be used as uniform variables in shader - glm::dvec3 bodyPosition = data.positionVec3; + // debug rotation controlled from GUI glm::mat4 unitMat4(1); @@ -215,11 +210,14 @@ void RenderableModel::render(const RenderData& data) { // Model transform and view transform needs to be in double precision glm::dmat4 modelTransform = - glm::translate(glm::dmat4(1.0), bodyPosition) * // Translation + glm::translate(glm::dmat4(1.0), data.positionVec3) * // Translation glm::dmat4(_stateMatrix) * // Spice rotation debugModelRotation; // debug model rotation controlled from GUI glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; - glm::vec3 directionToSun = glm::normalize(_sunPosition.vec3() - glm::vec3(bodyPosition)); + + + + glm::vec3 directionToSun = glm::normalize(_sunPos - data.positionVec3); glm::vec3 directionToSunViewSpace = glm::mat3(data.camera.combinedViewMatrix()) * directionToSun; _programObject->setUniform("transparency", _alpha); @@ -264,15 +262,13 @@ void RenderableModel::update(const UpdateData& data) { // _time = futureTime; //} + double lt; + _sunPos = openspace::SpiceManager::ref().targetPosition("SUN", "SUN", "GALACTIC", {}, _time, lt); + // set spice-orientation in accordance to timestamp if (!_source.empty()) { _stateMatrix = SpiceManager::ref().positionTransformMatrix(_source, _destination, _time) * _modelTransform; - } - - double lt; - glm::dvec3 p = - openspace::SpiceManager::ref().targetPosition("SUN", _target, "GALACTIC", {}, _time, lt); - _sunPosition = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z); + } } void RenderableModel::loadTexture() { diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index bf658aca9d..daa2df8685 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -76,7 +76,7 @@ private: //bool _isGhost; int _frameCount; - psc _sunPosition; + glm::dvec3 _sunPos; properties::BoolProperty _performShading; properties::Vec3Property _debugModelRotation; diff --git a/modules/base/rendering/renderableplanet.cpp b/modules/base/rendering/renderableplanet.cpp index 5fad671bc3..8cc278a29c 100644 --- a/modules/base/rendering/renderableplanet.cpp +++ b/modules/base/rendering/renderableplanet.cpp @@ -157,8 +157,7 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) dictionary.getValue(keyFrame, _frame); dictionary.getValue(keyBody, _target); - if (_target != "") - setBody(_target); + // TODO: textures need to be replaced by a good system similar to the geometry as soon // as the requirements are fixed (ab) @@ -618,26 +617,7 @@ void RenderablePlanet::render(const RenderData& data) transform[i][j] = static_cast(_stateMatrix[i][j]); } } - transform = transform * rot * roty * rotProp; - - // setup the data to the shader - double lt; - glm::dvec3 sunPosFromPlanet = - SpiceManager::ref().targetPosition("SUN", _target, "GALACTIC", {}, _time, lt); - sunPosFromPlanet *= 1000.0; // from Km to m - psc sun_pos = PowerScaledCoordinate::CreatePowerScaledCoordinate(sunPosFromPlanet.x, sunPosFromPlanet.y, sunPosFromPlanet.z); - - glm::dvec3 planetPosFromSun = - SpiceManager::ref().targetPosition(_target, "SUN", "GALACTIC", {}, _time, lt); - psc tmppos = PowerScaledCoordinate::CreatePowerScaledCoordinate(planetPosFromSun.x, planetPosFromSun.y, planetPosFromSun.z); - glm::vec3 cam_dir = glm::normalize(data.camera.position().vec3() - tmppos.vec3()); - - // This is camera position vector (camera direction) in world coordinates. - //_programObject->setUniform("cam_dir", cam_dir); - - //glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix(); - //glm::vec3 camSpaceEye = (-(modelview*data.position.vec4())).xyz; - //_programObject->setUniform("camdir", camSpaceEye); + transform = transform * rot * roty * rotProp; _programObject->setUniform("transparency", _alpha); _programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); @@ -649,9 +629,7 @@ void RenderablePlanet::render(const RenderData& data) float scaleFactor = data.camera.scaling().x * powf(10.0, data.camera.scaling().y); glm::mat4 scaleCamTrans = glm::scale(glm::mat4(1.0), glm::vec3(scaleFactor)); - // Is it wright not considering the camera rotation matrix here? - /*glm::mat4 ModelViewTrans = data.camera.viewMatrix() * scaleCamTrans * - data.camera.viewRotationMatrix() * translateCamTrans * translateObjTrans * transform;*/ + glm::mat4 ModelViewTrans = data.camera.viewMatrix() * scaleCamTrans * translateCamTrans * translateObjTrans * transform; if (_atmosphereEnabled) @@ -692,6 +670,8 @@ void RenderablePlanet::render(const RenderData& data) glCullFace(GL_BACK); // TODO: Move Calculations to VIEW SPACE (precision problems avoidance...) + + double lt; // Shadow calculations.. if (!_shadowConfArray.empty()) { std::vector shadowDataArray; @@ -848,232 +828,15 @@ void RenderablePlanet::render(const RenderData& data) // HDR _programObject->setUniform("exposure", 0.4f); - /*std::stringstream ss; - ss << "atmosphere-" << count++ << ".ppm"; - saveTextureToPPMFile(GL_COLOR_ATTACHMENT0, ss.str(), m_viewport[2], m_viewport[3]);*/ } - - // render _geometry->render(); // disable shader _programObject->deactivate(); - - - // - // - //// Render Atmosphere to a texture: - //if (_atmosphereEnabled) { - - // /*std::cout << "\nTestes..." << std::endl; - // glm::dvec3 sunPosSun = SpiceManager::ref().targetPosition("SUN", "SUN", "GALACTIC", {}, _time, lt); - // glm::dvec3 earthPosSun = SpiceManager::ref().targetPosition("EARTH", "SUN", "GALACTIC", {}, _time, lt); - // std::cout << "\n\nSun in Sun: " << sunPosSun.x << ", " << sunPosSun.y << ", " << sunPosSun.z << std::endl; - // std::cout << "\n\nEarth in Sun: " << earthPosSun.x << ", " << earthPosSun.y << ", " << earthPosSun.z << std::endl; - // std::cout << "\n\nCam Position in Sun: " << data.camera.position().vec3().x << ", " << data.camera.position().vec3().y << ", " << data.camera.position().vec3().z << std::endl; - // std::cout << "\n\nCam Position from Earth in Sun: " << cam_dir.x << ", " << cam_dir.y << ", " << cam_dir.z << std::endl; - // - // glm::dmat3 sun2earthMat = SpiceManager::ref().frameTransformationMatrix("GALACTIC", "IAU_EARTH", _time); - // glm::dvec3 sunPosEarth = sun2earthMat * sunPosSun; - // glm::dvec3 earthPosEarth = sun2earthMat * earthPosSun; - // glm::dvec3 camDirEarth = sun2earthMat * cam_dir; - // glm::dvec3 camPosEarth = sun2earthMat * data.camera.position().vec3(); - // std::cout << "\n\nSun in Earth: " << sunPosEarth.x << ", " << sunPosEarth.y << ", " << sunPosEarth.z << std::endl; - // std::cout << "\n\nEarth in Earth: " << earthPosEarth.x << ", " << earthPosEarth.y << ", " << earthPosEarth.z << std::endl; - // std::cout << "\n\nCam Position in Earth: " << camPosEarth.x << ", " << camPosEarth.y << ", " << camPosEarth.z << std::endl; - // std::cout << "\n\nCam Position from Earth in Earth: " << camDirEarth.x << ", " << camDirEarth.y << ", " << camDirEarth.z << std::endl; - - // glm::dvec3 sunPosView = glm::dvec3(data.camera.viewMatrix() * glm::dvec4(sunPosSun.x, sunPosSun.y, sunPosSun.z, 1.0)); - // glm::dvec3 earthPosView = glm::dvec3(data.camera.viewMatrix() * glm::dvec4(earthPosSun.x, earthPosSun.y, earthPosSun.z, 1.0)); - // glm::dvec3 camDirView = glm::dvec3(data.camera.viewMatrix() * glm::dvec4(cam_dir.x, cam_dir.y, cam_dir.z, 0.0)); - // glm::dvec3 camPosView = glm::dvec3(data.camera.viewMatrix() * glm::dvec4(data.camera.position().vec3().x, data.camera.position().vec3().y, data.camera.position().vec3().z, 1.0)); - // std::cout << "\n\nSun in View: " << sunPosView.x << ", " << sunPosView.y << ", " << sunPosView.z << std::endl; - // std::cout << "\n\nEarth in View: " << earthPosView.x << ", " << earthPosView.y << ", " << earthPosView.z << std::endl; - // std::cout << "\n\nCam Position in View: " << camPosView.x << ", " << camPosView.y << ", " << camPosView.z << std::endl; - // std::cout << "\n\nCam Position from Earth in View: " << camDirView.x << ", " << camDirView.y << ", " << camDirView.z << std::endl;*/ - - - // GLint defaultFBO; - // glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); - - // GLint m_viewport[4]; - // glGetIntegerv(GL_VIEWPORT, m_viewport); - - // glBindFramebuffer(GL_FRAMEBUFFER, _atmosphereFBO); - // glReadBuffer(GL_COLOR_ATTACHMENT1); - // GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; - // glDrawBuffers(2, drawBuffers); - - // if (!glIsTexture(_dummyTexture)) { - // _dummyTextureUnit.activate(); - // glGenTextures(1, &_dummyTexture); - // //glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _dummyTexture); - // glBindTexture(GL_TEXTURE_2D, _dummyTexture); - // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - // glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); - // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_viewport[2], - // m_viewport[3], 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); - // /*glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 8, GL_RGBA, - // m_viewport[2], m_viewport[3], true);*/ - // } - - // glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, _dummyTexture, 0); - // glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, _atmosphereTexture, 0); - // //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, _dummyTexture, 0); - // //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D_MULTISAMPLE, _atmosphereTexture, 0); - // if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { - // LERROR("Atmosphere Framework not built."); - // GLenum fbErr = glCheckFramebufferStatus(GL_FRAMEBUFFER); - // switch (fbErr) { - // case GL_FRAMEBUFFER_UNDEFINED: - // LERROR("Indefined framebuffer."); - // break; - // case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - // LERROR("Incomplete, missing attachement."); - // break; - // case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: - // LERROR("Framebuffer doesn't have at least one image attached to it."); - // break; - // case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: - // LERROR("Returned if the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE for any color attachment point(s) named by GL_DRAW_BUFFERi."); - // break; - // case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: - // LERROR("Returned if GL_READ_BUFFER is not GL_NONE and the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE for the color attachment point named by GL_READ_BUFFER."); - // break; - // case GL_FRAMEBUFFER_UNSUPPORTED: - // LERROR("Returned if the combination of internal formats of the attached images violates an implementation - dependent set of restrictions."); - // break; - // case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: - // LERROR("Returned if the value of GL_RENDERBUFFER_SAMPLES is not the same for all attached renderbuffers; if the value of GL_TEXTURE_SAMPLES is the not same for all attached textures; or , if the attached images are a mix of renderbuffers and textures, the value of GL_RENDERBUFFER_SAMPLES does not match the value of GL_TEXTURE_SAMPLES."); - // LERROR("Returned if the value of GL_TEXTURE_FIXED_SAMPLE_LOCATIONS is not the same for all attached textures; or , if the attached images are a mix of renderbuffers and textures, the value of GL_TEXTURE_FIXED_SAMPLE_LOCATIONS is not GL_TRUE for all attached textures."); - // break; - // case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: - // LERROR("Returned if any framebuffer attachment is layered, and any populated attachment is not layered, or if all populated color attachments are not from textures of the same target."); - // break; - // } - // } - - // GLenum err; - // while ((err = glGetError()) != GL_NO_ERROR) { - // const GLubyte * errorString = gluErrorString(err); - // std::stringstream ss; - // ss << "Error setting up atmosphere framebuffer. OpenGL error: " - // << err << " - " << errorString << std::endl; - // LERROR(ss.str()); - // } - - // glClearColor(1.0, 0.0, 0.0, 1.0); - // glClear(GL_COLOR_BUFFER_BIT); - // - // _atmosphereProgramObject->activate(); - // //glm::vec2 camScaling = data.camera.scaling(); - // ///*glm::mat4 invScaling = glm::scale(glm::mat4(1.0), glm::vec3(1.0 / (camScaling.x * pow(10.0, camScaling.y)))); - // //glm::mat4 invCamRot = glm::inverse(data.camera.viewRotationMatrix()); - // //glm::mat4 invTrans = glm::translate(glm::mat4(1.0), glm::vec3(-data.camera.position().vec4()));*/ - - // //glm::mat4 camScaleTrans = glm::scale(glm::mat4(1.0), glm::vec3(camScaling.x * pow(10.0, camScaling.y))); - // //glm::mat4 camRotationTrans = glm::mat4(glm::mat3(data.camera.viewRotationMatrix())); - // //glm::mat4 camTranslationTrans = glm::translate(glm::mat4(1.0), glm::vec3(-data.camera.position().vec4())); - - // //glm::mat4 completeInverse = glm::inverse(data.camera.viewProjectionMatrix() * camScaleTrans * - // // camRotationTrans * camTranslationTrans); - - - // // Object Space (in Km) - // glm::mat4 obj2World = glm::translate(glm::mat4(1.0), data.position.vec3() / 1000.0f); - // glm::mat4 M = data.camera.viewMatrix() * scaleCamTrans * data.camera.viewRotationMatrix() * - // translateCamTrans * obj2World * transform; - - // // World Space - // /*glm::mat4 M = data.camera.viewMatrix() * scaleCamTrans * data.camera.viewRotationMatrix() * - // translateCamTrans;*/ - - // //glm::mat4 completeInverse = glm::inverse(data.camera.projectionMatrix() * M); - // glm::mat4 completeInverse = glm::inverse(M); - - // //glm::mat4 completeInverse = glm::inverse(data.camera.projectionMatrix() * ModelViewTrans); - - // _atmosphereProgramObject->setUniform("completeInverse", completeInverse); - // _atmosphereProgramObject->setUniform("projInverse", glm::inverse(data.camera.projectionMatrix())); - // - // //// This is camera position and planet position vector in world coordinates, in Km. - // //glm::vec4 cameraPosWorld = glm::vec4(data.camera.position().vec3() / 1000.0f, 1.0); - // //glm::vec4 planetPositionWorld = glm::vec4(data.position.vec3() / 1000.0f, 1.0); - // //_atmosphereProgramObject->setUniform("cameraPosWorld", cameraPosWorld); - // //_atmosphereProgramObject->setUniform("planetPosition", planetPositionWorld); - // //// I know it is (0,0,0). It is here just for sake of sanity. :-p - // //glm::dvec3 sunPosWorld = - // // SpiceManager::ref().targetPosition("SUN", "SUN", "GALACTIC", {}, _time, lt); - // //_atmosphereProgramObject->setUniform("sunPositionWorld", sunPosWorld); - - // // This is camera position and planet position vector in object coordinates, in Km. - // glm::mat4 world2Obj = glm::inverse(obj2World * transform); - // glm::vec4 cameraPosObj = world2Obj * glm::vec4(data.camera.position().vec3() / 1000.0f, 1.0); - // glm::vec4 planetPositionObj = world2Obj * glm::vec4(data.position.vec3() / 1000.0f, 1.0); - // _atmosphereProgramObject->setUniform("cameraPosObj", cameraPosObj); - // _atmosphereProgramObject->setUniform("planetPositionObj", planetPositionObj); - // - // // I know it is (0,0,0). It is here just for sake of sanity. :-p - // glm::dvec3 sunPosWorld = - // SpiceManager::ref().targetPosition("SUN", "SUN", "GALACTIC", {}, _time, lt); - // glm::vec4 sunPosObj = world2Obj * glm::vec4(sunPosWorld.x, sunPosWorld.y, sunPosWorld.z, 1.0); - // _atmosphereProgramObject->setUniform("sunPositionObj", glm::vec3(sunPosObj)); - - // //// DEBUG: - // //std::cout << "\n\nSun in Obj Space: " << sunPosObj.x << ", " << sunPosObj.y << ", " << sunPosObj.z << std::endl; - // //std::cout << "\n\nEarth in Obj Space: " << planetPositionObj.x << ", " << planetPositionObj.y << ", " << planetPositionObj.z << std::endl; - // //std::cout << "\n\nCam in Obj Space: " << cameraPosObj.x << ", " << cameraPosObj.y << ", " << cameraPosObj.z << std::endl; - // - // _transmittanceTableTextureUnit.activate(); - // //glBindTexture(GL_TEXTURE_2D, _transmittanceTableTexture); - // _atmosphereProgramObject->setUniform("transmittanceSampler", _transmittanceTableTextureUnit); - - // _irradianceTableTextureUnit.activate(); - // //glBindTexture(GL_TEXTURE_2D, _irradianceTableTexture); - // _atmosphereProgramObject->setUniform("irradianceSampler", _irradianceTableTextureUnit); - - // _inScatteringTableTextureUnit.activate(); - // //glBindTexture(GL_TEXTURE_3D, _inScatteringTableTexture); - // _atmosphereProgramObject->setUniform("inscatterSampler", _inScatteringTableTextureUnit); - // - // if (_hasReflectanceTexture) { - // ghoul::opengl::TextureUnit reflectanceUnit; - // reflectanceUnit.activate(); - // _reflectanceTexture->bind(); - // _atmosphereProgramObject->setUniform("reflectanceSampler", reflectanceUnit); - // } - - // // HDR - // _atmosphereProgramObject->setUniform("exposure", 0.4f); - - // setPscUniforms(*_atmosphereProgramObject.get(), data.camera, data.position); - - // // check OpenGL error - // while ((err = glGetError()) != GL_NO_ERROR) { - // const GLubyte * errorString = gluErrorString(err); - // std::cout << "\n\nBefore Rendering Planet. OpenGL error: " - // << err << " - " << errorString << std::endl; - // } - - // renderQuadForCalc(_atmosphereRenderVAO, 6); - - // std::stringstream ss; - // ss << "atmosphere-" << count++ << ".ppm"; - // saveTextureToPPMFile(GL_COLOR_ATTACHMENT1, ss.str(), m_viewport[2], m_viewport[3]); - - // _atmosphereProgramObject->deactivate(); - - // glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - // glViewport(m_viewport[0], m_viewport[1], - // m_viewport[2], m_viewport[3]); - //} } void RenderablePlanet::update(const UpdateData& data) { diff --git a/modules/base/rendering/renderableplanet.h b/modules/base/rendering/renderableplanet.h index 089c8b1ab2..7f38b0d9ad 100644 --- a/modules/base/rendering/renderableplanet.h +++ b/modules/base/rendering/renderableplanet.h @@ -212,6 +212,8 @@ private: bool tempPic; unsigned int count; + + }; } // namespace openspace diff --git a/modules/newhorizons/rendering/renderablemodelprojection.cpp b/modules/newhorizons/rendering/renderablemodelprojection.cpp index f730eb032c..b203ee5f4a 100644 --- a/modules/newhorizons/rendering/renderablemodelprojection.cpp +++ b/modules/newhorizons/rendering/renderablemodelprojection.cpp @@ -90,8 +90,7 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di dictionary.getValue(keySource, _source); dictionary.getValue(keyDestination, _destination); dictionary.getValue(keyBody, _target); - if (_target != "") - setBody(_target); + bool completeSuccess = true; completeSuccess &= _projectionComponent.initializeProjectionSettings(dictionary); diff --git a/modules/newhorizons/rendering/renderableplaneprojection.cpp b/modules/newhorizons/rendering/renderableplaneprojection.cpp index 26a8acc25e..62b9c68c20 100644 --- a/modules/newhorizons/rendering/renderableplaneprojection.cpp +++ b/modules/newhorizons/rendering/renderableplaneprojection.cpp @@ -315,21 +315,8 @@ void RenderablePlaneProjection::setTarget(std::string body) { bool hasBody, found = false; std::string targetBody; - for (auto node : nodes) { - possibleTarget = node->renderable(); - if (possibleTarget != nullptr) { - hasBody = possibleTarget->hasBody(); - if (hasBody && possibleTarget->getBody(targetBody) && (targetBody == body)) { - _target.node = node->name(); // get name from propertyOwner - found = true; - break; - } - } - } - if (found) { - _target.body = body; - _target.frame = openspace::SpiceManager::ref().frameFromBody(body); - } + _target.body = body; + _target.frame = openspace::SpiceManager::ref().frameFromBody(body); } std::string RenderablePlaneProjection::findClosestTarget(double currentTime) { @@ -344,32 +331,9 @@ std::string RenderablePlaneProjection::findClosestTarget(double currentTime) { PowerScaledScalar min = PowerScaledScalar::CreatePSS(REALLY_FAR); PowerScaledScalar distance = PowerScaledScalar::CreatePSS(0.0); - std::string closestTarget = ""; - - double lt; - glm::dvec3 p = - SpiceManager::ref().targetPosition(_spacecraft, "SSB", GalacticFrame, {}, currentTime, lt); - psc spacecraftPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z); - for (auto node : nodes) - { - possibleTarget = node->renderable(); - if (possibleTarget != nullptr) { - hasBody = possibleTarget->hasBody(); - if (hasBody && possibleTarget->getBody(targetBody)) { - found = SpiceManager::ref().isTargetInFieldOfView(targetBody, _spacecraft, _instrument, SpiceManager::FieldOfViewMethod::Ellipsoid, {}, currentTime); - if (found){ - targets.push_back(node->name()); // get name from propertyOwner - distance = (psc::CreatePowerScaledCoordinate(node->worldPosition().x, node->worldPosition().y, node->worldPosition().z) - spacecraftPos).length(); - if (distance < min) - closestTarget = targetBody; - } - } - } - } - - return closestTarget; + return targetBody; } } // namespace openspace diff --git a/modules/newhorizons/rendering/renderableplanetprojection.cpp b/modules/newhorizons/rendering/renderableplanetprojection.cpp index 13516f1e5f..cb22a265bb 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.cpp +++ b/modules/newhorizons/rendering/renderableplanetprojection.cpp @@ -83,9 +83,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& } dictionary.getValue(keyFrame, _frame); - dictionary.getValue(keyBody, _target); - if (_target != "") - setBody(_target); + dictionary.getValue(keyBody, _body); success = _projectionComponent.initializeProjectionSettings(dictionary); ghoul_assert(success, ""); diff --git a/modules/newhorizons/rendering/renderableplanetprojection.h b/modules/newhorizons/rendering/renderableplanetprojection.h index b87d8922b2..c5f2553183 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.h +++ b/modules/newhorizons/rendering/renderableplanetprojection.h @@ -95,7 +95,7 @@ private: std::vector _imageTimes; - std::string _target; + std::string _body; std::string _frame; bool _capture; diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 767920c5c1..817fa18aff 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -74,8 +74,6 @@ Renderable::Renderable() : _enabled("enabled", "Is Enabled", true) , _startTime("") , _endTime("") - , _targetBody("") - , _hasBody(false) , _hasTimeInterval(false) { @@ -85,8 +83,6 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary) : _enabled("enabled", "Is Enabled", true) , _startTime("") , _endTime("") - , _targetBody("") - , _hasBody(false) , _hasTimeInterval(false) { setName("renderable"); @@ -156,10 +152,6 @@ bool Renderable::hasTimeInterval() { return _hasTimeInterval; } -bool Renderable::hasBody() { - return _hasBody; -} - bool Renderable::getInterval(double& start, double& end) { if (_startTime != "" && _endTime != "") { start = SpiceManager::ref().ephemerisTimeFromDate(_startTime); @@ -170,20 +162,6 @@ bool Renderable::getInterval(double& start, double& end) { return false; } -bool Renderable::getBody(std::string& body) { - if (_hasBody) { - body = _targetBody; - return true; - } - else - return false; -} - -void Renderable::setBody(std::string& body) { - _targetBody = body; - _hasBody = true; -} - bool Renderable::isReady() const { return true; }