mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-24 13:59:09 -06:00
WIP: transit method graph
This commit is contained in:
@@ -166,6 +166,28 @@ namespace openspace::exoplanets{
|
||||
);
|
||||
}
|
||||
|
||||
void addTransitGraphs() {
|
||||
std::string script = "openspace.addScreenSpaceRenderable("
|
||||
"{"
|
||||
"Identifier = 'Transit2',"
|
||||
"Type = 'ScreenSpaceImageLocal',"
|
||||
"TexturePath = openspace.absPath('${BASE}/modules/exoplanets/prick.png'),"
|
||||
"EuclideanPosition = {0.0, 0.0},"
|
||||
"});"
|
||||
"openspace.addScreenSpaceRenderable("
|
||||
"{"
|
||||
"Identifier = 'Transit1',"
|
||||
"Type = 'ScreenSpaceImageLocal',"
|
||||
"TexturePath = openspace.absPath('${BASE}/modules/exoplanets/graph.png'),"
|
||||
"EuclideanPosition = {0.0, -0.7},"
|
||||
"});";
|
||||
|
||||
OsEng.scriptEngine().queueScript(
|
||||
script,
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DiscoveryMethods::scaleNode(std::string nodeName, float scalefactor) {
|
||||
@@ -220,16 +242,8 @@ namespace openspace::exoplanets{
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
void DiscoveryMethods::moveCameraDopplerView(glm::dvec3 pos) {
|
||||
|
||||
Camera* cam = OsEng.navigationHandler().camera();
|
||||
cam->setPositionVec3(pos);
|
||||
OsEng.navigationHandler().resetCameraDirection();
|
||||
|
||||
}
|
||||
|
||||
void DiscoveryMethods::moveCameraTransitView(glm::dvec3 pos) {
|
||||
void DiscoveryMethods::moveCamera(glm::dvec3 pos) {
|
||||
|
||||
Camera* cam = OsEng.navigationHandler().camera();
|
||||
cam->setPositionVec3(pos);
|
||||
@@ -254,6 +268,14 @@ namespace openspace::exoplanets{
|
||||
);
|
||||
}
|
||||
|
||||
void DiscoveryMethods::setTransitImagePos(float valueX,float valueY) {
|
||||
std::string script = "openspace.setPropertyValueSingle( 'ScreenSpace.Transit2.EuclideanPosition', {" + std::to_string(valueX) + "," + std::to_string(valueY) + "}); ";
|
||||
OsEng.scriptEngine().queueScript(
|
||||
script,
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
void DiscoveryMethods::addDopplerMethodVisualization() {
|
||||
SceneGraphNode* focusNode = OsEng.navigationHandler().focusNode();
|
||||
std::string starName = OsEng.moduleEngine().module<ExoplanetsModule>()->getStarName(); // getStarName
|
||||
@@ -272,7 +294,7 @@ namespace openspace::exoplanets{
|
||||
// MOVE CAMERA
|
||||
glm::dvec3 faceOnVector = glm::normalize(glm::cross(starToSunVec, north));
|
||||
glm::dvec3 cameraPosition = starPosition + ((4.0 * semiMajorAxis * 149597870700.0) * faceOnVector);
|
||||
moveCameraDopplerView(cameraPosition);
|
||||
moveCamera(cameraPosition);
|
||||
// END CAMERA
|
||||
|
||||
// SCALE STAR AND PLANET
|
||||
@@ -355,8 +377,13 @@ namespace openspace::exoplanets{
|
||||
|
||||
// MOVE CAMERA
|
||||
//borde kanske va periapsis distance, men det går bra ändå
|
||||
glm::dvec3 cameraPosition = starPosition + ((3.0 * semiMajorAxis * 149597870700.0) * starToSunVec);;
|
||||
moveCameraTransitView(cameraPosition);
|
||||
glm::dvec3 north = OsEng.moduleEngine().module<ExoplanetsModule>()->getNorthVector();
|
||||
//glm::dvec3 faceOnVector = glm::normalize(glm::cross(starToSunVec, north));
|
||||
glm::dvec3 cameraPosition = starPosition + ((4.0 * semiMajorAxis * 149597870700.0) * starToSunVec);
|
||||
//glm::dvec3 cameraPosition = starPosition + ((3.0 * semiMajorAxis * 149597870700.0) * faceOnVector);
|
||||
|
||||
|
||||
moveCamera(cameraPosition);
|
||||
// END CAMERA
|
||||
toggleVisabilityPlanet(planetNames[0], "true");
|
||||
|
||||
@@ -366,17 +393,21 @@ namespace openspace::exoplanets{
|
||||
periapsisDistance *= 149597870700.0; // in m
|
||||
starRadius *= 6.957E8; // in m
|
||||
|
||||
float scale = (0.666 * periapsisDistance) / starRadius; // actual radius * scale = wanted radius
|
||||
float scale = (0.5 * periapsisDistance) / starRadius; // actual radius * scale = wanted radius
|
||||
scaleNode(starName + "Globe", scale);
|
||||
scaleNode(planetNames[0], scale); //eller använda getPlna()?
|
||||
_transitScaleFactor = scale;
|
||||
// END SCALE
|
||||
|
||||
// ADD THE GRAPH
|
||||
addTransitGraphs();
|
||||
// END GRAPH
|
||||
|
||||
// HELPER MARKERS
|
||||
glm::dvec3 north = OsEng.moduleEngine().module<ExoplanetsModule>()->getNorthVector();
|
||||
|
||||
glm::dvec3 northDirectionPos = starPosition + (double(starRadius * scale) * north);
|
||||
glm::dvec3 viewDirectionPos = starPosition + (double(starRadius * scale) * starToSunVec);
|
||||
addDirectionsMarkers(viewDirectionPos, northDirectionPos, starRadius);
|
||||
//addDirectionsMarkers(viewDirectionPos, northDirectionPos, starRadius);
|
||||
// END MARKERS
|
||||
}
|
||||
void DiscoveryMethods::removeTransitMethodVisualization() {
|
||||
@@ -386,7 +417,12 @@ namespace openspace::exoplanets{
|
||||
scaleNode(starName + "Globe", 1);
|
||||
scaleNode(planetNames[0], 1);
|
||||
|
||||
|
||||
// REMOVE GRAPH
|
||||
std::string script = "openspace.removeScreenSpaceRenderable('Transit2');openspace.removeScreenSpaceRenderable('Transit1');";
|
||||
OsEng.scriptEngine().queueScript(
|
||||
script,
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
|
||||
//REMOVE HELP MARKERS
|
||||
removeDirectionsMarkers();
|
||||
|
||||
@@ -38,8 +38,8 @@ public:
|
||||
bool isTransit();
|
||||
bool isReference();
|
||||
void setDopplerImagePos(float);
|
||||
void setTransitImagePos(float,float);
|
||||
float getTransitScaleFactor();
|
||||
//void setSunReferencePosition(glm::dvec3);
|
||||
|
||||
private:
|
||||
properties::BoolProperty _showTransit;
|
||||
@@ -57,8 +57,7 @@ private:
|
||||
void removeDirectionsMarkers();
|
||||
void scaleNode(std::string, float);
|
||||
void moveStar(std::string, float);
|
||||
void moveCameraTransitView(glm::dvec3);
|
||||
void moveCameraDopplerView(glm::dvec3);
|
||||
void moveCamera(glm::dvec3);
|
||||
void toggleVisabilityOuterPlanets(std::vector<std::string>, std::string);
|
||||
void toggleVisabilityPlanet(std::string, std::string);
|
||||
|
||||
|
||||
@@ -166,6 +166,85 @@ void ExoplanetsModule::internalInitialize(const ghoul::Dictionary&) {
|
||||
_discoveryMethods->setDopplerImagePos(imagePos);
|
||||
|
||||
}
|
||||
if (_discoveryMethods->isTransit()) {
|
||||
|
||||
std::string starName = OsEng.moduleEngine().module<ExoplanetsModule>()->getStarName();
|
||||
std::vector<std::string> planetNames = OsEng.moduleEngine().module<ExoplanetsModule>()->getPlna();
|
||||
SceneGraphNode* planetNode = OsEng.renderEngine().scene()->sceneGraphNode(planetNames[0]);
|
||||
SceneGraphNode* starNode = OsEng.renderEngine().scene()->sceneGraphNode(starName);
|
||||
glm::dvec3 planetPos = planetNode->worldPosition();
|
||||
glm::dvec3 starPos = starNode->worldPosition();
|
||||
|
||||
glm::dvec3 starToPosVec = planetPos - starPos;
|
||||
glm::dvec3 starToSunVec = normalize(glm::dvec3(0.0, 0.0, 0.0) - starPos);
|
||||
|
||||
std::vector<Exoplanet> planets = OsEng.moduleEngine().module<ExoplanetsModule>()->getPlsy();
|
||||
float starRadius = planets[0].RSTAR * 6.957E8 * _discoveryMethods->getTransitScaleFactor(); // in m
|
||||
|
||||
glm::dvec3 north = _north;
|
||||
float northAngle = glm::acos(glm::dot(normalize(starToPosVec), north)) * 57.2957795;
|
||||
float viewAngle = glm::acos(glm::dot(normalize(starToPosVec), starToSunVec)) * 57.2957795;
|
||||
|
||||
glm::dvec3 posVecProjected = starToPosVec - (((dot(starToPosVec, starToSunVec)) / (glm::length(starToSunVec)))*starToSunVec);
|
||||
float l = glm::length(posVecProjected); //in m
|
||||
float imageYPos = -0.6;
|
||||
if (l<(starRadius*0.76) && viewAngle <= 90.0) { // in front of star
|
||||
imageYPos = -0.8;
|
||||
}
|
||||
//imageYPos = -0.7;
|
||||
|
||||
float imageXPos = 0;
|
||||
if (viewAngle <= 90.0 && northAngle <= 90.0)
|
||||
{
|
||||
imageXPos = (viewAngle / 90.0) * 0.5;
|
||||
}
|
||||
else if (viewAngle > 90.0 && northAngle <= 90.0)
|
||||
{
|
||||
imageXPos = (viewAngle / 90.0) * 0.5;
|
||||
}
|
||||
else if (viewAngle > 90.0 && northAngle > 90.0)
|
||||
{
|
||||
imageXPos = (viewAngle / 90.0) * -0.5;
|
||||
}
|
||||
else if (viewAngle <= 90.0 && northAngle > 90.0)
|
||||
{
|
||||
imageXPos = (viewAngle / 90.0) * -0.5;
|
||||
}
|
||||
imageXPos *= 0.25;
|
||||
_discoveryMethods->setTransitImagePos(imageXPos, imageYPos);
|
||||
|
||||
//glm::dvec3 sunPos = glm::dvec3(0.0, 0.0, 0.0);
|
||||
/*Camera* cam = OsEng.navigationHandler().camera();
|
||||
glm::dvec3 sunPos = cam->positionVec3();
|
||||
glm::dvec3 radiusPos = starPos + (double(planets[0].RSTAR * _discoveryMethods->getTransitScaleFactor()) * _north);
|
||||
glm::dvec3 sunToRadius = normalize(radiusPos - sunPos);
|
||||
glm::dvec3 sunToStar = normalize(starPos - sunPos);
|
||||
|
||||
glm::dvec3 sunToPlanet = normalize(planetPos - sunPos);
|
||||
|
||||
|
||||
double angleRadiusStar = glm::acos(glm::dot(sunToRadius, sunToStar))*57.2957795;
|
||||
|
||||
double anglePlanetStar = glm::acos(glm::dot(sunToPlanet, sunToStar))*57.2957795;
|
||||
|
||||
glm::dvec3 starToSun = normalize(sunPos - starPos);
|
||||
glm::dvec3 starToPlanet = normalize(planetPos - starPos);
|
||||
|
||||
double anglePlanetSun = glm::dot(starToPlanet, starToSun); //glm::acos(glm::dot(starToPlanet, starToSun)) * 57.2957795;
|
||||
|
||||
float anglePlanetNorth = glm::acos(glm::dot(starToPlanet, _north)) * 57.2957795;
|
||||
|
||||
//
|
||||
float imageYPos = 1.0;
|
||||
//float viewAngle = glm::acos(glm::dot(starToPlanet, starToSun)) * 57.2957795;
|
||||
//TRANSITING
|
||||
if (anglePlanetStar < angleRadiusStar && anglePlanetSun >= 0.0) {
|
||||
imageYPos = -1.0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user