mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 12:59:07 -06:00
resolved merge conflict
This commit is contained in:
@@ -31,8 +31,9 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableglobe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/geometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/gridgeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapgeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/grid.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/basicgrid.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapgrid.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/globemesh.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/patchrenderer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapglobe.h
|
||||
@@ -41,6 +42,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/texturetileset.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/twmstileprovider.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmappyramid.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/gdaldataconverter.h
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/chunknode.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/latlon.h
|
||||
@@ -53,8 +55,9 @@ 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/grid.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/basicgrid.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapgrid.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/globemesh.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/patchrenderer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapglobe.cpp
|
||||
@@ -63,6 +66,7 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/texturetileset.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/twmstileprovider.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmappyramid.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/gdaldataconverter.cpp
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/chunknode.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/latlon.cpp
|
||||
|
||||
175
modules/globebrowsing/rendering/basicgrid.cpp
Normal file
175
modules/globebrowsing/rendering/basicgrid.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/basicgrid.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "BasicGrid";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
BasicGrid::BasicGrid(
|
||||
unsigned int xSegments,
|
||||
unsigned int ySegments,
|
||||
Geometry::Positions usePositions,
|
||||
Geometry::TextureCoordinates useTextureCoordinates,
|
||||
Geometry::Normals useNormals)
|
||||
: Grid(
|
||||
xSegments,
|
||||
ySegments,
|
||||
usePositions,
|
||||
useTextureCoordinates,
|
||||
useNormals)
|
||||
{
|
||||
_geometry = std::unique_ptr<Geometry>(new Geometry(
|
||||
CreateElements(xSegments, ySegments),
|
||||
usePositions,
|
||||
useTextureCoordinates,
|
||||
useNormals));
|
||||
|
||||
if (usePositions == Geometry::Positions::Yes) {
|
||||
_geometry->setVertexPositions(CreatePositions(_xSegments, _ySegments));
|
||||
}
|
||||
if (useTextureCoordinates == Geometry::TextureCoordinates::Yes) {
|
||||
_geometry->setVertexTextureCoordinates(CreateTextureCoordinates(_xSegments, _ySegments));
|
||||
}
|
||||
if (useNormals == Geometry::Normals::Yes) {
|
||||
_geometry->setVertexNormals(CreateNormals(_xSegments, _ySegments));
|
||||
}
|
||||
}
|
||||
|
||||
BasicGrid::~BasicGrid()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int BasicGrid::xSegments() const {
|
||||
return _xSegments;
|
||||
}
|
||||
|
||||
int BasicGrid::ySegments() const {
|
||||
return _ySegments;
|
||||
}
|
||||
|
||||
void BasicGrid::validate(int xSegments, int ySegments) {
|
||||
ghoul_assert(xSegments > 0 && ySegments > 0,
|
||||
"Resolution must be at least 1x1. (" << xSegments << ", " << ySegments << ")");
|
||||
}
|
||||
|
||||
inline size_t BasicGrid::numElements(int xSegments, int ySegments){
|
||||
return 3 * 2 * xSegments * ySegments;
|
||||
}
|
||||
|
||||
inline size_t BasicGrid::numVertices(int xSegments, int ySegments) {
|
||||
return (xSegments + 1) * (ySegments + 1);
|
||||
}
|
||||
|
||||
std::vector<GLuint> BasicGrid::CreateElements(int xSegments, int ySegments) {
|
||||
validate(xSegments, ySegments);
|
||||
|
||||
std::vector<GLuint> elements;
|
||||
elements.reserve(numElements(xSegments, ySegments));
|
||||
for (unsigned int y = 0; y < ySegments; y++) {
|
||||
for (unsigned int x = 0; x < xSegments; x++) {
|
||||
|
||||
// x v01---v11 x ..
|
||||
// | / |
|
||||
// x v00---v10 x ..
|
||||
//
|
||||
// x x x x ..
|
||||
// : : : :
|
||||
|
||||
GLuint v00 = (y + 0) * (xSegments + 1) + x + 0;
|
||||
GLuint v10 = (y + 0) * (xSegments + 1) + x + 1;
|
||||
GLuint v01 = (y + 1) * (xSegments + 1) + x + 0;
|
||||
GLuint v11 = (y + 1) * (xSegments + 1) + x + 1;
|
||||
|
||||
// add upper triangle
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
// add lower triangle
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
std::vector<glm::vec4> BasicGrid::CreatePositions(
|
||||
int xSegments,
|
||||
int ySegments)
|
||||
{
|
||||
validate(xSegments, ySegments);
|
||||
std::vector<glm::vec4> positions;
|
||||
positions.reserve(numVertices(xSegments, ySegments));
|
||||
|
||||
// Copy from 2d texture coordinates and use as template to create positions
|
||||
std::vector<glm::vec2> templateTextureCoords = CreateTextureCoordinates(xSegments, ySegments);
|
||||
for (unsigned int i = 0; i < templateTextureCoords.size(); i++)
|
||||
{
|
||||
positions.push_back(glm::vec4(
|
||||
templateTextureCoords[i],
|
||||
0.0f,
|
||||
1.0f
|
||||
));
|
||||
}
|
||||
return positions;
|
||||
}
|
||||
|
||||
std::vector<glm::vec2> BasicGrid::CreateTextureCoordinates(int xSegments, int ySegments){
|
||||
validate(xSegments, ySegments);
|
||||
std::vector<glm::vec2> textureCoordinates;
|
||||
textureCoordinates.reserve(numVertices(xSegments, ySegments));
|
||||
|
||||
for (unsigned int y = 0; y < ySegments + 1; y++) {
|
||||
for (unsigned int x = 0; x < xSegments + 1; x++) {
|
||||
textureCoordinates.push_back(glm::vec2(
|
||||
static_cast<float>(x) / static_cast<float>(xSegments),
|
||||
static_cast<float>(y) / static_cast<float>(ySegments)
|
||||
));
|
||||
}
|
||||
}
|
||||
return textureCoordinates;
|
||||
}
|
||||
|
||||
std::vector<glm::vec3> BasicGrid::CreateNormals(int xSegments, int ySegments) {
|
||||
validate(xSegments, ySegments);
|
||||
std::vector<glm::vec3> normals;
|
||||
normals.reserve(numVertices(xSegments, ySegments));
|
||||
|
||||
for (unsigned int y = 0; y < ySegments + 1; y++) {
|
||||
for (unsigned int x = 0; x < xSegments + 1; x++) {
|
||||
normals.push_back(glm::vec3(0, 0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
return normals;
|
||||
}
|
||||
|
||||
}// namespace openspace
|
||||
@@ -22,49 +22,53 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __CLIPMAPGEOMETRY_H__
|
||||
#define __CLIPMAPGEOMETRY_H__
|
||||
|
||||
#include <modules/globebrowsing/rendering/geometry.h>
|
||||
#ifndef __BASICGRIDGEOMETRY_H__
|
||||
#define __BASICGRIDGEOMETRY_H__
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <modules/globebrowsing/rendering/grid.h>
|
||||
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ClipMapGeometry : public Geometry
|
||||
class BasicGrid : public Grid
|
||||
{
|
||||
public:
|
||||
ClipMapGeometry(
|
||||
unsigned int resolution,
|
||||
Positions usePositions = Positions::No,
|
||||
TextureCoordinates useTextures = TextureCoordinates::Yes,
|
||||
Normals useNormals = Normals::No
|
||||
);
|
||||
/**
|
||||
\param xSegments is the number of grid cells in the x direction.
|
||||
\param ySegments is the number of grid cells in the y direction.
|
||||
\param usePositions determines whether or not to upload any vertex position data
|
||||
to the GPU.
|
||||
\param useTextureCoordinates determines whether or not to upload any vertex texture
|
||||
coordinate data to the GPU.
|
||||
\param useNormals determines whether or not to upload any vertex normal data
|
||||
to the GPU.
|
||||
*/
|
||||
BasicGrid(
|
||||
unsigned int xSegments,
|
||||
unsigned int ySegments,
|
||||
Geometry::Positions usePositions,
|
||||
Geometry::TextureCoordinates useTextureCoordinates,
|
||||
Geometry::Normals useNormals);
|
||||
~BasicGrid();
|
||||
|
||||
~ClipMapGeometry();
|
||||
|
||||
const unsigned int resolution() const;
|
||||
virtual int xSegments() const;
|
||||
virtual int ySegments() const;
|
||||
|
||||
static size_t numVerticesBottom(unsigned int resolution);
|
||||
static size_t numVerticesLeft(unsigned int resolution);
|
||||
static size_t numVerticesRight(unsigned int resolution);
|
||||
static size_t numVerticesTop(unsigned int resolution);
|
||||
|
||||
static size_t numElements(unsigned int resolution);
|
||||
static size_t numVertices(unsigned int resolution);
|
||||
private:
|
||||
static std::vector<GLuint> CreateElements(unsigned int resoluion);
|
||||
static std::vector<glm::vec4> CreatePositions(unsigned int resolution);
|
||||
static std::vector<glm::vec2> CreateTextureCoordinates(unsigned int resolution);
|
||||
static std::vector<glm::vec3> CreateNormals(unsigned int resolution);
|
||||
virtual std::vector<GLuint> CreateElements( int xRes, int yRes);
|
||||
virtual std::vector<glm::vec4> CreatePositions( int xRes, int yRes);
|
||||
virtual std::vector<glm::vec2> CreateTextureCoordinates( int xRes, int yRes);
|
||||
virtual std::vector<glm::vec3> CreateNormals( int xRes, int yRes);
|
||||
|
||||
static void validate(unsigned int resolution);
|
||||
void validate(int xSegments, int ySegments);
|
||||
|
||||
// _resolution defines how many grid squares the geometry has in one direction.
|
||||
// In its uncontracted state, the clipmap geometry will have two extra grid squares
|
||||
// in each direction.
|
||||
unsigned int _resolution;
|
||||
inline size_t numElements(int xSegments, int ySegments);
|
||||
inline size_t numVertices(int xSegments, int ySegments);
|
||||
};
|
||||
} // namespace openspace
|
||||
#endif // __CLIPMAPGEOMETRY_H__
|
||||
#endif // __BASICGRIDGEOMETRY_H__
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <modules/globebrowsing/rendering/chunklodglobe.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/basicgrid.h>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
@@ -79,7 +81,9 @@ namespace openspace {
|
||||
|
||||
// ---------
|
||||
// init Renderer
|
||||
auto geometry = std::shared_ptr<Geometry>(new GridGeometry(10, 10,
|
||||
auto geometry = std::shared_ptr<BasicGrid>(new BasicGrid(
|
||||
10,
|
||||
10,
|
||||
Geometry::Positions::No,
|
||||
Geometry::TextureCoordinates::Yes,
|
||||
Geometry::Normals::No));
|
||||
|
||||
@@ -1,291 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/clipmapgeometry.h>
|
||||
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ClipMapGeometry";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ClipMapGeometry::ClipMapGeometry(
|
||||
unsigned int resolution,
|
||||
Positions usePositions,
|
||||
TextureCoordinates useTextures,
|
||||
Normals useNormals)
|
||||
: Geometry(CreateElements(resolution), usePositions, useTextures, useNormals)
|
||||
, _resolution(resolution)
|
||||
{
|
||||
if(_useVertexPositions){
|
||||
setVertexPositions(CreatePositions(_resolution));
|
||||
}
|
||||
if (_useTextureCoordinates) {
|
||||
setVertexTextureCoordinates(CreateTextureCoordinates(_resolution));
|
||||
}
|
||||
if (_useVertexNormals) {
|
||||
setVertexNormals(CreateNormals(_resolution));
|
||||
}
|
||||
}
|
||||
|
||||
ClipMapGeometry::~ClipMapGeometry()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const unsigned int ClipMapGeometry::resolution() const {
|
||||
return _resolution;
|
||||
}
|
||||
|
||||
size_t ClipMapGeometry::numElements(unsigned int resolution)
|
||||
{
|
||||
int numElementsInTotalSquare = 6 * (resolution + 1) * (resolution + 1);
|
||||
int numElementsInHole = 6 * (resolution / 4 * resolution / 4);
|
||||
return numElementsInTotalSquare - numElementsInHole;
|
||||
}
|
||||
|
||||
size_t ClipMapGeometry::numVerticesBottom(unsigned int resolution)
|
||||
{
|
||||
return (resolution + 1 + 2) * (resolution / 4 + 1 + 1);
|
||||
}
|
||||
|
||||
size_t ClipMapGeometry::numVerticesLeft(unsigned int resolution)
|
||||
{
|
||||
return (resolution / 4 + 1 + 1) * (resolution / 2 + 1);
|
||||
}
|
||||
|
||||
size_t ClipMapGeometry::numVerticesRight(unsigned int resolution)
|
||||
{
|
||||
return (resolution / 4 + 1 + 1) * (resolution / 2 + 1);
|
||||
}
|
||||
|
||||
size_t ClipMapGeometry::numVerticesTop(unsigned int resolution)
|
||||
{
|
||||
return (resolution + 1 + 2) * (resolution / 4 + 1 + 1);
|
||||
}
|
||||
|
||||
size_t ClipMapGeometry::numVertices(unsigned int resolution)
|
||||
{
|
||||
return numVerticesBottom(resolution) +
|
||||
numVerticesLeft(resolution) +
|
||||
numVerticesRight(resolution) +
|
||||
numVerticesTop(resolution);
|
||||
}
|
||||
|
||||
void ClipMapGeometry::validate(unsigned int resolution) {
|
||||
ghoul_assert(resolution >= 8,
|
||||
"Resolution must be at least 8. (" << resolution << ")");
|
||||
ghoul_assert(resolution == pow(2, int(log2(resolution))),
|
||||
"Resolution must be a power of 2. (" << resolution << ")");
|
||||
}
|
||||
|
||||
std::vector<GLuint> ClipMapGeometry::CreateElements(unsigned int resolution) {
|
||||
validate(resolution);
|
||||
std::vector<GLuint> elements;
|
||||
elements.reserve(numElements(resolution));
|
||||
|
||||
// The clipmap geometry is built up by four parts as follows:
|
||||
// 0 = Bottom part
|
||||
// 1 = Left part
|
||||
// 2 = Right part
|
||||
// 3 = Top part
|
||||
//
|
||||
// 33333333
|
||||
// 33333333
|
||||
// 11 22
|
||||
// 11 22
|
||||
// 00000000
|
||||
// 00000000
|
||||
|
||||
|
||||
// x v01---v11 x ..
|
||||
// | / |
|
||||
// x v00---v10 x ..
|
||||
//
|
||||
// x x x x ..
|
||||
// : : : :
|
||||
|
||||
unsigned int previousVerts[4];
|
||||
previousVerts[0] = 0;
|
||||
previousVerts[1] = previousVerts[0] + numVerticesBottom(resolution);
|
||||
previousVerts[2] = previousVerts[1] + numVerticesLeft(resolution);
|
||||
previousVerts[3] = previousVerts[2] + numVerticesRight(resolution);
|
||||
|
||||
// Build the bottom part of the clipmap geometry
|
||||
for (unsigned int y = 0; y < resolution / 4 + 1; y++) {
|
||||
for (unsigned int x = 0; x < resolution + 2; x++) {
|
||||
GLuint v00 = previousVerts[0] + (y + 0) * (resolution + 3) + x + 0;
|
||||
GLuint v10 = previousVerts[0] + (y + 0) * (resolution + 3) + x + 1;
|
||||
GLuint v01 = previousVerts[0] + (y + 1) * (resolution + 3) + x + 0;
|
||||
GLuint v11 = previousVerts[0] + (y + 1) * (resolution + 3) + x + 1;
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
|
||||
// Build the left part of the clipmap geometry
|
||||
for (unsigned int y = 0; y < resolution / 2; y++) {
|
||||
for (unsigned int x = 0; x < resolution / 4 + 1; x++) {
|
||||
GLuint v00 = previousVerts[1] + (y + 0) * (resolution / 4 + 2) + x + 0;
|
||||
GLuint v10 = previousVerts[1] + (y + 0) * (resolution / 4 + 2) + x + 1;
|
||||
GLuint v01 = previousVerts[1] + (y + 1) * (resolution / 4 + 2) + x + 0;
|
||||
GLuint v11 = previousVerts[1] + (y + 1) * (resolution / 4 + 2) + x + 1;
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
|
||||
// Build the left part of the clipmap geometry
|
||||
for (unsigned int y = 0; y < resolution / 2; y++) {
|
||||
for (unsigned int x = 0; x < resolution / 4 + 1; x++) {
|
||||
GLuint v00 = previousVerts[2] + (y + 0) * (resolution / 4 + 2) + x + 0;
|
||||
GLuint v10 = previousVerts[2] + (y + 0) * (resolution / 4 + 2) + x + 1;
|
||||
GLuint v01 = previousVerts[2] + (y + 1) * (resolution / 4 + 2) + x + 0;
|
||||
GLuint v11 = previousVerts[2] + (y + 1) * (resolution / 4 + 2) + x + 1;
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
|
||||
// Build the left part of the clipmap geometry
|
||||
for (unsigned int y = 0; y < resolution / 4 + 1; y++) {
|
||||
for (unsigned int x = 0; x < resolution + 2; x++) {
|
||||
GLuint v00 = previousVerts[3] + (y + 0) * (resolution + 3) + x + 0;
|
||||
GLuint v10 = previousVerts[3] + (y + 0) * (resolution + 3) + x + 1;
|
||||
GLuint v01 = previousVerts[3] + (y + 1) * (resolution + 3) + x + 0;
|
||||
GLuint v11 = previousVerts[3] + (y + 1) * (resolution + 3) + x + 1;
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
std::vector<glm::vec4> ClipMapGeometry::CreatePositions(unsigned int resolution)
|
||||
{
|
||||
validate(resolution);
|
||||
std::vector<glm::vec4> positions;
|
||||
positions.reserve(numVertices(resolution));
|
||||
std::vector<glm::vec2> templateTextureCoords = CreateTextureCoordinates(resolution);
|
||||
|
||||
// Copy from 2d texture coordinates and use as template to create positions
|
||||
for (unsigned int i = 0; i < templateTextureCoords.size(); i++) {
|
||||
positions.push_back(
|
||||
glm::vec4(
|
||||
templateTextureCoords[i].x,
|
||||
templateTextureCoords[i].y,
|
||||
0,
|
||||
1));
|
||||
}
|
||||
|
||||
return positions;
|
||||
}
|
||||
|
||||
|
||||
std::vector<glm::vec2> ClipMapGeometry::CreateTextureCoordinates(unsigned int resolution){
|
||||
validate(resolution);
|
||||
std::vector<glm::vec2> textureCoordinates;
|
||||
textureCoordinates.reserve(numVertices(resolution));
|
||||
|
||||
// Resolution needs to be an int to compare with negative numbers
|
||||
int intResolution = resolution;
|
||||
// Build the bottom part of the clipmap geometry
|
||||
for (int y = -1; y < intResolution / 4 + 1; y++) {
|
||||
for (int x = -1; x < intResolution + 2; x++) {
|
||||
textureCoordinates.push_back(glm::vec2(
|
||||
static_cast<float>(x) / intResolution,
|
||||
static_cast<float>(y) / intResolution));
|
||||
}
|
||||
}
|
||||
|
||||
// Build the left part of the clipmap geometry
|
||||
for (int y = intResolution / 4; y < 3 * intResolution / 4 + 1; y++) {
|
||||
for (int x = -1; x < intResolution / 4 + 1; x++) {
|
||||
textureCoordinates.push_back(glm::vec2(
|
||||
static_cast<float>(x) / intResolution,
|
||||
static_cast<float>(y) / intResolution));
|
||||
}
|
||||
}
|
||||
|
||||
// Build the right part of the clipmap geometry
|
||||
for (int y = intResolution / 4; y < 3 * intResolution / 4 + 1; y++) {
|
||||
for (int x = 3 * intResolution / 4; x < intResolution + 2; x++) {
|
||||
float u = static_cast<float>(x) / intResolution;
|
||||
float v = static_cast<float>(y) / intResolution;
|
||||
textureCoordinates.push_back(glm::vec2(u, v));
|
||||
}
|
||||
}
|
||||
|
||||
// Build the top part of the clipmap geometry
|
||||
for (int y = 3 * intResolution / 4; y < intResolution + 2; y++) {
|
||||
for (int x = -1; x < intResolution + 2; x++) {
|
||||
textureCoordinates.push_back(glm::vec2(
|
||||
static_cast<float>(x) / intResolution,
|
||||
static_cast<float>(y) / intResolution));
|
||||
}
|
||||
}
|
||||
|
||||
return textureCoordinates;
|
||||
}
|
||||
|
||||
std::vector<glm::vec3> ClipMapGeometry::CreateNormals(unsigned int resolution) {
|
||||
validate(resolution);
|
||||
std::vector<glm::vec3> normals;
|
||||
normals.reserve(numVertices(resolution));
|
||||
|
||||
for (unsigned int y = 0; y < resolution + 1; y++) {
|
||||
for (unsigned int x = 0; x < resolution + 1; x++) {
|
||||
normals.push_back(glm::vec3(0, 0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
return normals;
|
||||
}
|
||||
}// namespace openspace
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <modules/globebrowsing/rendering/clipmapglobe.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/clipmapgeometry.h>
|
||||
#include <modules/globebrowsing/rendering/clipmapgrid.h>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
@@ -71,16 +71,10 @@ namespace openspace {
|
||||
|
||||
// ---------
|
||||
// init Renderer
|
||||
auto patchRenderer = new ClipMapPatchRenderer(shared_ptr<ClipMapGeometry>(new ClipMapGeometry(32)));
|
||||
_patchRenderer.reset(patchRenderer);
|
||||
auto smallestPatchRenderer = new ClipMapPatchRenderer(shared_ptr<GridGeometry>(
|
||||
new GridGeometry(
|
||||
32,
|
||||
32,
|
||||
Geometry::Positions::No,
|
||||
Geometry::TextureCoordinates::Yes,
|
||||
Geometry::Normals::No)));
|
||||
_smallestPatchRenderer.reset(smallestPatchRenderer);
|
||||
auto outerPatchRenderer = new ClipMapPatchRenderer(shared_ptr<OuterClipMapGrid>(new OuterClipMapGrid(32)));
|
||||
_outerPatchRenderer.reset(outerPatchRenderer);
|
||||
auto innerPatchRenderer = new ClipMapPatchRenderer(shared_ptr<InnerClipMapGrid>(new InnerClipMapGrid(32)));
|
||||
_innerPatchRenderer.reset(innerPatchRenderer);
|
||||
}
|
||||
|
||||
ClipMapGlobe::~ClipMapGlobe() {
|
||||
@@ -108,10 +102,10 @@ namespace openspace {
|
||||
for (size_t i = minDepth; i < maxDepth; i++)
|
||||
{
|
||||
LatLon patchSize = _clipMapPyramid.getPatchSizeAtLevel(i);
|
||||
_patchRenderer->renderPatch(patchSize, data, 6.3e6);
|
||||
_outerPatchRenderer->renderPatch(patchSize, data, 6.3e6);
|
||||
}
|
||||
LatLon patchSize = _clipMapPyramid.getPatchSizeAtLevel(maxDepth);
|
||||
_smallestPatchRenderer->renderPatch(patchSize, data, 6.3e6);
|
||||
_innerPatchRenderer->renderPatch(patchSize, data, 6.3e6);
|
||||
}
|
||||
|
||||
void ClipMapGlobe::update(const UpdateData& data) {
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/geometry.h>
|
||||
#include <modules/globebrowsing/rendering/gridgeometry.h>
|
||||
#include <modules/globebrowsing/rendering/grid.h>
|
||||
#include <modules/globebrowsing/rendering/distanceswitch.h>
|
||||
#include <modules/globebrowsing/rendering/patchrenderer.h>
|
||||
#include <modules/globebrowsing/rendering/clipmappyramid.h>
|
||||
@@ -57,8 +57,8 @@ namespace openspace {
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ClipMapPatchRenderer> _patchRenderer;
|
||||
std::unique_ptr<ClipMapPatchRenderer> _smallestPatchRenderer;
|
||||
std::unique_ptr<ClipMapPatchRenderer> _outerPatchRenderer;
|
||||
std::unique_ptr<ClipMapPatchRenderer> _innerPatchRenderer;
|
||||
|
||||
ClipMapPyramid _clipMapPyramid;
|
||||
|
||||
|
||||
448
modules/globebrowsing/rendering/clipmapgrid.cpp
Normal file
448
modules/globebrowsing/rendering/clipmapgrid.cpp
Normal file
@@ -0,0 +1,448 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/clipmapgrid.h>
|
||||
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ClipMapGrid";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CLIPMAP GRID (Abstract class) //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ClipMapGrid::ClipMapGrid(unsigned int segments)
|
||||
: Grid(segments, segments, Geometry::Positions::No, Geometry::TextureCoordinates::Yes, Geometry::Normals::No)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ClipMapGrid::~ClipMapGrid()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int ClipMapGrid::xSegments() const {
|
||||
return segments();
|
||||
}
|
||||
|
||||
int ClipMapGrid::ySegments() const {
|
||||
return segments();
|
||||
}
|
||||
|
||||
int ClipMapGrid::segments() const {
|
||||
return _xSegments;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OUTER CLIPMAP GRID //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
OuterClipMapGrid::OuterClipMapGrid(unsigned int segments)
|
||||
: ClipMapGrid(segments)
|
||||
{
|
||||
_geometry = std::unique_ptr<Geometry>(new Geometry(
|
||||
CreateElements(segments, segments),
|
||||
Geometry::Positions::No,
|
||||
Geometry::TextureCoordinates::Yes,
|
||||
Geometry::Normals::No));
|
||||
|
||||
_geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments));
|
||||
}
|
||||
|
||||
OuterClipMapGrid::~OuterClipMapGrid()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
size_t OuterClipMapGrid::numElements(int segments)
|
||||
{
|
||||
int numElementsInTotalSquare = 6 * (segments + 1) * (segments + 1);
|
||||
int numElementsInHole = 6 * (segments / 4 * segments / 4);
|
||||
return numElementsInTotalSquare - numElementsInHole;
|
||||
}
|
||||
|
||||
size_t OuterClipMapGrid::numVerticesBottom(int segments)
|
||||
{
|
||||
return (segments + 1 + 2) * (segments / 4 + 1 + 1);
|
||||
}
|
||||
|
||||
size_t OuterClipMapGrid::numVerticesLeft(int segments)
|
||||
{
|
||||
return (segments / 4 + 1 + 1) * (segments / 2 + 1);
|
||||
}
|
||||
|
||||
size_t OuterClipMapGrid::numVerticesRight(int segments)
|
||||
{
|
||||
return (segments / 4 + 1 + 1) * (segments / 2 + 1);
|
||||
}
|
||||
|
||||
size_t OuterClipMapGrid::numVerticesTop(int segments)
|
||||
{
|
||||
return (segments + 1 + 2) * (segments / 4 + 1 + 1);
|
||||
}
|
||||
|
||||
size_t OuterClipMapGrid::numVertices(int segments)
|
||||
{
|
||||
return numVerticesBottom(segments) +
|
||||
numVerticesLeft(segments) +
|
||||
numVerticesRight(segments) +
|
||||
numVerticesTop(segments);
|
||||
}
|
||||
|
||||
void OuterClipMapGrid::validate(int xRes, int yRes) {
|
||||
|
||||
ghoul_assert(xRes == yRes,
|
||||
"segments must be equal in x and in y. ");
|
||||
int segments = xRes;
|
||||
ghoul_assert(segments >= 8,
|
||||
"segments must be at least 8. (" << segments << ")");
|
||||
ghoul_assert(segments == pow(2, int(log2(segments))),
|
||||
"segments must be a power of 2. (" << segments << ")");
|
||||
}
|
||||
|
||||
std::vector<GLuint> OuterClipMapGrid::CreateElements(int xRes, int yRes) {
|
||||
validate(xRes, yRes);
|
||||
int segments = xRes;
|
||||
std::vector<GLuint> elements;
|
||||
elements.reserve(numElements(segments));
|
||||
|
||||
// The clipmap geometry is built up by four parts as follows:
|
||||
// 0 = Bottom part
|
||||
// 1 = Left part
|
||||
// 2 = Right part
|
||||
// 3 = Top part
|
||||
//
|
||||
// 33333333
|
||||
// 33333333
|
||||
// 11 22
|
||||
// 11 22
|
||||
// 00000000
|
||||
// 00000000
|
||||
|
||||
|
||||
// x v01---v11 x ..
|
||||
// | / |
|
||||
// x v00---v10 x ..
|
||||
//
|
||||
// x x x x ..
|
||||
// : : : :
|
||||
|
||||
unsigned int previousVerts[4];
|
||||
previousVerts[0] = 0;
|
||||
previousVerts[1] = previousVerts[0] + numVerticesBottom(segments);
|
||||
previousVerts[2] = previousVerts[1] + numVerticesLeft(segments);
|
||||
previousVerts[3] = previousVerts[2] + numVerticesRight(segments);
|
||||
|
||||
// Build the bottom part of the clipmap geometry
|
||||
for (unsigned int y = 0; y < segments / 4 + 1; y++) {
|
||||
for (unsigned int x = 0; x < segments + 2; x++) {
|
||||
GLuint v00 = previousVerts[0] + (y + 0) * (segments + 3) + x + 0;
|
||||
GLuint v10 = previousVerts[0] + (y + 0) * (segments + 3) + x + 1;
|
||||
GLuint v01 = previousVerts[0] + (y + 1) * (segments + 3) + x + 0;
|
||||
GLuint v11 = previousVerts[0] + (y + 1) * (segments + 3) + x + 1;
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
|
||||
// Build the left part of the clipmap geometry
|
||||
for (unsigned int y = 0; y < segments / 2; y++) {
|
||||
for (unsigned int x = 0; x < segments / 4 + 1; x++) {
|
||||
GLuint v00 = previousVerts[1] + (y + 0) * (segments / 4 + 2) + x + 0;
|
||||
GLuint v10 = previousVerts[1] + (y + 0) * (segments / 4 + 2) + x + 1;
|
||||
GLuint v01 = previousVerts[1] + (y + 1) * (segments / 4 + 2) + x + 0;
|
||||
GLuint v11 = previousVerts[1] + (y + 1) * (segments / 4 + 2) + x + 1;
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
|
||||
// Build the left part of the clipmap geometry
|
||||
for (unsigned int y = 0; y < segments / 2; y++) {
|
||||
for (unsigned int x = 0; x < segments / 4 + 1; x++) {
|
||||
GLuint v00 = previousVerts[2] + (y + 0) * (segments / 4 + 2) + x + 0;
|
||||
GLuint v10 = previousVerts[2] + (y + 0) * (segments / 4 + 2) + x + 1;
|
||||
GLuint v01 = previousVerts[2] + (y + 1) * (segments / 4 + 2) + x + 0;
|
||||
GLuint v11 = previousVerts[2] + (y + 1) * (segments / 4 + 2) + x + 1;
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
|
||||
// Build the left part of the clipmap geometry
|
||||
for (unsigned int y = 0; y < segments / 4 + 1; y++) {
|
||||
for (unsigned int x = 0; x < segments + 2; x++) {
|
||||
GLuint v00 = previousVerts[3] + (y + 0) * (segments + 3) + x + 0;
|
||||
GLuint v10 = previousVerts[3] + (y + 0) * (segments + 3) + x + 1;
|
||||
GLuint v01 = previousVerts[3] + (y + 1) * (segments + 3) + x + 0;
|
||||
GLuint v11 = previousVerts[3] + (y + 1) * (segments + 3) + x + 1;
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
std::vector<glm::vec4> OuterClipMapGrid::CreatePositions(int xRes, int yRes)
|
||||
{
|
||||
validate(xRes, yRes);
|
||||
int segments = xRes;
|
||||
std::vector<glm::vec4> positions;
|
||||
positions.reserve(numVertices(segments));
|
||||
std::vector<glm::vec2> templateTextureCoords = CreateTextureCoordinates(xRes, yRes);
|
||||
|
||||
// Copy from 2d texture coordinates and use as template to create positions
|
||||
for (unsigned int i = 0; i < templateTextureCoords.size(); i++) {
|
||||
positions.push_back(
|
||||
glm::vec4(
|
||||
templateTextureCoords[i].x,
|
||||
templateTextureCoords[i].y,
|
||||
0,
|
||||
1));
|
||||
}
|
||||
|
||||
return positions;
|
||||
}
|
||||
|
||||
|
||||
std::vector<glm::vec2> OuterClipMapGrid::CreateTextureCoordinates(int xRes, int yRes){
|
||||
validate(xRes, yRes);
|
||||
int segments = xRes;
|
||||
std::vector<glm::vec2> textureCoordinates;
|
||||
textureCoordinates.reserve(numVertices(segments));
|
||||
|
||||
// Build the bottom part of the clipmap geometry
|
||||
for (int y = -1; y < segments / 4 + 1; y++) {
|
||||
for (int x = -1; x < segments + 2; x++) {
|
||||
textureCoordinates.push_back(glm::vec2(
|
||||
static_cast<float>(x) / segments,
|
||||
static_cast<float>(y) / segments));
|
||||
}
|
||||
}
|
||||
|
||||
// Build the left part of the clipmap geometry
|
||||
for (int y = segments / 4; y < 3 * segments / 4 + 1; y++) {
|
||||
for (int x = -1; x < segments / 4 + 1; x++) {
|
||||
textureCoordinates.push_back(glm::vec2(
|
||||
static_cast<float>(x) / segments,
|
||||
static_cast<float>(y) / segments));
|
||||
}
|
||||
}
|
||||
|
||||
// Build the right part of the clipmap geometry
|
||||
for (int y = segments / 4; y < 3 * segments / 4 + 1; y++) {
|
||||
for (int x = 3 * segments / 4; x < segments + 2; x++) {
|
||||
float u = static_cast<float>(x) / segments;
|
||||
float v = static_cast<float>(y) / segments;
|
||||
textureCoordinates.push_back(glm::vec2(u, v));
|
||||
}
|
||||
}
|
||||
|
||||
// Build the top part of the clipmap geometry
|
||||
for (int y = 3 * segments / 4; y < segments + 2; y++) {
|
||||
for (int x = -1; x < segments + 2; x++) {
|
||||
textureCoordinates.push_back(glm::vec2(
|
||||
static_cast<float>(x) / segments,
|
||||
static_cast<float>(y) / segments));
|
||||
}
|
||||
}
|
||||
|
||||
return textureCoordinates;
|
||||
}
|
||||
|
||||
std::vector<glm::vec3> OuterClipMapGrid::CreateNormals(int xRes, int yRes) {
|
||||
validate(xRes, yRes);
|
||||
int segments = xRes;
|
||||
std::vector<glm::vec3> normals;
|
||||
normals.reserve(numVertices(segments));
|
||||
|
||||
for (int y = -1; y < segments + 2; y++) {
|
||||
for (int x = -1; x < segments + 2; x++) {
|
||||
normals.push_back(glm::vec3(0, 0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
return normals;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// INNER CLIPMAP GRID //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
InnerClipMapGrid::InnerClipMapGrid(unsigned int segments)
|
||||
: ClipMapGrid(segments)
|
||||
{
|
||||
_geometry = std::unique_ptr<Geometry>(new Geometry(
|
||||
CreateElements(segments, segments),
|
||||
Geometry::Positions::No,
|
||||
Geometry::TextureCoordinates::Yes,
|
||||
Geometry::Normals::No));
|
||||
|
||||
_geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments));
|
||||
}
|
||||
|
||||
InnerClipMapGrid::~InnerClipMapGrid()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
size_t InnerClipMapGrid::numElements(int segments)
|
||||
{
|
||||
return segments * segments * 6;
|
||||
}
|
||||
|
||||
size_t InnerClipMapGrid::numVertices(int segments)
|
||||
{
|
||||
return (segments + 1) * (segments + 1);
|
||||
}
|
||||
|
||||
void InnerClipMapGrid::validate(int xRes, int yRes) {
|
||||
|
||||
ghoul_assert(xRes == yRes,
|
||||
"segments must be equal in x and in y. ");
|
||||
int segments = xRes;
|
||||
ghoul_assert(segments >= 1,
|
||||
"segments must be at least 1. (" << segments << ")");
|
||||
}
|
||||
|
||||
std::vector<GLuint> InnerClipMapGrid::CreateElements(int xRes, int yRes) {
|
||||
validate(xRes, yRes);
|
||||
int segments = xRes;
|
||||
std::vector<GLuint> elements;
|
||||
elements.reserve(numElements(segments));
|
||||
|
||||
// x v01---v11 x ..
|
||||
// | / |
|
||||
// x v00---v10 x ..
|
||||
//
|
||||
// x x x x ..
|
||||
// : : : :
|
||||
|
||||
for (unsigned int y = 0; y < segments + 2; y++) {
|
||||
for (unsigned int x = 0; x < segments + 2; x++) {
|
||||
GLuint v00 = (y + 0) * (segments + 3) + x + 0;
|
||||
GLuint v10 = (y + 0) * (segments + 3) + x + 1;
|
||||
GLuint v01 = (y + 1) * (segments + 3) + x + 0;
|
||||
GLuint v11 = (y + 1) * (segments + 3) + x + 1;
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
std::vector<glm::vec4> InnerClipMapGrid::CreatePositions(int xRes, int yRes)
|
||||
{
|
||||
validate(xRes, yRes);
|
||||
int segments = xRes;
|
||||
std::vector<glm::vec4> positions;
|
||||
positions.reserve(numVertices(segments));
|
||||
std::vector<glm::vec2> templateTextureCoords = CreateTextureCoordinates(xRes, yRes);
|
||||
|
||||
// Copy from 2d texture coordinates and use as template to create positions
|
||||
for (unsigned int i = 0; i < templateTextureCoords.size(); i++) {
|
||||
positions.push_back(
|
||||
glm::vec4(
|
||||
templateTextureCoords[i].x,
|
||||
templateTextureCoords[i].y,
|
||||
0,
|
||||
1));
|
||||
}
|
||||
|
||||
return positions;
|
||||
}
|
||||
|
||||
|
||||
std::vector<glm::vec2> InnerClipMapGrid::CreateTextureCoordinates(int xRes, int yRes) {
|
||||
validate(xRes, yRes);
|
||||
int segments = xRes;
|
||||
std::vector<glm::vec2> textureCoordinates;
|
||||
textureCoordinates.reserve(numVertices(segments));
|
||||
|
||||
// Build the bottom part of the clipmap geometry
|
||||
for (int y = -1; y < segments + 2; y++) {
|
||||
for (int x = -1; x < segments + 2; x++) {
|
||||
textureCoordinates.push_back(glm::vec2(
|
||||
static_cast<float>(x) / segments,
|
||||
static_cast<float>(y) / segments));
|
||||
}
|
||||
}
|
||||
|
||||
return textureCoordinates;
|
||||
}
|
||||
|
||||
std::vector<glm::vec3> InnerClipMapGrid::CreateNormals(int xRes, int yRes) {
|
||||
validate(xRes, yRes);
|
||||
int segments = xRes;
|
||||
std::vector<glm::vec3> normals;
|
||||
normals.reserve(numVertices(segments));
|
||||
|
||||
for (int y = -1; y < segments + 2; y++) {
|
||||
for (int x = -1; x < segments + 2; x++) {
|
||||
normals.push_back(glm::vec3(0, 0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
return normals;
|
||||
}
|
||||
|
||||
|
||||
}// namespace openspace
|
||||
129
modules/globebrowsing/rendering/clipmapgrid.h
Normal file
129
modules/globebrowsing/rendering/clipmapgrid.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __CLIPMAPGEOMETRY_H__
|
||||
#define __CLIPMAPGEOMETRY_H__
|
||||
|
||||
#include <modules/globebrowsing/rendering/grid.h>
|
||||
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CLIPMAP GRID (Abstract class) //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
This class defines a grid used for the layers of a geometry clipmap. A geometry
|
||||
clipmap is built up from a pyramid of clipmaps so the majority of the grids used
|
||||
are of the class OuterClipMapGrid. The vertex positions and texture coordinated are
|
||||
defined differently than for a normal BasicGrid. Other than having the basic grid
|
||||
vertices it also creates padding of one grid cell on the perimeter. This padding can be
|
||||
used when rendering a ClipMapGrid so that an inner layer of the pyramid can move and
|
||||
snap to the outer layers grid cells.
|
||||
*/
|
||||
class ClipMapGrid : public Grid
|
||||
{
|
||||
public:
|
||||
ClipMapGrid(unsigned int segments);
|
||||
|
||||
~ClipMapGrid();
|
||||
|
||||
virtual int xSegments() const;
|
||||
virtual int ySegments() const;
|
||||
|
||||
/**
|
||||
Returns the segments of the grid. A ClipMapGrid must have the segments in x and
|
||||
y direction equal so this function works as a wrapper for xSegments() and
|
||||
ySegments().
|
||||
*/
|
||||
int segments() const;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OUTER CLIPMAP GRID //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
The outer layers of a geometry clipmap pyramid can be built up by grids with sizes
|
||||
increasing with the power of 2. The OuterClipMapGrid has a whole in the middle where
|
||||
a smaller ClipMapGrid of half the size can fit.
|
||||
*/
|
||||
class OuterClipMapGrid : public ClipMapGrid
|
||||
{
|
||||
public:
|
||||
OuterClipMapGrid(unsigned int segments);
|
||||
|
||||
~OuterClipMapGrid();
|
||||
|
||||
protected:
|
||||
virtual std::vector<GLuint> CreateElements(int xSegments, int ySegments);
|
||||
virtual std::vector<glm::vec4> CreatePositions(int xSegments, int ySegments);
|
||||
virtual std::vector<glm::vec2> CreateTextureCoordinates(int xSegments, int ySegments);
|
||||
virtual std::vector<glm::vec3> CreateNormals(int xSegments, int ySegments);
|
||||
|
||||
private:
|
||||
void validate(int xSegments, int ySegments);
|
||||
|
||||
static size_t numVerticesBottom(int segments);
|
||||
static size_t numVerticesLeft(int segments);
|
||||
static size_t numVerticesRight(int segments);
|
||||
static size_t numVerticesTop(int segments);
|
||||
|
||||
static size_t numElements(int segments);
|
||||
static size_t numVertices(int segments);
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// INNER CLIPMAP GRID //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
The InnerClipMapGrid can be used for the inner most (smallest) grid of a geometry clipmap
|
||||
pyramid. The only difference from a OuterClipMapGrid is that this grid does not have
|
||||
a whole where a smaller ClipMapGrid can be positioned.
|
||||
*/
|
||||
class InnerClipMapGrid : public ClipMapGrid
|
||||
{
|
||||
public:
|
||||
InnerClipMapGrid(unsigned int segments);
|
||||
|
||||
~InnerClipMapGrid();
|
||||
|
||||
private:
|
||||
virtual std::vector<GLuint> CreateElements( int xSegments, int ySegments);
|
||||
virtual std::vector<glm::vec4> CreatePositions(int xSegments, int ySegments);
|
||||
virtual std::vector<glm::vec2> CreateTextureCoordinates(int xSegments, int ySegments);
|
||||
virtual std::vector<glm::vec3> CreateNormals(int xSegments, int ySegments);
|
||||
|
||||
void validate(int xSegments, int ySegments);
|
||||
|
||||
static size_t numElements(int segments);
|
||||
static size_t numVertices(int segments);
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
#endif // __CLIPMAPGEOMETRY_H__
|
||||
124
modules/globebrowsing/rendering/gdaldataconverter.cpp
Normal file
124
modules/globebrowsing/rendering/gdaldataconverter.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/gdaldataconverter.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "GdalDataConverter";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
GdalDataConverter::GdalDataConverter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GdalDataConverter::~GdalDataConverter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<Texture> GdalDataConverter::convertToOpenGLTexture(GDALDataset* dataSet)
|
||||
{
|
||||
int nCols = dataSet->GetRasterBand(1)->GetXSize();
|
||||
int nRows = dataSet->GetRasterBand(1)->GetYSize();
|
||||
|
||||
GDALRasterBand* redBand = dataSet->GetRasterBand(1);
|
||||
GDALRasterBand* greenBand = dataSet->GetRasterBand(2);
|
||||
GDALRasterBand* blueBand = dataSet->GetRasterBand(3);
|
||||
|
||||
int blockSizeX;
|
||||
int blockSizeY;
|
||||
|
||||
redBand->GetBlockSize(&blockSizeX, &blockSizeY);
|
||||
|
||||
int nBlocksX = nCols / blockSizeX;
|
||||
int nBlocksY = nRows / blockSizeY;
|
||||
|
||||
// A block where data is copied
|
||||
GByte* blockR = (GByte*)CPLMalloc(sizeof(GByte) * blockSizeX * blockSizeY);
|
||||
GByte* blockG = (GByte*)CPLMalloc(sizeof(GByte) * blockSizeX * blockSizeY);
|
||||
GByte* blockB = (GByte*)CPLMalloc(sizeof(GByte) * blockSizeX * blockSizeY);
|
||||
// The data that the texture should use
|
||||
GLubyte* imageData = (GLubyte*)CPLMalloc(sizeof(GLubyte) * nCols * nRows * 4);
|
||||
|
||||
// For each block
|
||||
for (size_t blockY = 0; blockY < nBlocksY; blockY++)
|
||||
{
|
||||
for (size_t blockX = 0; blockX < nBlocksX; blockX++)
|
||||
{
|
||||
redBand->ReadBlock(blockX, blockY, blockR);
|
||||
greenBand->ReadBlock(blockX, blockY, blockG);
|
||||
blueBand->ReadBlock(blockX, blockY, blockB);
|
||||
|
||||
size_t blockPixelIndexX = blockSizeX * blockX;
|
||||
size_t blockPixelIndexY = blockSizeY * blockY;
|
||||
|
||||
size_t startPixelIndex = blockPixelIndexY * nCols + blockPixelIndexX;
|
||||
|
||||
|
||||
// For each pixel in each block
|
||||
for (size_t yInBlock = 0; yInBlock < blockSizeY; yInBlock++)
|
||||
{
|
||||
for (size_t xInBlock = 0; xInBlock < blockSizeX; xInBlock++)
|
||||
{
|
||||
size_t pixelIndexInBlock = xInBlock + yInBlock * blockSizeX;
|
||||
size_t globalPixelIndex = (startPixelIndex + xInBlock + yInBlock * nCols) * 4;
|
||||
|
||||
GLubyte pixelR = blockR[pixelIndexInBlock];
|
||||
GLubyte pixelG = blockG[pixelIndexInBlock];
|
||||
GLubyte pixelB = blockB[pixelIndexInBlock];
|
||||
|
||||
imageData[globalPixelIndex + 0] = pixelR;
|
||||
imageData[globalPixelIndex + 1] = pixelG;
|
||||
imageData[globalPixelIndex + 2] = pixelB;
|
||||
imageData[globalPixelIndex + 3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The texture should take ownership of the data
|
||||
std::shared_ptr<Texture> texture = std::shared_ptr<Texture>(new Texture(
|
||||
static_cast<void*>(imageData),
|
||||
glm::uvec3(nCols, nRows, 1),
|
||||
Texture::Format::RGBA,
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
Texture::FilterMode::Linear,
|
||||
Texture::WrappingMode::Repeat));
|
||||
|
||||
// Free the row
|
||||
CPLFree(blockR);
|
||||
CPLFree(blockG);
|
||||
CPLFree(blockB);
|
||||
|
||||
// Do not free imageData since the texture now has ownership of it
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
53
modules/globebrowsing/rendering/gdaldataconverter.h
Normal file
53
modules/globebrowsing/rendering/gdaldataconverter.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __GDALDATACONVERTER_H__
|
||||
#define __GDALDATACONVERTER_H__
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
#include "gdal_priv.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
using namespace ghoul::opengl;
|
||||
|
||||
class GdalDataConverter
|
||||
{
|
||||
public:
|
||||
GdalDataConverter();
|
||||
~GdalDataConverter();
|
||||
|
||||
std::shared_ptr<Texture> convertToOpenGLTexture(GDALDataset* dataSet);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __GDALDATACONVERTER_H__
|
||||
@@ -134,7 +134,7 @@ namespace openspace {
|
||||
//glCullFace(GL_BACK);
|
||||
|
||||
// render
|
||||
_grid.drawUsingActiveProgram();
|
||||
_grid.geometry().drawUsingActiveProgram();
|
||||
|
||||
// disable shader
|
||||
_programObject->deactivate();
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/geometry.h>
|
||||
#include <modules/globebrowsing/rendering/gridgeometry.h>
|
||||
#include <modules/globebrowsing/rendering/basicgrid.h>
|
||||
#include <modules/globebrowsing/rendering/distanceswitch.h>
|
||||
|
||||
namespace ghoul {
|
||||
@@ -59,7 +59,7 @@ namespace openspace {
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
|
||||
//std::unique_ptr<Geometry> _testGeometry;
|
||||
GridGeometry _grid;
|
||||
BasicGrid _grid;
|
||||
|
||||
|
||||
properties::IntProperty _rotation;
|
||||
|
||||
55
modules/globebrowsing/rendering/grid.cpp
Normal file
55
modules/globebrowsing/rendering/grid.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/grid.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "Grid";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
Grid::Grid(
|
||||
int xSegments,
|
||||
int ySegments,
|
||||
Geometry::Positions usePositions,
|
||||
Geometry::TextureCoordinates useTextures,
|
||||
Geometry::Normals useNormals)
|
||||
: _xSegments(xSegments)
|
||||
, _ySegments(ySegments)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Grid::~Grid()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Geometry& Grid::geometry()
|
||||
{
|
||||
return *_geometry;
|
||||
}
|
||||
|
||||
}// namespace openspace
|
||||
@@ -22,7 +22,6 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
|
||||
#ifndef __GRIDGEOMETRY_H__
|
||||
#define __GRIDGEOMETRY_H__
|
||||
|
||||
@@ -35,44 +34,41 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class GridGeometry : public Geometry
|
||||
class Grid
|
||||
{
|
||||
public:
|
||||
GridGeometry(
|
||||
unsigned int xRes,
|
||||
unsigned int yRes,
|
||||
Positions usePositions = Positions::No,
|
||||
TextureCoordinates useTextures = TextureCoordinates::No,
|
||||
Normals useNormals = Normals::No
|
||||
);
|
||||
Grid(
|
||||
int xSegments,
|
||||
int ySegments,
|
||||
Geometry::Positions usePositions = Geometry::Positions::No,
|
||||
Geometry::TextureCoordinates useTextures = Geometry::TextureCoordinates::No,
|
||||
Geometry::Normals useNormals = Geometry::Normals::No);
|
||||
~Grid();
|
||||
|
||||
~GridGeometry();
|
||||
Geometry& geometry();
|
||||
|
||||
inline const unsigned int xResolution() const;
|
||||
inline const unsigned int yResolution() const;
|
||||
/**
|
||||
Returns the number of grid cells in the x direction. Hence the number of vertices
|
||||
in the x direction is xResolution + 1.
|
||||
*/
|
||||
virtual int xSegments() const = 0;
|
||||
|
||||
/**
|
||||
Returns the number of grid cells in the y direction. Hence the number of vertices
|
||||
in the y direction is xResolution + 1.
|
||||
*/
|
||||
virtual int ySegments() const = 0;
|
||||
|
||||
inline static size_t numElements(unsigned int xRes, unsigned int yRes);
|
||||
static size_t numVertices(unsigned int xRes, unsigned int yRes);
|
||||
protected:
|
||||
virtual std::vector<GLuint> CreateElements( int xSegments, int ySegments) = 0;
|
||||
virtual std::vector<glm::vec4> CreatePositions( int xSegments, int ySegments) = 0;
|
||||
virtual std::vector<glm::vec2> CreateTextureCoordinates( int xSegments, int ySegments) = 0;
|
||||
virtual std::vector<glm::vec3> CreateNormals( int xSegments, int ySegments) = 0;
|
||||
|
||||
private:
|
||||
static std::vector<GLuint> CreateElements(unsigned int xRes, unsigned int yRes);
|
||||
static std::vector<glm::vec4> CreatePositions(
|
||||
unsigned int xRes,
|
||||
unsigned int yRes,
|
||||
float xSize = 1.0f,
|
||||
float ySize = 1.0f,
|
||||
float xOffset = 0.0f,
|
||||
float yOffset = 0.0f);
|
||||
static std::vector<glm::vec2> CreateTextureCoordinates(
|
||||
unsigned int xRes,
|
||||
unsigned int yRes);
|
||||
static std::vector<glm::vec3> CreateNormals(unsigned int xRes, unsigned int yRes);
|
||||
std::unique_ptr<Geometry> _geometry;
|
||||
|
||||
inline static void validate(unsigned int xRes, unsigned int yRes);
|
||||
inline void validateIndices(unsigned int x, unsigned int y);
|
||||
|
||||
unsigned int _xRes;
|
||||
unsigned int _yRes;
|
||||
const int _xSegments;
|
||||
const int _ySegments;
|
||||
};
|
||||
} // namespace openspace
|
||||
#endif // __GRIDGEOMETRY_H__
|
||||
@@ -1,154 +0,0 @@
|
||||
#include <modules/globebrowsing/rendering/gridgeometry.h>
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "GridGeometry";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
GridGeometry::GridGeometry(
|
||||
unsigned int xRes,
|
||||
unsigned int yRes,
|
||||
Positions usePositions,
|
||||
TextureCoordinates useTextures,
|
||||
Normals useNormals)
|
||||
: Geometry(CreateElements(xRes, yRes), usePositions, useTextures, useNormals)
|
||||
{
|
||||
if(_useVertexPositions){
|
||||
setVertexPositions(CreatePositions(xRes, yRes));
|
||||
}
|
||||
if (_useTextureCoordinates) {
|
||||
setVertexTextureCoordinates(CreateTextureCoordinates(xRes, yRes));
|
||||
}
|
||||
if (_useVertexNormals) {
|
||||
setVertexNormals(CreateNormals(xRes, yRes));
|
||||
}
|
||||
_xRes = xRes;
|
||||
_yRes = yRes;
|
||||
}
|
||||
|
||||
GridGeometry::~GridGeometry()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const unsigned int GridGeometry::xResolution() const {
|
||||
return _xRes;
|
||||
}
|
||||
|
||||
const unsigned int GridGeometry::yResolution() const {
|
||||
return _yRes;
|
||||
}
|
||||
|
||||
void GridGeometry::validate(unsigned int xRes, unsigned int yRes) {
|
||||
ghoul_assert(xRes > 0 && yRes > 0,
|
||||
"Resolution must be at least 1x1. (" << xRes << ", " << yRes << ")");
|
||||
}
|
||||
|
||||
void GridGeometry::validateIndices(unsigned int x, unsigned int y) {
|
||||
validate(x, y);
|
||||
ghoul_assert(x < _xRes, "x index is outside range: x = " << x << " xRes = " << _xRes);
|
||||
ghoul_assert(y < _yRes, "y index is outside range: y = " << y << " yRes = " << _yRes);
|
||||
}
|
||||
|
||||
inline size_t GridGeometry::numElements(unsigned int xRes, unsigned int yRes){
|
||||
return 3 * 2 * (xRes - 1)*(yRes - 1);
|
||||
}
|
||||
|
||||
inline size_t GridGeometry::numVertices(unsigned int xRes, unsigned int yRes) {
|
||||
return xRes * yRes;
|
||||
}
|
||||
|
||||
std::vector<GLuint> GridGeometry::CreateElements(unsigned int xRes, unsigned int yRes) {
|
||||
validate(xRes, yRes);
|
||||
|
||||
std::vector<GLuint> elements;
|
||||
elements.reserve(numElements(xRes, yRes));
|
||||
for (unsigned int y = 0; y < yRes-1; y++) {
|
||||
for (unsigned int x = 0; x < xRes-1; x++) {
|
||||
|
||||
// x v01---v11 x ..
|
||||
// | / |
|
||||
// x v00---v10 x ..
|
||||
//
|
||||
// x x x x ..
|
||||
// : : : :
|
||||
|
||||
GLuint v00 = (y + 0) * xRes + x + 0;
|
||||
GLuint v10 = (y + 0) * xRes + x + 1;
|
||||
GLuint v01 = (y + 1) * xRes + x + 0;
|
||||
GLuint v11 = (y + 1) * xRes + x + 1;
|
||||
|
||||
// add upper triangle
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v10);
|
||||
elements.push_back(v11);
|
||||
|
||||
// add lower triangle
|
||||
elements.push_back(v00);
|
||||
elements.push_back(v11);
|
||||
elements.push_back(v01);
|
||||
}
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
std::vector<glm::vec4> GridGeometry::CreatePositions(
|
||||
unsigned int xRes,
|
||||
unsigned int yRes,
|
||||
float xSize,
|
||||
float ySize,
|
||||
float xOffset,
|
||||
float yOffset)
|
||||
{
|
||||
validate(xRes, yRes);
|
||||
std::vector<glm::vec4> positions;
|
||||
positions.reserve(numVertices(xRes, yRes));
|
||||
|
||||
// Copy from 2d texture coordinates and use as template to create positions
|
||||
std::vector<glm::vec2> templateTextureCoords = CreateTextureCoordinates(xRes, yRes);
|
||||
for (unsigned int i = 0; i < templateTextureCoords.size(); i++)
|
||||
{
|
||||
positions.push_back(glm::vec4(
|
||||
templateTextureCoords[i],
|
||||
0.0f,
|
||||
1.0f
|
||||
));
|
||||
}
|
||||
return positions;
|
||||
}
|
||||
|
||||
std::vector<glm::vec2> GridGeometry::CreateTextureCoordinates(unsigned int xRes, unsigned int yRes){
|
||||
validate(xRes, yRes);
|
||||
std::vector<glm::vec2> textureCoordinates;
|
||||
textureCoordinates.reserve(numVertices(xRes, yRes));
|
||||
|
||||
for (unsigned int y = 0; y < yRes; y++) {
|
||||
for (unsigned int x = 0; x < xRes; x++) {
|
||||
textureCoordinates.push_back(glm::vec2(
|
||||
static_cast<float>(x) / static_cast<float>(xRes - 1),
|
||||
static_cast<float>(y) / static_cast<float>(yRes - 1)
|
||||
));
|
||||
}
|
||||
}
|
||||
return textureCoordinates;
|
||||
}
|
||||
|
||||
std::vector<glm::vec3> GridGeometry::CreateNormals(unsigned int xRes, unsigned int yRes) {
|
||||
validate(xRes, yRes);
|
||||
std::vector<glm::vec3> normals;
|
||||
normals.reserve(numVertices(xRes, yRes));
|
||||
|
||||
for (unsigned int y = 0; y < yRes; y++) {
|
||||
for (unsigned int x = 0; x < xRes; x++) {
|
||||
normals.push_back(glm::vec3(0, 0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
return normals;
|
||||
}
|
||||
|
||||
}// namespace openspace
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <modules/globebrowsing/rendering/patchrenderer.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/clipmapgeometry.h>
|
||||
#include <modules/globebrowsing/rendering/clipmapgrid.h>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <math.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "LatLonPatch";
|
||||
const std::string _loggerCat = "PatchRenderer";
|
||||
|
||||
const std::string keyFrame = "Frame";
|
||||
const std::string keyGeometry = "Geometry";
|
||||
@@ -55,9 +55,8 @@ namespace openspace {
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// PATCH RENDERER //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
PatchRenderer::PatchRenderer(shared_ptr<Geometry> geometry)
|
||||
: _geometry(geometry)
|
||||
, _tileSet(LatLon(M_PI, M_PI * 2), LatLon(M_PI / 2, - M_PI), 0)
|
||||
PatchRenderer::PatchRenderer()
|
||||
: _tileSet(LatLon(M_PI, M_PI * 2), LatLon(M_PI / 2, -M_PI), 0)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -75,8 +74,9 @@ namespace openspace {
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// LATLON PATCH RENDERER //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
LatLonPatchRenderer::LatLonPatchRenderer(shared_ptr<Geometry> geometry)
|
||||
: PatchRenderer(geometry)
|
||||
LatLonPatchRenderer::LatLonPatchRenderer(shared_ptr<Grid> grid)
|
||||
: PatchRenderer()
|
||||
, _grid(grid)
|
||||
{
|
||||
_programObject = OsEng.renderEngine().buildRenderProgram(
|
||||
"LatLonSphereMappingProgram",
|
||||
@@ -142,6 +142,7 @@ namespace openspace {
|
||||
_programObject->setUniform("uvTransformPatchToTile", uvTransform);
|
||||
|
||||
LatLon swCorner = patch.southWestCorner();
|
||||
_programObject->setUniform("segmentsPerPatch", _grid->xSegments());
|
||||
_programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform);
|
||||
_programObject->setUniform("minLatLon", vec2(swCorner.toLonLatVec2()));
|
||||
_programObject->setUniform("lonLatScalingFactor", vec2(patch.size().toLonLatVec2()));
|
||||
@@ -152,7 +153,7 @@ namespace openspace {
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
// render
|
||||
_geometry->drawUsingActiveProgram();
|
||||
_grid->geometry().drawUsingActiveProgram();
|
||||
|
||||
// disable shader
|
||||
_programObject->deactivate();
|
||||
@@ -163,8 +164,9 @@ namespace openspace {
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// CLIPMAP PATCH RENDERER //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
ClipMapPatchRenderer::ClipMapPatchRenderer(shared_ptr<Geometry> geometry)
|
||||
: PatchRenderer(geometry)
|
||||
ClipMapPatchRenderer::ClipMapPatchRenderer(shared_ptr<ClipMapGrid> grid)
|
||||
: PatchRenderer()
|
||||
, _grid(grid)
|
||||
{
|
||||
_programObject = OsEng.renderEngine().buildRenderProgram(
|
||||
"LatLonSphereMappingProgram",
|
||||
@@ -191,7 +193,7 @@ namespace openspace {
|
||||
mat4 modelTransform = translate(mat4(1), data.position.vec3());
|
||||
|
||||
// Snap patch position
|
||||
int segmentsPerPatch = 32;
|
||||
int segmentsPerPatch = _grid->segments();
|
||||
LatLon stepSize = LatLon(
|
||||
patchSize.lat / segmentsPerPatch,
|
||||
patchSize.lon / segmentsPerPatch);
|
||||
@@ -232,6 +234,7 @@ namespace openspace {
|
||||
_programObject->setUniform(
|
||||
"modelViewProjectionTransform",
|
||||
data.camera.projectionMatrix() * viewTransform * modelTransform);
|
||||
_programObject->setUniform("segmentsPerPatch", segmentsPerPatch);
|
||||
_programObject->setUniform("minLatLon", vec2(newPatch.southWestCorner().toLonLatVec2()));
|
||||
_programObject->setUniform("lonLatScalingFactor", vec2(patchSize.toLonLatVec2()));
|
||||
_programObject->setUniform("globeRadius", float(radius));
|
||||
@@ -242,7 +245,7 @@ namespace openspace {
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
// render
|
||||
_geometry->drawUsingActiveProgram();
|
||||
_grid->geometry().drawUsingActiveProgram();
|
||||
|
||||
// disable shader
|
||||
_programObject->deactivate();
|
||||
|
||||
@@ -32,75 +32,78 @@
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <modules/globebrowsing/datastructures/latlon.h>
|
||||
#include <modules/globebrowsing/rendering/gridgeometry.h>
|
||||
#include <modules/globebrowsing/rendering/grid.h>
|
||||
#include <modules/globebrowsing/rendering/clipmapgrid.h>
|
||||
#include <modules/globebrowsing/rendering/frustrumculler.h>
|
||||
#include <modules/globebrowsing/rendering/texturetileset.h>
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
class ProgramObject;
|
||||
class ProgramObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class LonLatPatch;
|
||||
class Geometry;
|
||||
|
||||
using std::shared_ptr;
|
||||
using std::unique_ptr;
|
||||
using ghoul::opengl::ProgramObject;
|
||||
class LonLatPatch;
|
||||
class Geometry;
|
||||
|
||||
using std::shared_ptr;
|
||||
using std::unique_ptr;
|
||||
using ghoul::opengl::ProgramObject;
|
||||
|
||||
class PatchRenderer {
|
||||
public:
|
||||
|
||||
PatchRenderer(shared_ptr<Geometry>);
|
||||
~PatchRenderer();
|
||||
class PatchRenderer {
|
||||
public:
|
||||
|
||||
PatchRenderer();
|
||||
~PatchRenderer();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
unique_ptr<ProgramObject> _programObject;
|
||||
shared_ptr<Geometry> _geometry;
|
||||
|
||||
TextureTileSet _tileSet;
|
||||
};
|
||||
unique_ptr<ProgramObject> _programObject;
|
||||
TextureTileSet _tileSet;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// PATCH RENDERER SUBCLASSES //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// PATCH RENDERER SUBCLASSES //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class LatLonPatchRenderer : public PatchRenderer {
|
||||
public:
|
||||
LatLonPatchRenderer(shared_ptr<Geometry>);
|
||||
class LatLonPatchRenderer : public PatchRenderer {
|
||||
public:
|
||||
LatLonPatchRenderer(shared_ptr<Grid> grid);
|
||||
|
||||
void renderPatch(
|
||||
const LatLonPatch& patch,
|
||||
const RenderData& data,
|
||||
double radius);
|
||||
void renderPatch(
|
||||
const LatLonPatch& patch,
|
||||
const RenderData& data,
|
||||
double radius);
|
||||
|
||||
void renderPatch(
|
||||
const LatLonPatch& patch,
|
||||
const RenderData& data,
|
||||
double radius,
|
||||
const TileIndex& ti);
|
||||
void renderPatch(
|
||||
const LatLonPatch& patch,
|
||||
const RenderData& data,
|
||||
double radius,
|
||||
const TileIndex& ti);
|
||||
|
||||
private:
|
||||
TwmsTileProvider tileProvider;
|
||||
};
|
||||
private:
|
||||
TwmsTileProvider tileProvider;
|
||||
shared_ptr<Grid> _grid;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ClipMapPatchRenderer : public PatchRenderer {
|
||||
public:
|
||||
ClipMapPatchRenderer(shared_ptr<Geometry> geometry);
|
||||
class ClipMapPatchRenderer : public PatchRenderer {
|
||||
public:
|
||||
ClipMapPatchRenderer(shared_ptr<ClipMapGrid> grid);
|
||||
|
||||
void renderPatch(
|
||||
const LatLon& patchSize,
|
||||
const RenderData& data,
|
||||
double radius);
|
||||
};
|
||||
void renderPatch(
|
||||
const LatLon& patchSize,
|
||||
const RenderData& data,
|
||||
double radius);
|
||||
private:
|
||||
shared_ptr<ClipMapGrid> _grid;
|
||||
};
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __LATLONPATCH_H__
|
||||
@@ -24,12 +24,16 @@
|
||||
|
||||
#include <modules/globebrowsing/rendering/texturetileset.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/gdaldataconverter.h>
|
||||
|
||||
#include <ghoul/opengl/texturemanager.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include "gdal_priv.h"
|
||||
#include "cpl_conv.h" // for CPLMalloc()
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
@@ -45,6 +49,23 @@ namespace openspace {
|
||||
, _depth(depth)
|
||||
{
|
||||
|
||||
|
||||
// Read using GDAL
|
||||
|
||||
/*
|
||||
GDALDataset *poDataset;
|
||||
GDALAllRegister();
|
||||
poDataset = (GDALDataset *)GDALOpen(absPath("textures/earth_bluemarble.jpg").c_str(), GA_ReadOnly);
|
||||
assert(poDataset != NULL);
|
||||
GdalDataConverter conv;
|
||||
|
||||
_testTexture = conv.convertToOpenGLTexture(poDataset);
|
||||
|
||||
_testTexture->uploadTexture();
|
||||
_testTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
*/
|
||||
|
||||
|
||||
// Set e texture to test
|
||||
std::string fileName = "textures/earth_bluemarble.jpg";
|
||||
//std::string fileName = "../../../build/tiles/tile5_8_12.png";
|
||||
@@ -60,6 +81,7 @@ namespace openspace {
|
||||
//_testTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
|
||||
_testTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TextureTileSet::~TextureTileSet(){
|
||||
|
||||
@@ -38,6 +38,8 @@ uniform sampler2D nightTex;
|
||||
uniform sampler2D textureSampler;
|
||||
uniform mat3 uvTransformPatchToTile;
|
||||
|
||||
uniform int segmentsPerPatch;
|
||||
|
||||
in vec4 vs_position;
|
||||
in vec2 vs_uv;
|
||||
|
||||
@@ -50,8 +52,10 @@ Fragment getFragment() {
|
||||
|
||||
frag.color = texture(textureSampler, vec2(uvTransformPatchToTile * vec3(vs_uv.s, vs_uv.t, 1)));
|
||||
frag.color = 0.001*frag.color + 0.999*texture(textureSampler, vs_uv);
|
||||
vec4 uvColor = vec4(fract(vs_uv * 32 / 32), 0.4,1);
|
||||
|
||||
vec4 uvColor = vec4(fract(vs_uv * segmentsPerPatch), 0.4,1);
|
||||
frag.color = frag.color.a < 0.1 ? uvColor * 0.5 : frag.color;
|
||||
|
||||
frag.depth = pscDepth(vs_position);
|
||||
|
||||
return frag;
|
||||
|
||||
@@ -36,11 +36,13 @@
|
||||
//#include <test_chunknode.inl>
|
||||
#include <test_lrucache.inl>
|
||||
#include <test_twmstileprovider.inl>
|
||||
|
||||
//#include <test_luaconversions.inl>
|
||||
//#include <test_powerscalecoordinates.inl>
|
||||
//#include <test_angle.inl>
|
||||
//#include <test_latlonpatch.inl>
|
||||
//#include <test_texturetileset.inl>
|
||||
#include <test_gdalwms.inl>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
|
||||
62
tests/test_gdalwms.inl
Normal file
62
tests/test_gdalwms.inl
Normal file
@@ -0,0 +1,62 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 "gtest/gtest.h"
|
||||
|
||||
#include "gdal.h"
|
||||
|
||||
#include "gdal_priv.h"
|
||||
|
||||
#include <ogr_spatialref.h>
|
||||
|
||||
|
||||
#include "cpl_conv.h"
|
||||
|
||||
//#include "wms/wmsdriver.h"
|
||||
//#include "wms/wmsmetadataset.h"
|
||||
|
||||
|
||||
class GdalWmsTest : public testing::Test {};
|
||||
|
||||
TEST_F(GdalWmsTest, Simple) {
|
||||
//GDALRegister_WMS();
|
||||
|
||||
|
||||
|
||||
GDALWMSDataset* wms_dataset = GDALOpen("../test.xml", GA_ReadOnly);
|
||||
if (wms_dataset)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
GDALDataset *poDataset;
|
||||
GDALAllRegister();
|
||||
poDataset = (GDALDataset *)GDALOpen("filename", GA_ReadOnly);
|
||||
if (poDataset == NULL)
|
||||
{
|
||||
std::cout << "NULL" << std::endl;
|
||||
}*/
|
||||
}
|
||||
Reference in New Issue
Block a user