mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-21 11:39:51 -06:00
Clearified latlon interface.
This commit is contained in:
@@ -67,7 +67,7 @@ namespace openspace {
|
||||
glm::sin(lat));
|
||||
}
|
||||
|
||||
Vec2 LatLon::asVec2() const {
|
||||
Vec2 LatLon::toLonLatVec2() const {
|
||||
return Vec2(lon, lat);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ struct LatLon {
|
||||
|
||||
static LatLon fromCartesian(const Vec3& v);
|
||||
Vec3 asUnitCartesian();
|
||||
Vec2 asVec2() const;
|
||||
Vec2 toLonLatVec2() const;
|
||||
|
||||
inline bool operator==(const LatLon& other);
|
||||
inline bool operator!=(const LatLon& other) { return !(*this == (other)); }
|
||||
|
||||
@@ -128,8 +128,8 @@ namespace openspace {
|
||||
|
||||
LatLon swCorner = patch.southWestCorner();
|
||||
_programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform);
|
||||
_programObject->setUniform("minLatLon", vec2(swCorner.asVec2()));
|
||||
_programObject->setUniform("latLonScalingFactor", 2.0f * vec2(patch.halfSize.asVec2()));
|
||||
_programObject->setUniform("minLatLon", vec2(swCorner.toLonLatVec2()));
|
||||
_programObject->setUniform("lonLatScalingFactor", 2.0f * vec2(patch.halfSize.toLonLatVec2()));
|
||||
_programObject->setUniform("globeRadius", float(radius));
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
@@ -200,8 +200,8 @@ namespace openspace {
|
||||
//LDEBUG("contraction = [ " << contraction.x << " , " << contraction.y << " ]");
|
||||
|
||||
_programObject->setUniform("modelViewProjectionTransform", data.camera.projectionMatrix() * viewTransform * modelTransform);
|
||||
_programObject->setUniform("minLatLon", vec2(swCorner.asVec2()));
|
||||
_programObject->setUniform("latLonScalingFactor", 2.0f * vec2(patch.halfSize.lat, patch.halfSize.lon));
|
||||
_programObject->setUniform("minLatLon", vec2(swCorner.toLonLatVec2()));
|
||||
_programObject->setUniform("lonLatScalingFactor", 2.0f * vec2(patch.halfSize.toLonLatVec2()));
|
||||
_programObject->setUniform("globeRadius", float(radius));
|
||||
_programObject->setUniform("contraction", contraction);
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace openspace {
|
||||
int level = log2(static_cast<int>(glm::max(
|
||||
sizeLevel0.lat / patch.halfSize.lat * 2,
|
||||
sizeLevel0.lon / patch.halfSize.lon * 2)));
|
||||
Vec2 TileSize = sizeLevel0.asVec2() / pow(2, level);
|
||||
glm::ivec2 tileIndex = -(patch.northWestCorner().asVec2() + offsetLevel0.asVec2()) / TileSize;
|
||||
Vec2 TileSize = sizeLevel0.toLonLatVec2() / pow(2, level);
|
||||
glm::ivec2 tileIndex = -(patch.northWestCorner().toLonLatVec2() + offsetLevel0.toLonLatVec2()) / TileSize;
|
||||
return glm::ivec3(tileIndex, level);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ uniform mat4 modelViewProjectionTransform;
|
||||
uniform float globeRadius;
|
||||
|
||||
uniform vec2 minLatLon;
|
||||
uniform vec2 latLonScalingFactor;
|
||||
uniform vec2 lonLatScalingFactor;
|
||||
uniform ivec2 contraction; // [-1, 1]
|
||||
|
||||
layout(location = 1) in vec2 in_uv;
|
||||
@@ -46,10 +46,10 @@ vec3 latLonToCartesian(float latitude, float longitude, float radius) {
|
||||
}
|
||||
|
||||
vec3 globalInterpolation(vec2 uv) {
|
||||
vec2 latLonInput;
|
||||
latLonInput.y = minLatLon.y + latLonScalingFactor.y * uv.y; // Lat
|
||||
latLonInput.x = minLatLon.x + latLonScalingFactor.x * uv.x; // Lon
|
||||
vec3 positionModelSpace = latLonToCartesian(latLonInput.y, latLonInput.x, globeRadius);
|
||||
vec2 lonLatInput;
|
||||
lonLatInput.y = minLatLon.y + lonLatScalingFactor.y * uv.y; // Lat
|
||||
lonLatInput.x = minLatLon.x + lonLatScalingFactor.x * uv.x; // Lon
|
||||
vec3 positionModelSpace = latLonToCartesian(lonLatInput.y, lonLatInput.x, globeRadius);
|
||||
return positionModelSpace;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ uniform mat4 modelViewProjectionTransform;
|
||||
uniform float globeRadius;
|
||||
|
||||
uniform vec2 minLatLon;
|
||||
uniform vec2 latLonScalingFactor;
|
||||
uniform vec2 lonLatScalingFactor;
|
||||
|
||||
layout(location = 1) in vec2 in_UV;
|
||||
|
||||
@@ -45,10 +45,10 @@ vec3 latLonToCartesian(float latitude, float longitude, float radius) {
|
||||
}
|
||||
|
||||
vec3 globalInterpolation() {
|
||||
vec2 latLonInput;
|
||||
latLonInput.y = minLatLon.y + latLonScalingFactor.y * in_UV.y; // Lat
|
||||
latLonInput.x = minLatLon.x + latLonScalingFactor.x * in_UV.x; // Lon
|
||||
vec3 positionModelSpace = latLonToCartesian(latLonInput.y, latLonInput.x, globeRadius);
|
||||
vec2 lonLatInput;
|
||||
lonLatInput.y = minLatLon.y + lonLatScalingFactor.y * in_UV.y; // Lat
|
||||
lonLatInput.x = minLatLon.x + lonLatScalingFactor.x * in_UV.x; // Lon
|
||||
vec3 positionModelSpace = latLonToCartesian(lonLatInput.y, lonLatInput.x, globeRadius);
|
||||
return positionModelSpace;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user