mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-13 08:58:54 -05:00
Solved merge conflict
This commit is contained in:
@@ -38,6 +38,8 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapglobe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunklodglobe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/frustrumculler.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/texturetile.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/texturetileset.h
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/chunknode.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/latlon.h
|
||||
@@ -45,19 +47,21 @@ set(HEADER_FILES
|
||||
)
|
||||
|
||||
set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/geometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/gridgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/globemesh.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/patchrenderer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunklodglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/frustrumculler.cpp
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/chunknode.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/latlon.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/geometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/gridgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/globemesh.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/patchrenderer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunklodglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/frustrumculler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/texturetile.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/texturetileset.cpp
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/chunknode.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/latlon.cpp
|
||||
|
||||
)
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
@@ -36,6 +36,11 @@ namespace openspace {
|
||||
// LATITUDE LONGITUDE //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LatLon::LatLon()
|
||||
: lat(0)
|
||||
, lon(0)
|
||||
{}
|
||||
|
||||
LatLon::LatLon(Scalar latitude, Scalar longitude)
|
||||
: lat(latitude)
|
||||
, lon(longitude)
|
||||
@@ -62,8 +67,8 @@ namespace openspace {
|
||||
glm::sin(lat));
|
||||
}
|
||||
|
||||
Vec2 LatLon::asVec2() const {
|
||||
return Vec2(lat, lon);
|
||||
Vec2 LatLon::toLonLatVec2() const {
|
||||
return Vec2(lon, lat);
|
||||
}
|
||||
|
||||
bool LatLon::operator==(const LatLon& other) {
|
||||
|
||||
@@ -39,12 +39,13 @@ typedef glm::dvec3 Vec3;
|
||||
namespace openspace {
|
||||
|
||||
struct LatLon {
|
||||
LatLon();
|
||||
LatLon(Scalar latitude, Scalar longitude);
|
||||
LatLon(const LatLon& src);
|
||||
|
||||
static LatLon fromCartesian(const Vec3& v);
|
||||
Vec3 asUnitCartesian() const;
|
||||
Vec2 asVec2() const;
|
||||
Vec2 toLonLatVec2() const;
|
||||
|
||||
inline bool operator==(const LatLon& other);
|
||||
inline bool operator!=(const LatLon& other) { return !(*this == (other)); }
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace openspace {
|
||||
const glm::vec2& pointScreenSpace,
|
||||
const glm::vec2& marginScreenSpace) const;
|
||||
|
||||
|
||||
glm::vec2 transformToScreenSpace(const vec3& point, const mat4x4& modelViewProjection) const;
|
||||
|
||||
};
|
||||
|
||||
@@ -102,10 +102,17 @@ namespace openspace {
|
||||
* viewTransform * modelTransform;
|
||||
|
||||
|
||||
// Get the textures that should be used for rendering
|
||||
glm::ivec3 tileIndex = tileSet.getTileIndex(patch);
|
||||
LatLonPatch tilePatch = tileSet.getTilePositionAndScale(tileIndex);
|
||||
TextureTile tile00 = tileSet.getTile(tileIndex);
|
||||
|
||||
// Upload the tile to the GPU (a lot of caching things should be done)
|
||||
|
||||
LatLon swCorner = patch.southWestCorner();
|
||||
_programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform);
|
||||
_programObject->setUniform("minLatLon", vec2(swCorner.lat, swCorner.lon));
|
||||
_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);
|
||||
@@ -170,8 +177,8 @@ namespace openspace {
|
||||
//LDEBUG("contraction = [ " << contraction.x << " , " << contraction.y << " ]");
|
||||
|
||||
_programObject->setUniform("modelViewProjectionTransform", data.camera.projectionMatrix() * viewTransform * modelTransform);
|
||||
_programObject->setUniform("minLatLon", vec2(swCorner.lat, swCorner.lon));
|
||||
_programObject->setUniform("latLonScalingFactor", 2.0f * vec2(halfSize.lat, halfSize.lon));
|
||||
_programObject->setUniform("minLatLon", vec2(swCorner.toLonLatVec2()));
|
||||
_programObject->setUniform("lonLatScalingFactor", 2.0f * vec2(halfSize.toLonLatVec2()));
|
||||
_programObject->setUniform("globeRadius", float(radius));
|
||||
_programObject->setUniform("contraction", contraction);
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <modules/globebrowsing/datastructures/latlon.h>
|
||||
#include <modules/globebrowsing/rendering/gridgeometry.h>
|
||||
#include <modules/globebrowsing/rendering/frustrumculler.h>
|
||||
#include <modules/globebrowsing/rendering/texturetileset.h>
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
@@ -66,6 +67,7 @@ namespace openspace {
|
||||
unique_ptr<ProgramObject> _programObject;
|
||||
shared_ptr<Geometry> _geometry;
|
||||
|
||||
TextureTileSet tileSet;
|
||||
};
|
||||
|
||||
|
||||
|
||||
36
modules/globebrowsing/rendering/texturetile.cpp
Normal file
36
modules/globebrowsing/rendering/texturetile.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/rendering/texturetile.h>
|
||||
|
||||
namespace openspace {
|
||||
TextureTile::TextureTile()
|
||||
{
|
||||
}
|
||||
|
||||
TextureTile::~TextureTile()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
46
modules/globebrowsing/rendering/texturetile.h
Normal file
46
modules/globebrowsing/rendering/texturetile.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __TEXTURETILE_H__
|
||||
#define __TEXTURETILE_H__
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class TextureTile
|
||||
{
|
||||
public:
|
||||
TextureTile();
|
||||
~TextureTile();
|
||||
|
||||
private:
|
||||
glm::ivec2 positionIndex;
|
||||
int level;
|
||||
};
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __TEXTURETILE_H__
|
||||
72
modules/globebrowsing/rendering/texturetileset.cpp
Normal file
72
modules/globebrowsing/rendering/texturetileset.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/rendering/texturetileset.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace openspace {
|
||||
TextureTileSet::TextureTileSet()
|
||||
{
|
||||
}
|
||||
|
||||
TextureTileSet::~TextureTileSet()
|
||||
{
|
||||
}
|
||||
|
||||
glm::ivec3 TextureTileSet::getTileIndex(LatLonPatch patch)
|
||||
{
|
||||
int level = log2(static_cast<int>(glm::max(
|
||||
sizeLevel0.lat / patch.halfSize().lat * 2,
|
||||
sizeLevel0.lon / patch.halfSize().lon * 2)));
|
||||
Vec2 TileSize = sizeLevel0.toLonLatVec2() / pow(2, level);
|
||||
glm::ivec2 tileIndex = -(patch.northWestCorner().toLonLatVec2() + offsetLevel0.toLonLatVec2()) / TileSize;
|
||||
return glm::ivec3(tileIndex, level);
|
||||
}
|
||||
|
||||
TextureTile TextureTileSet::getTile(LatLonPatch patch)
|
||||
{
|
||||
return getTile(getTileIndex(patch));
|
||||
}
|
||||
|
||||
TextureTile TextureTileSet::getTile(glm::ivec3 tileIndex)
|
||||
{
|
||||
return TextureTile();
|
||||
}
|
||||
|
||||
LatLonPatch TextureTileSet::getTilePositionAndScale(glm::ivec3 tileIndex)
|
||||
{
|
||||
LatLon tileSize = LatLon(
|
||||
sizeLevel0.lat / pow(2, tileIndex.z),
|
||||
sizeLevel0.lon / pow(2, tileIndex.z));
|
||||
LatLon northWest = LatLon(
|
||||
offsetLevel0.lat + tileIndex.y * tileSize.lat,
|
||||
offsetLevel0.lon + tileIndex.x * tileSize.lon);
|
||||
|
||||
return LatLonPatch(
|
||||
LatLon(northWest.lat + tileSize.lat / 2, northWest.lon + tileSize.lon / 2),
|
||||
LatLon(tileSize.lat / 2, tileSize.lon / 2));
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
56
modules/globebrowsing/rendering/texturetileset.h
Normal file
56
modules/globebrowsing/rendering/texturetileset.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __TEXTURETILESET_H__
|
||||
#define __TEXTURETILESET_H__
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include <modules/globebrowsing/datastructures/latlon.h>
|
||||
#include <modules/globebrowsing/rendering/texturetile.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class TextureTileSet
|
||||
{
|
||||
public:
|
||||
TextureTileSet();
|
||||
~TextureTileSet();
|
||||
|
||||
/// Returns the index of the tile at an appropriate level.
|
||||
/// Appropriate meaning that the tile should be at as high level as possible
|
||||
/// Without the tile being smaller than the patch in lat-lon space.
|
||||
/// The tile needs to be at least as big as the patch.
|
||||
glm::ivec3 getTileIndex(LatLonPatch patch);
|
||||
TextureTile getTile(LatLonPatch patch);
|
||||
TextureTile getTile(glm::ivec3 tileIndex);
|
||||
LatLonPatch getTilePositionAndScale(glm::ivec3 tileIndex);
|
||||
private:
|
||||
LatLon sizeLevel0;
|
||||
LatLon offsetLevel0;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __TEXTURETILESET_H__
|
||||
@@ -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.x = minLatLon.x + latLonScalingFactor.x * uv.y; // Lat
|
||||
latLonInput.y = minLatLon.y + latLonScalingFactor.y * uv.x; // Lon
|
||||
vec3 positionModelSpace = latLonToCartesian(latLonInput.x, latLonInput.y, 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.x = minLatLon.x + latLonScalingFactor.x * in_UV.y; // Lat
|
||||
latLonInput.y = minLatLon.y + latLonScalingFactor.y * in_UV.x; // Lon
|
||||
vec3 positionModelSpace = latLonToCartesian(latLonInput.x, latLonInput.y, 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