Convert tabs to spaces.

This commit is contained in:
Kalle Bladin
2016-08-17 00:30:53 -04:00
parent 64ba3d2717
commit c01808ce10
56 changed files with 972 additions and 972 deletions

View File

@@ -42,7 +42,7 @@ public:
bool windowHasResized() const override;
double averageDeltaTime() const override;
double deltaTime() const override;
double deltaTime() const override;
glm::vec2 mousePosition() const override;
uint32_t mouseButtons(int maxNumber) const override;
glm::ivec2 currentWindowSize() const override;

View File

@@ -79,11 +79,11 @@ public:
*/
virtual double averageDeltaTime() const;
/**
* Returns the frametime in seconds. On default, this method returns <code>0.0</code>.
* \return The frametime in seconds
*/
virtual double deltaTime() const;
/**
* Returns the frametime in seconds. On default, this method returns <code>0.0</code>.
* \return The frametime in seconds
*/
virtual double deltaTime() const;
/**
* Returns the location of the mouse cursor in pixel screen coordinates. On default,

View File

@@ -68,15 +68,15 @@ public:
Post
};
enum class FrametimeType {
DtTimeAvg = 0,
FPS,
FPSAvg
};
enum class FrametimeType {
DtTimeAvg = 0,
FPS,
FPSAvg
};
static const std::string KeyFontMono;
static const std::string KeyFontLight;
static const std::vector<FrametimeType> FrametimeTypes;
static const std::vector<FrametimeType> FrametimeTypes;
RenderEngine();
~RenderEngine();
@@ -104,7 +104,7 @@ public:
void takeScreenshot();
void toggleInfoText(bool b);
void toggleFrametimeType(int t);
void toggleFrametimeType(int t);
// Performance measurements
void setPerformanceMeasurements(bool performanceMeasurements);
@@ -207,7 +207,7 @@ private:
ghoul::Dictionary _resolveData;
ScreenLog* _log;
FrametimeType _frametimeType;
FrametimeType _frametimeType;
bool _showInfo;
bool _showLog;

View File

@@ -41,16 +41,16 @@ namespace openspace {
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
#endif
class TransformationManager : public ghoul::Singleton<TransformationManager> {
friend class ghoul::Singleton<TransformationManager>;
friend class ghoul::Singleton<TransformationManager>;
public:
TransformationManager();
~TransformationManager();
TransformationManager();
~TransformationManager();
glm::dmat3 frameTransformationMatrix(std::string from, std::string to, double ephemerisTime) const;
glm::dmat3 frameTransformationMatrix(std::string from, std::string to, double ephemerisTime) const;
private:
glm::dmat3 kameleonTransformationMatrix(std::string from, std::string to, double ephemerisTime) const;
glm::dmat3 kameleonTransformationMatrix(std::string from, std::string to, double ephemerisTime) const;
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
std::shared_ptr<ccmc::Kameleon> _kameleon;

View File

@@ -205,7 +205,7 @@ float phaseFunctionR(float mu) {
// Mie phase function
float phaseFunctionM(float mu) {
return 1.5 * 1.0 / (4.0 * M_PI) * (1.0 - mieG*mieG) * pow(1.0 + (mieG*mieG) - 2.0*mieG*mu, -3.0/2.0) * (1.0 + mu * mu) / (2.0 + mieG*mieG);
return 1.5 * 1.0 / (4.0 * M_PI) * (1.0 - mieG*mieG) * pow(1.0 + (mieG*mieG) - 2.0*mieG*mu, -3.0/2.0) * (1.0 + mu * mu) / (2.0 + mieG*mieG);
}
float opticalDepth(float H, float r, float mu, float d) {
@@ -225,7 +225,7 @@ vec4 texture4D(sampler3D table, float r, float mu, float muS, float nu)
float rmu = r * mu;
float delta = rmu * rmu - r * r + Rg * Rg;
vec4 cst = rmu < 0.0 && delta > 0.0 ? vec4(1.0, 0.0, 0.0, 0.5 - 0.5 / float(RES_MU)) : vec4(-1.0, H * H, H, 0.5 + 0.5 / float(RES_MU));
float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R));
float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R));
float uMu = cst.w + (rmu * cst.x + sqrt(delta + cst.y)) / (rho + cst.z) * (0.5 - 1.0 / float(RES_MU));
float uMuS = 0.5 / float(RES_MU_S) + (atan(max(muS, -0.1975) * tan(1.26 * 1.1)) / 1.1 + (1.0 - 0.26)) * 0.5 * (1.0 - 1.0 / float(RES_MU_S));
float lerp = (nu + 1.0) / 2.0 * (float(RES_NU) - 1.0);
@@ -240,18 +240,18 @@ vec3 analyticTransmittance(float r, float mu, float d) {
}
vec3 getMie(vec4 rayMie) {
return rayMie.rgb * rayMie.a / max(rayMie.r, 1e-4) * (betaR.r / betaR);
return rayMie.rgb * rayMie.a / max(rayMie.r, 1e-4) * (betaR.r / betaR);
}
vec2 getTransmittanceUV(float r, float mu) {
float uR, uMu;
uR = sqrt((r - Rg) / (Rt - Rg));
uMu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5;
uR = sqrt((r - Rg) / (Rt - Rg));
uMu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5;
return vec2(uMu, uR);
}
vec3 transmittanceFromTexture(float r, float mu) {
vec2 uv = getTransmittanceUV(r, mu);
vec2 uv = getTransmittanceUV(r, mu);
return texture(transmittanceTexture, uv).rgb;
}

View File

@@ -59,9 +59,9 @@ void getMuMuSNu(const float r, vec4 dhdH, out float mu, out float mu_s, out floa
}
vec3 transmittanceFromTexture(const float r, const float mu) {
float u_r = sqrt((r - Rg) / (Rt - Rg));
float u_r = sqrt((r - Rg) / (Rt - Rg));
// See Colliene to understand the different mapping.
float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5;
float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5;
return texture(transmittanceTexture, vec2(u_mu, u_r)).rgb;
}
@@ -106,7 +106,7 @@ vec4 texture4D(sampler3D table, const float r, const float mu,
float rmu = r * mu;
float delta = rmu * rmu - r * r + Rg * Rg;
vec4 cst = rmu < 0.0 && delta > 0.0 ? vec4(1.0, 0.0, 0.0, 0.5 - 0.5 / float(RES_MU)) : vec4(-1.0, H * H, H, 0.5 + 0.5 / float(RES_MU));
float u_r = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R));
float u_r = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R));
float u_mu = cst.w + (rmu * cst.x + sqrt(delta + cst.y)) / (rho + cst.z) * (0.5 - 1.0 / float(RES_MU));
float u_mu_s = 0.5 / float(RES_MU_S) + (atan(max(mu_s, -0.1975) * tan(1.26 * 1.1)) / 1.1 + (1.0 - 0.26)) * 0.5 * (1.0 - 1.0 / float(RES_MU_S));
float lerp = (nu + 1.0) / 2.0 * (float(RES_NU) - 1.0);

View File

@@ -37,7 +37,7 @@ out float s;
void main()
{
vec4 position = vec4(in_position.xyz * pow(10, in_position.w), 1);
vec4 position = vec4(in_position.xyz * pow(10, in_position.w), 1);
vec4 positionClipSpace = modelViewProjectionTransform * position;
// Write output

View File

@@ -59,9 +59,9 @@ void getMuMuSNu(const float r, vec4 dhdH, out float mu, out float mu_s, out floa
}
vec3 transmittanceFromTexture(const float r, const float mu) {
float u_r = sqrt((r - Rg) / (Rt - Rg));
float u_r = sqrt((r - Rg) / (Rt - Rg));
// See Colliene to understand the different mapping.
float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5;
float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5;
return texture(transmittanceTexture, vec2(u_mu, u_r)).rgb;
}

View File

@@ -59,7 +59,7 @@ vec4 texture4D(sampler3D table, float r, float mu, float muS, float nu)
float rmu = r * mu;
float delta = rmu * rmu - r * r + Rg * Rg;
vec4 cst = rmu < 0.0 && delta > 0.0 ? vec4(1.0, 0.0, 0.0, 0.5 - 0.5 / float(RES_MU)) : vec4(-1.0, H * H, H, 0.5 + 0.5 / float(RES_MU));
float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R));
float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R));
float uMu = cst.w + (rmu * cst.x + sqrt(delta + cst.y)) / (rho + cst.z) * (0.5 - 1.0 / float(RES_MU));
float uMuS = 0.5 / float(RES_MU_S) + (atan(max(muS, -0.1975) * tan(1.26 * 1.1)) / 1.1 + (1.0 - 0.26)) * 0.5 * (1.0 - 1.0 / float(RES_MU_S));
float lerp = (nu + 1.0) / 2.0 * (float(RES_NU) - 1.0);
@@ -82,9 +82,9 @@ float limit(float r, float mu) {
}
vec3 transmittanceFromTexture(const float r, const float mu) {
float u_r = sqrt((r - Rg) / (Rt - Rg));
float u_r = sqrt((r - Rg) / (Rt - Rg));
// See Colliene to understand the different mapping.
float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5;
float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5;
return texture(transmittanceTexture, vec2(u_mu, u_r)).rgb;
}

View File

@@ -37,9 +37,9 @@ void getRAndMu(out float r, out float mu) {
}
vec3 transmittance(const float r, const float mu) {
float u_r = sqrt((r - Rg) / (Rt - Rg));
float u_r = sqrt((r - Rg) / (Rt - Rg));
// See Colliene to understand the different mapping.
float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5;
float u_mu = atan((mu + 0.15) / (1.0 + 0.15) * tan(1.5)) / 1.5;
return texture(transmittanceTexture, vec2(u_mu, u_r)).rgb;
}

View File

@@ -57,7 +57,7 @@ vec4 texture4D(sampler3D table, const float r, const float mu,
float rmu = r * mu;
float delta = rmu * rmu - r * r + Rg * Rg;
vec4 cst = rmu < 0.0 && delta > 0.0 ? vec4(1.0, 0.0, 0.0, 0.5 - 0.5 / float(RES_MU)) : vec4(-1.0, H * H, H, 0.5 + 0.5 / float(RES_MU));
float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R));
float uR = 0.5 / float(RES_R) + rho / H * (1.0 - 1.0 / float(RES_R));
float uMu = cst.w + (rmu * cst.x + sqrt(delta + cst.y)) / (rho + cst.z) * (0.5 - 1.0 / float(RES_MU));
float uMuS = 0.5 / float(RES_MU_S) + (atan(max(muS, -0.1975) * tan(1.26 * 1.1)) / 1.1 + (1.0 - 0.26)) * 0.5 * (1.0 - 1.0 / float(RES_MU_S));
float lerp = (nu + 1.0) / 2.0 * (float(RES_NU) - 1.0);

View File

@@ -31,8 +31,8 @@ in vec4 fs_vertexPosition;
uniform vec4 color;
Fragment getFragment(){
Fragment frag;
frag.color = color;
frag.depth = fs_vertexPosition.w;
return frag;
Fragment frag;
frag.color = color;
frag.depth = fs_vertexPosition.w;
return frag;
}

View File

@@ -31,6 +31,6 @@ layout(location = 0) in vec4 vertexPositionClippingSpace;
out vec4 fs_vertexPosition;
void main(){
fs_vertexPosition = z_normalization(vertexPositionClippingSpace);
gl_Position = fs_vertexPosition;
fs_vertexPosition = z_normalization(vertexPositionClippingSpace);
gl_Position = fs_vertexPosition;
}

View File

@@ -44,7 +44,7 @@ namespace {
namespace openspace {
//////////////////////////////////////////////////////////////////////////////////////
// FRUSTUM CULLER //
// FRUSTUM CULLER //
//////////////////////////////////////////////////////////////////////////////////////
FrustumCuller::FrustumCuller(const AABB3 viewFrustum)
: _viewFrustum(viewFrustum){
@@ -81,7 +81,7 @@ namespace openspace {
//////////////////////////////////////////////////////////////////////////////////////
// HORIZON CULLER //
// HORIZON CULLER //
//////////////////////////////////////////////////////////////////////////////////////
HorizonCuller::HorizonCuller() {

View File

@@ -36,137 +36,137 @@ template <typename T>
class Angle {
public:
//////////////////////////////////////////////////////////////////////////////////////
// STATIC CONSTANTS //
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
// STATIC CONSTANTS //
//////////////////////////////////////////////////////////////////////////////////////
static const T PI;
static const T EPSILON;
static const T PI;
static const T EPSILON;
/** = 0 radians = 0 degrees = no revolution */
static const Angle<T> ZERO;
/** = 0 radians = 0 degrees = no revolution */
static const Angle<T> ZERO;
/** = PI/2 radians = 90 degrees = quarter of a revolution */
static const Angle<T> QUARTER;
/** = PI/2 radians = 90 degrees = quarter of a revolution */
static const Angle<T> QUARTER;
/** = PI radians = 180 degrees = half a revolution */
static const Angle<T> HALF;
/** = PI radians = 180 degrees = half a revolution */
static const Angle<T> HALF;
/** = 2PI radians = 360 degrees = a full revolution */
static const Angle<T> FULL;
/** = 2PI radians = 360 degrees = a full revolution */
static const Angle<T> FULL;
//////////////////////////////////////////////////////////////////////////////////////
// Factory Methods //
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
// Factory Methods //
//////////////////////////////////////////////////////////////////////////////////////
static Angle<T> fromRadians(T radians);
static Angle<T> fromDegrees(T degrees);
static Angle<T> fromRevolutions(T revs);
static Angle<T> fromRadians(T radians);
static Angle<T> fromDegrees(T degrees);
static Angle<T> fromRevolutions(T revs);
public:
/** Copy constructor */
Angle<T>(const Angle<T>& other);
/** Copy constructor */
Angle<T>(const Angle<T>& other);
private:
/** Private constructor. Use factory methods to avoid unit confusion */
Angle<T>(T rad);
/** Private constructor. Use factory methods to avoid unit confusion */
Angle<T>(T rad);
//////////////////////////////////////////////////////////////////////////////////////
// Conversions //
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
// Conversions //
//////////////////////////////////////////////////////////////////////////////////////
public:
inline T asRadians() const;
inline T asDegrees() const;
inline T asRevolutions() const;
inline T asRadians() const;
inline T asDegrees() const;
inline T asRevolutions() const;
//////////////////////////////////////////////////////////////////////////////////////
// Operators (boilerplate, I know.. /eb) //
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
// Operators (boilerplate, I know.. /eb) //
//////////////////////////////////////////////////////////////////////////////////////
Angle<T> operator+(const Angle<T>& rhs) const;
Angle<T> operator-(const Angle<T>& rhs) const;
Angle<T> operator*(T rhs) const;
Angle<T> operator/(T rhs) const;
Angle<T> operator+(const Angle<T>& rhs) const;
Angle<T> operator-(const Angle<T>& rhs) const;
Angle<T> operator*(T rhs) const;
Angle<T> operator/(T rhs) const;
Angle<T> operator-() const;
Angle<T> operator-() const;
void operator+=(const Angle<T>& rhs);
void operator-=(const Angle<T>& rhs);
void operator*=(T rhs);
void operator/=(T rhs);
void operator+=(const Angle<T>& rhs);
void operator-=(const Angle<T>& rhs);
void operator*=(T rhs);
void operator/=(T rhs);
bool operator<(const Angle<T>& rhs) const;
bool operator<=(const Angle<T>& rhs) const;
bool operator>(const Angle<T>& rhs) const;
bool operator>=(const Angle<T>& rhs) const;
bool operator==(const Angle<T>& rhs) const;
bool operator!=(const Angle<T>& rhs) const;
bool operator<(const Angle<T>& rhs) const;
bool operator<=(const Angle<T>& rhs) const;
bool operator>(const Angle<T>& rhs) const;
bool operator>=(const Angle<T>& rhs) const;
bool operator==(const Angle<T>& rhs) const;
bool operator!=(const Angle<T>& rhs) const;
//////////////////////////////////////////////////////////////////////////////////////
// Chainable Relative Mutators //
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
// Chainable Relative Mutators //
//////////////////////////////////////////////////////////////////////////////////////
/**
* Normalizes the angle to the interval [0, 2pi[
*/
Angle<T>& normalize();
/**
* Normalizes the angle to the interval [0, 2pi[
*/
Angle<T>& normalize();
/**
* Normalizes the angle to the interval [center - pi, center + pi[
*/
Angle<T>& normalizeAround(const Angle<T>& center);
/**
* Normalizes the angle to the interval [center - pi, center + pi[
*/
Angle<T>& normalizeAround(const Angle<T>& center);
/**
* Clamps the angle to the interval [min, max].
* Default arguments are [0, 2pi].
*/
Angle<T>& clamp(const Angle<T>& min = ZERO, const Angle<T>& max = FULL);
/**
* Clamps the angle to the interval [min, max].
* Default arguments are [0, 2pi].
*/
Angle<T>& clamp(const Angle<T>& min = ZERO, const Angle<T>& max = FULL);
Angle<T>& abs();
Angle<T>& abs();
//////////////////////////////////////////////////////////////////////////////////////
// Chainable Relative Factory Methods //
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
// Chainable Relative Factory Methods //
//////////////////////////////////////////////////////////////////////////////////////
/**
* Returns a new angle normalized to the interval [0, 2pi[
*/
Angle<T> getNormalized() const;
/**
* Returns a new angle normalized to the interval [0, 2pi[
*/
Angle<T> getNormalized() const;
/**
* Returns a new angle normalized to the interval [center - pi, center + pi[
*/
Angle<T> getNormalizedAround(const Angle<T>& center) const;
/**
* Returns a new angle normalized to the interval [center - pi, center + pi[
*/
Angle<T> getNormalizedAround(const Angle<T>& center) const;
/**
* Returns a new angle clamped to the interval [min, max].
* Default arguments are [0, 2pi].
*/
Angle<T> getClamped(const Angle<T>& min = ZERO, const Angle<T>& max = FULL) const;
/**
* Returns a new angle clamped to the interval [min, max].
* Default arguments are [0, 2pi].
*/
Angle<T> getClamped(const Angle<T>& min = ZERO, const Angle<T>& max = FULL) const;
Angle<T> getAbs() const;
Angle<T> getAbs() const;
private:
T _radians;
T _radians;
};

View File

@@ -61,10 +61,10 @@ const Angle<T> Angle<T>::FULL = Angle::fromRadians(2*PI);
//////////////////////////////////////////////////////////////////////////////////////////
template <typename T> Angle<T>::Angle(const Angle<T>& other)
: _radians(other._radians) { }
: _radians(other._radians) { }
template <typename T> Angle<T>::Angle(T radians)
: _radians(radians) { }
: _radians(radians) { }
@@ -75,17 +75,17 @@ template <typename T> Angle<T>::Angle(T radians)
template <typename T>
Angle<T> Angle<T>::fromRadians(T rads) {
return Angle<T>(rads);
return Angle<T>(rads);
}
template <typename T>
Angle<T> Angle<T>::fromDegrees(T degrees) {
return Angle<T>(degrees * PI / 180.0);
return Angle<T>(degrees * PI / 180.0);
}
template <typename T>
Angle<T> Angle<T>::fromRevolutions(T revs) {
return Angle<T>(revs * 2 * PI);
return Angle<T>(revs * 2 * PI);
}
@@ -96,17 +96,17 @@ Angle<T> Angle<T>::fromRevolutions(T revs) {
template <typename T>
T Angle<T>::asRadians() const {
return _radians;
return _radians;
}
template <typename T>
T Angle<T>::asDegrees() const {
return _radians * 180.0 / PI;
return _radians * 180.0 / PI;
}
template <typename T>
T Angle<T>::asRevolutions() const {
return _radians / (2 * PI);
return _radians / (2 * PI);
}
@@ -117,49 +117,49 @@ T Angle<T>::asRevolutions() const {
template <typename T>
Angle<T> Angle<T>::operator+(const Angle<T>& rhs) const{
return Angle<T>(_radians + rhs._radians);
return Angle<T>(_radians + rhs._radians);
}
template <typename T>
Angle<T> Angle<T>::operator-(const Angle<T>& rhs) const{
return Angle<T>(_radians - rhs._radians);
return Angle<T>(_radians - rhs._radians);
}
template <typename T>
Angle<T> Angle<T>::operator*(T multiplier) const{
return Angle<T>(_radians * multiplier);
return Angle<T>(_radians * multiplier);
}
template <typename T>
Angle<T> Angle<T>::operator/(T divisor) const{
return Angle<T>(_radians / divisor);
return Angle<T>(_radians / divisor);
}
template <typename T>
Angle<T> Angle<T>::operator-() const {
return Angle<T>(-_radians);
return Angle<T>(-_radians);
}
template <typename T>
void Angle<T>::operator+=(const Angle<T>& rhs){
_radians += rhs._radians;
_radians += rhs._radians;
}
template <typename T>
void Angle<T>::operator-=(const Angle<T>& rhs){
_radians -= rhs._radians;
_radians -= rhs._radians;
}
template <typename T>
void Angle<T>::operator*=(T multiplier){
_radians *= multiplier;
_radians *= multiplier;
}
template <typename T>
void Angle<T>::operator/=(T divisor){
_radians /= divisor;
_radians /= divisor;
}
@@ -167,32 +167,32 @@ void Angle<T>::operator/=(T divisor){
template <typename T>
bool Angle<T>::operator<(const Angle<T>& rhs) const{
return _radians < rhs._radians;
return _radians < rhs._radians;
}
template <typename T>
bool Angle<T>::operator<=(const Angle<T>& rhs) const{
return _radians <= rhs._radians;
return _radians <= rhs._radians;
}
template <typename T>
bool Angle<T>::operator>(const Angle<T>& rhs) const{
return _radians > rhs._radians;
return _radians > rhs._radians;
}
template <typename T>
bool Angle<T>::operator>=(const Angle<T>& rhs) const{
return _radians >= rhs._radians;
return _radians >= rhs._radians;
}
template <typename T>
bool Angle<T>::operator==(const Angle<T>& rhs) const{
return _radians == rhs._radians;
return _radians == rhs._radians;
}
template <typename T>
bool Angle<T>::operator!=(const Angle<T>& rhs) const{
return _radians != rhs._radians;
return _radians != rhs._radians;
}
@@ -203,38 +203,38 @@ bool Angle<T>::operator!=(const Angle<T>& rhs) const{
template <typename T>
Angle<T>& Angle<T>::normalize() {
// this will cause _radians to be in value range ]-2pi, 2pi[
_radians = fmod(_radians, 2*PI);
// this will cause _radians to be in value range ]-2pi, 2pi[
_radians = fmod(_radians, 2*PI);
// ensure _radians are positive, ie in value range [0, 2pi[
if (_radians < 0.0){
_radians += 2 * PI;
}
// ensure _radians are positive, ie in value range [0, 2pi[
if (_radians < 0.0){
_radians += 2 * PI;
}
return *this;
return *this;
}
template <typename T>
Angle<T>& Angle<T>::normalizeAround(const Angle<T>& center) {
_radians -= center._radians + PI;
normalize();
_radians += center._radians - PI;
return *this;
_radians -= center._radians + PI;
normalize();
_radians += center._radians - PI;
return *this;
}
template <typename T>
Angle<T>& Angle<T>::clamp(const Angle<T>& min, const Angle<T>& max) {
_radians = _radians < min._radians ? min._radians
: _radians > max._radians ? max._radians
: _radians;
return *this;
_radians = _radians < min._radians ? min._radians
: _radians > max._radians ? max._radians
: _radians;
return *this;
}
template <typename T>
Angle<T>& Angle<T>::abs(){
_radians = glm::abs(_radians);
return *this;
_radians = glm::abs(_radians);
return *this;
}
@@ -245,24 +245,24 @@ Angle<T>& Angle<T>::abs(){
template <typename T>
Angle<T> Angle<T>::getNormalized() const {
return Angle<T>(*this).normalize();
return Angle<T>(*this).normalize();
}
template <typename T>
Angle<T> Angle<T>::getNormalizedAround(const Angle<T>& center) const {
return Angle<T>(*this).normalizeAround(center);
return Angle<T>(*this).normalizeAround(center);
}
template <typename T>
Angle<T> Angle<T>::getClamped(const Angle<T>& min, const Angle<T>& max) const {
return Angle<T>(*this).clamp(min, max);
return Angle<T>(*this).clamp(min, max);
}
template <typename T>
Angle<T> Angle<T>::getAbs() const {
return Angle<T>(*this).abs();
return Angle<T>(*this).abs();
}
} // namespace openspace

View File

@@ -143,8 +143,8 @@ namespace openspace {
{
Vec3 normal = geodeticSurfaceNormalForGeocentricallyProjectedPoint(p);
return Geodetic2(
asin(normal.z / length(normal)), // Latitude
atan2(normal.y, normal.x)); // Longitude
asin(normal.z / length(normal)), // Latitude
atan2(normal.y, normal.x)); // Longitude
}
Vec3 Ellipsoid::cartesianSurfacePosition(const Geodetic2& geodetic2) const

View File

@@ -36,7 +36,7 @@ namespace {
namespace openspace {
//////////////////////////////////////////////////////////////////////////////////////
// GEODETIC2 //
// GEODETIC2 //
//////////////////////////////////////////////////////////////////////////////////////
Geodetic2::Geodetic2()
@@ -84,7 +84,7 @@ namespace openspace {
//////////////////////////////////////////////////////////////////////////////////////
// GEODETICPATCH //
// GEODETICPATCH //
//////////////////////////////////////////////////////////////////////////////////////
GeodeticPatch::GeodeticPatch(

View File

@@ -88,7 +88,7 @@ struct Geodetic3 {
//////////////////////////////////////////////////////////////////////////////////////
// GEODETICPATCH //
// GEODETICPATCH //
//////////////////////////////////////////////////////////////////////////////////////
class GeodeticPatch {
public:
@@ -108,7 +108,7 @@ public:
void setCenter(const Geodetic2&);
void setHalfSize(const Geodetic2&);
void setHalfSize(const Geodetic2&);
/**
returns the latitude boundary which is closest to the equator

View File

@@ -35,33 +35,33 @@
namespace openspace {
GlobeBrowsingModule::GlobeBrowsingModule()
: OpenSpaceModule("GlobeBrowsing")
GlobeBrowsingModule::GlobeBrowsingModule()
: OpenSpaceModule("GlobeBrowsing")
{}
void GlobeBrowsingModule::internalInitialize() {
/*
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "Renderable factory was not created");
/*
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "Renderable factory was not created");
fRenderable->registerClass<Planet>("Planet");
fRenderable->registerClass<RenderableTestPlanet>("RenderableTestPlanet");
//fRenderable->registerClass<planettestgeometry::PlanetTestGeometry>("PlanetTestGeometry");
fRenderable->registerClass<Planet>("Planet");
fRenderable->registerClass<RenderableTestPlanet>("RenderableTestPlanet");
//fRenderable->registerClass<planettestgeometry::PlanetTestGeometry>("PlanetTestGeometry");
auto fPlanetGeometry = FactoryManager::ref().factory<planettestgeometry::PlanetTestGeometry>();
ghoul_assert(fPlanetGeometry, "Planet test geometry factory was not created");
fPlanetGeometry->registerClass<planettestgeometry::SimpleSphereTestGeometry>("SimpleSphereTest");
auto fPlanetGeometry = FactoryManager::ref().factory<planettestgeometry::PlanetTestGeometry>();
ghoul_assert(fPlanetGeometry, "Planet test geometry factory was not created");
fPlanetGeometry->registerClass<planettestgeometry::SimpleSphereTestGeometry>("SimpleSphereTest");
*/
*/
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "Renderable factory was not created");
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "Renderable factory was not created");
fRenderable->registerClass<RenderableGlobe>("RenderableGlobe");
fRenderable->registerClass<RenderableGlobe>("RenderableGlobe");
}
} // namespace openspace

View File

@@ -31,7 +31,7 @@ namespace openspace {
class GlobeBrowsingModule : public OpenSpaceModule {
public:
GlobeBrowsingModule();
GlobeBrowsingModule();
protected:
void internalInitialize() override;

View File

@@ -25,39 +25,39 @@
#include <modules/globebrowsing/meshes/basicgrid.h>
namespace {
const std::string _loggerCat = "BasicGrid";
const std::string _loggerCat = "BasicGrid";
}
namespace openspace {
BasicGrid::BasicGrid(
unsigned int xSegments,
unsigned int ySegments,
TriangleSoup::Positions usePositions,
TriangleSoup::TextureCoordinates useTextureCoordinates,
TriangleSoup::Normals useNormals)
: Grid(
xSegments,
ySegments,
usePositions,
useTextureCoordinates,
useNormals)
unsigned int xSegments,
unsigned int ySegments,
TriangleSoup::Positions usePositions,
TriangleSoup::TextureCoordinates useTextureCoordinates,
TriangleSoup::Normals useNormals)
: Grid(
xSegments,
ySegments,
usePositions,
useTextureCoordinates,
useNormals)
{
_geometry = std::unique_ptr<TriangleSoup>(new TriangleSoup(
CreateElements(xSegments, ySegments),
usePositions,
useTextureCoordinates,
useNormals));
_geometry = std::unique_ptr<TriangleSoup>(new TriangleSoup(
CreateElements(xSegments, ySegments),
usePositions,
useTextureCoordinates,
useNormals));
if (usePositions == TriangleSoup::Positions::Yes) {
_geometry->setVertexPositions(CreatePositions(_xSegments, _ySegments));
}
if (useTextureCoordinates == TriangleSoup::TextureCoordinates::Yes) {
_geometry->setVertexTextureCoordinates(CreateTextureCoordinates(_xSegments, _ySegments));
}
if (useNormals == TriangleSoup::Normals::Yes) {
_geometry->setVertexNormals(CreateNormals(_xSegments, _ySegments));
}
if (usePositions == TriangleSoup::Positions::Yes) {
_geometry->setVertexPositions(CreatePositions(_xSegments, _ySegments));
}
if (useTextureCoordinates == TriangleSoup::TextureCoordinates::Yes) {
_geometry->setVertexTextureCoordinates(CreateTextureCoordinates(_xSegments, _ySegments));
}
if (useNormals == TriangleSoup::Normals::Yes) {
_geometry->setVertexNormals(CreateNormals(_xSegments, _ySegments));
}
}
BasicGrid::~BasicGrid()
@@ -66,110 +66,110 @@ BasicGrid::~BasicGrid()
}
int BasicGrid::xSegments() const {
return _xSegments;
return _xSegments;
}
int BasicGrid::ySegments() const {
return _ySegments;
return _ySegments;
}
void BasicGrid::validate(int xSegments, int ySegments) {
ghoul_assert(xSegments > 0 && ySegments > 0,
"Resolution must be at least 1x1. (" << xSegments << ", " << 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;
return 3 * 2 * xSegments * ySegments;
}
inline size_t BasicGrid::numVertices(int xSegments, int ySegments) {
return (xSegments + 1) * (ySegments + 1);
return (xSegments + 1) * (ySegments + 1);
}
std::vector<GLuint> BasicGrid::CreateElements(int xSegments, int ySegments) {
validate(xSegments, 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++) {
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 ..
// : : : :
// 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;
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 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);
}
}
// add lower triangle
elements.push_back(v00);
elements.push_back(v11);
elements.push_back(v01);
}
}
return elements;
return elements;
}
std::vector<glm::vec4> BasicGrid::CreatePositions(
int xSegments,
int ySegments)
int xSegments,
int ySegments)
{
validate(xSegments, ySegments);
std::vector<glm::vec4> positions;
positions.reserve(numVertices(xSegments, 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;
// 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));
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;
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));
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));
}
}
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;
return normals;
}
}// namespace openspace

View File

@@ -37,38 +37,38 @@ namespace openspace {
class BasicGrid : public Grid
{
public:
/**
\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,
TriangleSoup::Positions usePositions,
TriangleSoup::TextureCoordinates useTextureCoordinates,
TriangleSoup::Normals useNormals);
~BasicGrid();
/**
\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,
TriangleSoup::Positions usePositions,
TriangleSoup::TextureCoordinates useTextureCoordinates,
TriangleSoup::Normals useNormals);
~BasicGrid();
virtual int xSegments() const;
virtual int ySegments() const;
virtual int xSegments() const;
virtual int ySegments() const;
private:
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);
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);
void validate(int xSegments, int ySegments);
void validate(int xSegments, int ySegments);
inline size_t numElements(int xSegments, int ySegments);
inline size_t numVertices(int xSegments, int ySegments);
inline size_t numElements(int xSegments, int ySegments);
inline size_t numVertices(int xSegments, int ySegments);
};
} // namespace openspace
#endif // __BASICGRIDGEOMETRY_H__

View File

@@ -27,17 +27,17 @@
#include <ghoul/opengl/ghoul_gl.h>
namespace {
const std::string _loggerCat = "ClipMapGrid";
const std::string _loggerCat = "ClipMapGrid";
}
namespace openspace {
//////////////////////////////////////////////////////////////////////////////////////////
// CLIPMAP GRID (Abstract class) //
// CLIPMAP GRID (Abstract class) //
//////////////////////////////////////////////////////////////////////////////////////////
ClipMapGrid::ClipMapGrid(unsigned int segments)
: Grid(segments, segments, TriangleSoup::Positions::No, TriangleSoup::TextureCoordinates::Yes, TriangleSoup::Normals::No)
: Grid(segments, segments, TriangleSoup::Positions::No, TriangleSoup::TextureCoordinates::Yes, TriangleSoup::Normals::No)
{
}
@@ -48,31 +48,31 @@ ClipMapGrid::~ClipMapGrid()
}
int ClipMapGrid::xSegments() const {
return segments();
return segments();
}
int ClipMapGrid::ySegments() const {
return segments();
return segments();
}
int ClipMapGrid::segments() const {
return _xSegments;
return _xSegments;
}
//////////////////////////////////////////////////////////////////////////////////////////
// OUTER CLIPMAP GRID //
// OUTER CLIPMAP GRID //
//////////////////////////////////////////////////////////////////////////////////////////
OuterClipMapGrid::OuterClipMapGrid(unsigned int segments)
: ClipMapGrid(segments)
{
_geometry = std::unique_ptr<TriangleSoup>(new TriangleSoup(
CreateElements(segments, segments),
TriangleSoup::Positions::No,
TriangleSoup::TextureCoordinates::Yes,
TriangleSoup::Normals::No));
_geometry = std::unique_ptr<TriangleSoup>(new TriangleSoup(
CreateElements(segments, segments),
TriangleSoup::Positions::No,
TriangleSoup::TextureCoordinates::Yes,
TriangleSoup::Normals::No));
_geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments));
_geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments));
}
OuterClipMapGrid::~OuterClipMapGrid()
@@ -82,254 +82,254 @@ 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;
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);
return (segments + 1 + 2) * (segments / 4 + 1 + 1);
}
size_t OuterClipMapGrid::numVerticesLeft(int segments)
{
return (segments / 4 + 1 + 1) * (segments / 2 + 1);
return (segments / 4 + 1 + 1) * (segments / 2 + 1);
}
size_t OuterClipMapGrid::numVerticesRight(int segments)
{
return (segments / 4 + 1 + 1) * (segments / 2 + 1);
return (segments / 4 + 1 + 1) * (segments / 2 + 1);
}
size_t OuterClipMapGrid::numVerticesTop(int segments)
{
return (segments + 1 + 2) * (segments / 4 + 1 + 1);
return (segments + 1 + 2) * (segments / 4 + 1 + 1);
}
size_t OuterClipMapGrid::numVertices(int segments)
{
return numVerticesBottom(segments) +
numVerticesLeft(segments) +
numVerticesRight(segments) +
numVerticesTop(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 << ")");
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
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 ..
// : : : :
// 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);
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;
// 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(v10);
elements.push_back(v11);
elements.push_back(v00);
elements.push_back(v11);
elements.push_back(v01);
}
}
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;
// 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(v10);
elements.push_back(v11);
elements.push_back(v00);
elements.push_back(v11);
elements.push_back(v01);
}
}
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;
// 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(v10);
elements.push_back(v11);
elements.push_back(v00);
elements.push_back(v11);
elements.push_back(v01);
}
}
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;
// 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(v10);
elements.push_back(v11);
elements.push_back(v00);
elements.push_back(v11);
elements.push_back(v01);
}
}
return elements;
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);
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));
}
// 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;
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));
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;
// 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));
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));
}
}
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;
return normals;
}
//////////////////////////////////////////////////////////////////////////////////////////
// INNER CLIPMAP GRID //
// INNER CLIPMAP GRID //
//////////////////////////////////////////////////////////////////////////////////////////
InnerClipMapGrid::InnerClipMapGrid(unsigned int segments)
: ClipMapGrid(segments)
: ClipMapGrid(segments)
{
_geometry = std::unique_ptr<TriangleSoup>(new TriangleSoup(
CreateElements(segments, segments),
TriangleSoup::Positions::No,
TriangleSoup::TextureCoordinates::Yes,
TriangleSoup::Normals::No));
_geometry = std::unique_ptr<TriangleSoup>(new TriangleSoup(
CreateElements(segments, segments),
TriangleSoup::Positions::No,
TriangleSoup::TextureCoordinates::Yes,
TriangleSoup::Normals::No));
_geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments));
_geometry->setVertexTextureCoordinates(CreateTextureCoordinates(segments, segments));
}
InnerClipMapGrid::~InnerClipMapGrid()
@@ -339,109 +339,109 @@ InnerClipMapGrid::~InnerClipMapGrid()
size_t InnerClipMapGrid::numElements(int segments)
{
return segments * segments * 6;
return segments * segments * 6;
}
size_t InnerClipMapGrid::numVertices(int segments)
{
return (segments + 1) * (segments + 1);
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 << ")");
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));
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 ..
// : : : :
// 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;
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(v10);
elements.push_back(v11);
elements.push_back(v00);
elements.push_back(v11);
elements.push_back(v01);
}
}
elements.push_back(v00);
elements.push_back(v11);
elements.push_back(v01);
}
}
return elements;
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);
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));
}
// 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;
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));
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));
}
}
// 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;
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));
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));
}
}
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;
return normals;
}

View File

@@ -33,7 +33,7 @@
namespace openspace {
//////////////////////////////////////////////////////////////////////////////////////////
// CLIPMAP GRID (Abstract class) //
// CLIPMAP GRID (Abstract class) //
//////////////////////////////////////////////////////////////////////////////////////////
/**
@@ -48,23 +48,23 @@ snap to the outer layers grid cells.
class ClipMapGrid : public Grid
{
public:
ClipMapGrid(unsigned int segments);
ClipMapGrid(unsigned int segments);
~ClipMapGrid();
~ClipMapGrid();
virtual int xSegments() const;
virtual int ySegments() const;
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;
/**
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 //
// OUTER CLIPMAP GRID //
//////////////////////////////////////////////////////////////////////////////////////////
/**
@@ -75,30 +75,30 @@ a smaller ClipMapGrid of half the size can fit.
class OuterClipMapGrid : public ClipMapGrid
{
public:
OuterClipMapGrid(unsigned int segments);
OuterClipMapGrid(unsigned int segments);
~OuterClipMapGrid();
~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);
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);
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 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);
static size_t numElements(int segments);
static size_t numVertices(int segments);
};
//////////////////////////////////////////////////////////////////////////////////////////
// INNER CLIPMAP GRID //
// INNER CLIPMAP GRID //
//////////////////////////////////////////////////////////////////////////////////////////
/**
@@ -109,20 +109,20 @@ a whole where a smaller ClipMapGrid can be positioned.
class InnerClipMapGrid : public ClipMapGrid
{
public:
InnerClipMapGrid(unsigned int segments);
InnerClipMapGrid(unsigned int segments);
~InnerClipMapGrid();
~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);
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);
void validate(int xSegments, int ySegments);
static size_t numElements(int segments);
static size_t numVertices(int segments);
static size_t numElements(int segments);
static size_t numVertices(int segments);
};
} // namespace openspace

View File

@@ -25,19 +25,19 @@
#include <modules/globebrowsing/meshes/grid.h>
namespace {
const std::string _loggerCat = "Grid";
const std::string _loggerCat = "Grid";
}
namespace openspace {
Grid::Grid(
int xSegments,
int ySegments,
TriangleSoup::Positions usePositions,
TriangleSoup::TextureCoordinates useTextures,
TriangleSoup::Normals useNormals)
: _xSegments(xSegments)
, _ySegments(ySegments)
Grid::Grid(
int xSegments,
int ySegments,
TriangleSoup::Positions usePositions,
TriangleSoup::TextureCoordinates useTextures,
TriangleSoup::Normals useNormals)
: _xSegments(xSegments)
, _ySegments(ySegments)
{
}
@@ -49,7 +49,7 @@ Grid::~Grid()
TriangleSoup& Grid::geometry()
{
return *_geometry;
return *_geometry;
}
}// namespace openspace

View File

@@ -37,38 +37,38 @@ namespace openspace {
class Grid
{
public:
Grid(
int xSegments,
int ySegments,
TriangleSoup::Positions usePositions = TriangleSoup::Positions::No,
TriangleSoup::TextureCoordinates useTextures = TriangleSoup::TextureCoordinates::No,
TriangleSoup::Normals useNormals = TriangleSoup::Normals::No);
~Grid();
Grid(
int xSegments,
int ySegments,
TriangleSoup::Positions usePositions = TriangleSoup::Positions::No,
TriangleSoup::TextureCoordinates useTextures = TriangleSoup::TextureCoordinates::No,
TriangleSoup::Normals useNormals = TriangleSoup::Normals::No);
~Grid();
TriangleSoup& geometry();
TriangleSoup& geometry();
/**
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;
/**
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;
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;
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;
std::unique_ptr<TriangleSoup> _geometry;
std::unique_ptr<TriangleSoup> _geometry;
const int _xSegments;
const int _ySegments;
const int _xSegments;
const int _ySegments;
};
} // namespace openspace
#endif // __GRIDGEOMETRY_H__

View File

@@ -98,7 +98,7 @@ namespace openspace {
// | / |
// x v00---v10 x ..
//
// x x x x ..
// x x x x ..
// : : : :
GLuint v00 = (y + 0) * (xSegments + 2 + 1) + x + 0;

View File

@@ -60,10 +60,10 @@ public:
virtual int ySegments() const;
private:
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);
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);
void validate(int xSegments, int ySegments);

View File

@@ -25,154 +25,154 @@
#include <modules/globebrowsing/meshes/trianglesoup.h>
namespace {
const std::string _loggerCat = "TriangleSoup";
const std::string _loggerCat = "TriangleSoup";
}
namespace openspace
{
TriangleSoup::TriangleSoup(std::vector<unsigned int> elements,
Positions usePositions, TextureCoordinates useTextures, Normals useNormals)
: _vaoID(0)
,_vertexBufferID(0)
,_elementBufferID(0)
,_useVertexPositions(usePositions == Positions::Yes)
,_useTextureCoordinates(useTextures == TextureCoordinates::Yes)
,_useVertexNormals(useNormals == Normals::Yes)
Positions usePositions, TextureCoordinates useTextures, Normals useNormals)
: _vaoID(0)
,_vertexBufferID(0)
,_elementBufferID(0)
,_useVertexPositions(usePositions == Positions::Yes)
,_useTextureCoordinates(useTextures == TextureCoordinates::Yes)
,_useVertexNormals(useNormals == Normals::Yes)
{
setElements(elements);
setElements(elements);
}
TriangleSoup::~TriangleSoup() {
glDeleteBuffers(1, &_vertexBufferID);
glDeleteBuffers(1, &_elementBufferID);
glDeleteVertexArrays(1, &_vaoID);
glDeleteBuffers(1, &_vertexBufferID);
glDeleteBuffers(1, &_elementBufferID);
glDeleteVertexArrays(1, &_vaoID);
}
void TriangleSoup::setVertexPositions(std::vector<glm::vec4> positions) {
_useVertexPositions = true;
_gpuDataNeedUpdate = true;
_vertexData.resize(positions.size());
for (size_t i = 0; i < positions.size(); i++)
{
_vertexData[i].position[0] = static_cast<GLfloat>(positions[i].x);
_vertexData[i].position[1] = static_cast<GLfloat>(positions[i].y);
_vertexData[i].position[2] = static_cast<GLfloat>(positions[i].z);
_vertexData[i].position[3] = static_cast<GLfloat>(positions[i].w);
}
_useVertexPositions = true;
_gpuDataNeedUpdate = true;
_vertexData.resize(positions.size());
for (size_t i = 0; i < positions.size(); i++)
{
_vertexData[i].position[0] = static_cast<GLfloat>(positions[i].x);
_vertexData[i].position[1] = static_cast<GLfloat>(positions[i].y);
_vertexData[i].position[2] = static_cast<GLfloat>(positions[i].z);
_vertexData[i].position[3] = static_cast<GLfloat>(positions[i].w);
}
}
void TriangleSoup::setVertexTextureCoordinates(std::vector<glm::vec2> textures) {
_useTextureCoordinates = true;
_gpuDataNeedUpdate = true;
_vertexData.resize(textures.size());
for (size_t i = 0; i < textures.size(); i++)
{
_vertexData[i].texture[0] = static_cast<GLfloat>(textures[i].s);
_vertexData[i].texture[1] = static_cast<GLfloat>(textures[i].t);
}
_useTextureCoordinates = true;
_gpuDataNeedUpdate = true;
_vertexData.resize(textures.size());
for (size_t i = 0; i < textures.size(); i++)
{
_vertexData[i].texture[0] = static_cast<GLfloat>(textures[i].s);
_vertexData[i].texture[1] = static_cast<GLfloat>(textures[i].t);
}
}
void TriangleSoup::setVertexNormals(std::vector<glm::vec3> normals) {
_useVertexNormals = true;
_gpuDataNeedUpdate = true;
_vertexData.resize(normals.size());
for (size_t i = 0; i < normals.size(); i++)
{
_vertexData[i].normal[0] = static_cast<GLfloat>(normals[i].x);
_vertexData[i].normal[1] = static_cast<GLfloat>(normals[i].y);
_vertexData[i].normal[2] = static_cast<GLfloat>(normals[i].z);
}
_useVertexNormals = true;
_gpuDataNeedUpdate = true;
_vertexData.resize(normals.size());
for (size_t i = 0; i < normals.size(); i++)
{
_vertexData[i].normal[0] = static_cast<GLfloat>(normals[i].x);
_vertexData[i].normal[1] = static_cast<GLfloat>(normals[i].y);
_vertexData[i].normal[2] = static_cast<GLfloat>(normals[i].z);
}
}
void TriangleSoup::setElements(std::vector<unsigned int> elements) {
_elementData.resize(elements.size());
_gpuDataNeedUpdate = true;
for (size_t i = 0; i < elements.size(); i++)
{
_elementData[i] = static_cast<GLuint>(elements[i]);
}
_elementData.resize(elements.size());
_gpuDataNeedUpdate = true;
for (size_t i = 0; i < elements.size(); i++)
{
_elementData[i] = static_cast<GLuint>(elements[i]);
}
}
bool TriangleSoup::updateDataInGPU() {
// Create VAO
if (_vaoID == 0)
glGenVertexArrays(1, &_vaoID);
// Create VAO
if (_vaoID == 0)
glGenVertexArrays(1, &_vaoID);
// Create VBOs
if (_vertexBufferID == 0 && _vertexData.size() > 0) {
glGenBuffers(1, &_vertexBufferID);
if (_vertexBufferID == 0) {
LERROR("Could not create vertex buffer");
return false;
}
}
if (_elementBufferID == 0 && _elementData.size() > 0) {
glGenBuffers(1, &_elementBufferID);
if (_elementBufferID == 0) {
LERROR("Could not create vertex element buffer");
return false;
}
}
// Create VBOs
if (_vertexBufferID == 0 && _vertexData.size() > 0) {
glGenBuffers(1, &_vertexBufferID);
if (_vertexBufferID == 0) {
LERROR("Could not create vertex buffer");
return false;
}
}
if (_elementBufferID == 0 && _elementData.size() > 0) {
glGenBuffers(1, &_elementBufferID);
if (_elementBufferID == 0) {
LERROR("Could not create vertex element buffer");
return false;
}
}
// First VAO setup
glBindVertexArray(_vaoID);
// First VAO setup
glBindVertexArray(_vaoID);
// Vertex buffer
glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferID);
glBufferData(
GL_ARRAY_BUFFER,
_vertexData.size() * sizeof(Vertex),
&_vertexData[0],
GL_STATIC_DRAW);
// Vertex buffer
glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferID);
glBufferData(
GL_ARRAY_BUFFER,
_vertexData.size() * sizeof(Vertex),
&_vertexData[0],
GL_STATIC_DRAW);
// Positions at location 0
if (_useVertexPositions) {
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, position)));
}
// Textures at location 1
if (_useTextureCoordinates) {
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, texture)));
}
// Normals at location 2
if (_useVertexNormals) {
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)));
}
// Positions at location 0
if (_useVertexPositions) {
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, position)));
}
// Textures at location 1
if (_useTextureCoordinates) {
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, texture)));
}
// Normals at location 2
if (_useVertexNormals) {
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)));
}
// Element buffer
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _elementBufferID);
glBufferData(
GL_ELEMENT_ARRAY_BUFFER,
_elementData.size() * sizeof(GLint),
&_elementData[0],
GL_STATIC_DRAW);
// Element buffer
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _elementBufferID);
glBufferData(
GL_ELEMENT_ARRAY_BUFFER,
_elementData.size() * sizeof(GLint),
&_elementData[0],
GL_STATIC_DRAW);
glBindVertexArray(0);
glBindVertexArray(0);
_gpuDataNeedUpdate = false;
return true;
return true;
}
void TriangleSoup::drawUsingActiveProgram() {
if (_gpuDataNeedUpdate) {
updateDataInGPU();
}
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _elementBufferID);
glDrawElements(GL_TRIANGLES, _elementData.size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
if (_gpuDataNeedUpdate) {
updateDataInGPU();
}
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _elementBufferID);
glDrawElements(GL_TRIANGLES, _elementData.size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
}
} // namespace openspace

View File

@@ -35,67 +35,67 @@
namespace openspace {
/**
Class to hold vertex data and handling OpenGL interfacing and rendering. A Geometry
has all data needed such as position buffer and normal buffer but all data is not
necessarily needed for all purpouses so the Geometry can disable use of normals for
example.
Class to hold vertex data and handling OpenGL interfacing and rendering. A Geometry
has all data needed such as position buffer and normal buffer but all data is not
necessarily needed for all purpouses so the Geometry can disable use of normals for
example.
*/
// TODO : Possibly render triangle strips in this class instead of triangles since
// that is faster
// TODO : Possibly render triangle strips in this class instead of triangles since
// that is faster
class TriangleSoup
{
public:
enum class Positions { Yes, No };
enum class TextureCoordinates { Yes, No };
enum class Normals { Yes, No };
enum class Positions { Yes, No };
enum class TextureCoordinates { Yes, No };
enum class Normals { Yes, No };
TriangleSoup(
std::vector<unsigned int> elements, // At least elements are required
Positions usePositions = Positions::No,
TextureCoordinates useTextures = TextureCoordinates::No,
Normals useNormals = Normals::No);
~TriangleSoup();
TriangleSoup(
std::vector<unsigned int> elements, // At least elements are required
Positions usePositions = Positions::No,
TextureCoordinates useTextures = TextureCoordinates::No,
Normals useNormals = Normals::No);
~TriangleSoup();
// Setters
void setVertexPositions(std::vector<glm::vec4> positions);
void setVertexTextureCoordinates(std::vector<glm::vec2> textures);
void setVertexNormals(std::vector<glm::vec3> normals);
void setElements(std::vector<unsigned int> elements);
// Setters
void setVertexPositions(std::vector<glm::vec4> positions);
void setVertexTextureCoordinates(std::vector<glm::vec2> textures);
void setVertexNormals(std::vector<glm::vec3> normals);
void setElements(std::vector<unsigned int> elements);
void drawUsingActiveProgram();
void drawUsingActiveProgram();
protected:
// Determines what attribute data is in use
bool _useVertexPositions;
bool _useTextureCoordinates;
bool _useVertexNormals;
// Determines what attribute data is in use
bool _useVertexPositions;
bool _useTextureCoordinates;
bool _useVertexNormals;
typedef struct {
public:
GLfloat position[4];
GLfloat texture[2];
GLfloat normal[3];
private:
GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase
} Vertex;
typedef struct {
public:
GLfloat position[4];
GLfloat texture[2];
GLfloat normal[3];
private:
GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase
} Vertex;
// Vertex data
std::vector<Vertex> _vertexData;
std::vector<GLuint> _elementData;
// Vertex data
std::vector<Vertex> _vertexData;
std::vector<GLuint> _elementData;
private:
bool updateDataInGPU();
bool updateDataInGPU();
// GL handles
GLuint _vaoID;
GLuint _vertexBufferID;
GLuint _elementBufferID;
// GL handles
GLuint _vaoID;
GLuint _vertexBufferID;
GLuint _elementBufferID;
bool _gpuDataNeedUpdate;
bool _gpuDataNeedUpdate;
};
} // namespace openspace

View File

@@ -26,7 +26,7 @@
#include <modules/globebrowsing/other/distanceswitch.h>
namespace {
const std::string _loggerCat = "DistanceSwitch";
const std::string _loggerCat = "DistanceSwitch";
}
namespace openspace {
@@ -40,59 +40,59 @@ DistanceSwitch::~DistanceSwitch() {
}
bool DistanceSwitch::initialize() {
for (int i = 0; i < _renderables.size(); ++i) {
_renderables[i]->initialize();
}
return true;
for (int i = 0; i < _renderables.size(); ++i) {
_renderables[i]->initialize();
}
return true;
}
bool DistanceSwitch::deinitialize() {
for (int i = 0; i < _renderables.size(); ++i) {
_renderables[i]->deinitialize();
}
return true;
for (int i = 0; i < _renderables.size(); ++i) {
_renderables[i]->deinitialize();
}
return true;
}
bool DistanceSwitch::isReady() const {
return true;
return true;
}
void DistanceSwitch::render(const RenderData& data) {
if (_maxDistances.size() == 0) {
return;
}
if (_maxDistances.size() == 0) {
return;
}
pss pssDistanceToCamera = (data.camera.position() - data.position).length();
double distanceToCamera = pssDistanceToCamera.lengthd();
pss pssDistanceToCamera = (data.camera.position() - data.position).length();
double distanceToCamera = pssDistanceToCamera.lengthd();
if (distanceToCamera > _maxDistances.back()) {
return;
}
if (distanceToCamera > _maxDistances.back()) {
return;
}
// linear search through nodes to find which Renderable to render
for (int i = 0; i < _renderables.size(); ++i) {
if (distanceToCamera < _maxDistances[i]) {
_renderables[i]->render(data);
return;
}
}
// linear search through nodes to find which Renderable to render
for (int i = 0; i < _renderables.size(); ++i) {
if (distanceToCamera < _maxDistances[i]) {
_renderables[i]->render(data);
return;
}
}
}
void DistanceSwitch::update(const UpdateData& data) {
for (int i = 0; i < _renderables.size(); ++i) {
_renderables[i]->update(data);
}
for (int i = 0; i < _renderables.size(); ++i) {
_renderables[i]->update(data);
}
}
void DistanceSwitch::addSwitchValue(std::shared_ptr<Renderable> renderable, double maxDistance) {
ghoul_assert(maxDistance > 0, "Renderable must have a positive maxDistance");
if (_maxDistances.size() > 0){
ghoul_assert(maxDistance > _maxDistances.back(),
"Renderables must be inserted in ascending order wrt distance");
}
_renderables.push_back(renderable);
_maxDistances.push_back(maxDistance);
ghoul_assert(maxDistance > 0, "Renderable must have a positive maxDistance");
if (_maxDistances.size() > 0){
ghoul_assert(maxDistance > _maxDistances.back(),
"Renderables must be inserted in ascending order wrt distance");
}
_renderables.push_back(renderable);
_maxDistances.push_back(maxDistance);
}
} // namespace openspace

View File

@@ -38,36 +38,36 @@ namespace openspace {
/**
Selects a specific Renderable to be used for rendering, based on distance to the
camera
Selects a specific Renderable to be used for rendering, based on distance to the
camera
*/
class DistanceSwitch {
public:
DistanceSwitch();
virtual ~DistanceSwitch();
DistanceSwitch();
virtual ~DistanceSwitch();
bool initialize();
bool deinitialize();
bool isReady() const;
bool initialize();
bool deinitialize();
bool isReady() const;
/**
Picks the first Renderable with the associated maxDistance greater than the
current distance to the camera
*/
void render(const RenderData& data);
void update(const UpdateData& data);
/**
Picks the first Renderable with the associated maxDistance greater than the
current distance to the camera
*/
void render(const RenderData& data);
void update(const UpdateData& data);
/**
Adds a new renderable (first argument) which may be rendered only if the distance
to the camera is less than maxDistance (second argument)
*/
void addSwitchValue(std::shared_ptr<Renderable> renderable, double maxDistance);
/**
Adds a new renderable (first argument) which may be rendered only if the distance
to the camera is less than maxDistance (second argument)
*/
void addSwitchValue(std::shared_ptr<Renderable> renderable, double maxDistance);
private:
std::vector<std::shared_ptr<Renderable>> _renderables;
std::vector<double> _maxDistances;
std::vector<std::shared_ptr<Renderable>> _renderables;
std::vector<double> _maxDistances;
};
} // openspace

View File

@@ -38,13 +38,13 @@ namespace openspace {
: _cacheSize(size) { }
template<typename KeyType, typename ValueType>
LRUCache<KeyType, ValueType>::~LRUCache() {
LRUCache<KeyType, ValueType>::~LRUCache() {
// Clean up list and map!
}
//////////////////////////////
// PUBLIC INTERFACE //
// PUBLIC INTERFACE //
//////////////////////////////
template<typename KeyType, typename ValueType>
@@ -94,7 +94,7 @@ namespace openspace {
//////////////////////////////
// PRIVATE HELPERS //
// PRIVATE HELPERS //
//////////////////////////////
template<typename KeyType, typename ValueType>
void LRUCache<KeyType, ValueType>::clean()

View File

@@ -26,14 +26,14 @@
#include "fragment.glsl"
Fragment getFragment() {
Fragment frag;
frag.color = getTileFragColor();
Fragment frag;
frag.color = getTileFragColor();
#if SHOW_CHUNK_EDGES
frag.color += patchBorderOverlay(fs_uv, vec3(0,1,0), 0.005);
frag.color += patchBorderOverlay(fs_uv, vec3(0,1,0), 0.005);
#endif // SHOW_CHUNK_EDGES
frag.depth = fs_position.w;
return frag;
frag.depth = fs_position.w;
return frag;
}

View File

@@ -46,35 +46,35 @@ out vec3 ellipsoidNormalCameraSpace;
out LevelWeights levelWeights;
PositionNormalPair globalInterpolation() {
vec2 lonLatInput;
lonLatInput.y = minLatLon.y + lonLatScalingFactor.y * in_uv.y; // Lat
lonLatInput.x = minLatLon.x + lonLatScalingFactor.x * in_uv.x; // Lon
PositionNormalPair positionPairModelSpace = geodetic2ToCartesian(lonLatInput.y, lonLatInput.x, radiiSquared);
return positionPairModelSpace;
vec2 lonLatInput;
lonLatInput.y = minLatLon.y + lonLatScalingFactor.y * in_uv.y; // Lat
lonLatInput.x = minLatLon.x + lonLatScalingFactor.x * in_uv.x; // Lon
PositionNormalPair positionPairModelSpace = geodetic2ToCartesian(lonLatInput.y, lonLatInput.x, radiiSquared);
return positionPairModelSpace;
}
void main() {
PositionNormalPair pair = globalInterpolation();
float distToVertexOnEllipsoid = length(pair.position - cameraPosition);
PositionNormalPair pair = globalInterpolation();
float distToVertexOnEllipsoid = length(pair.position - cameraPosition);
float levelInterpolationParameter = getLevelInterpolationParameter(chunkLevel, distanceScaleFactor, distToVertexOnEllipsoid);
float levelInterpolationParameter = getLevelInterpolationParameter(chunkLevel, distanceScaleFactor, distToVertexOnEllipsoid);
// use level weight for height sampling, and output to fragment shader
levelWeights = getLevelWeights(levelInterpolationParameter);
// use level weight for height sampling, and output to fragment shader
levelWeights = getLevelWeights(levelInterpolationParameter);
// Get the height value
float height = getTileVertexHeight(in_uv, levelWeights);
// Get the height value
float height = getTileVertexHeight(in_uv, levelWeights);
// Apply skirts
height -= getTileVertexSkirtLength();
// Add the height in the direction of the normal
pair.position += pair.normal * height;
vec4 positionClippingSpace = modelViewProjectionTransform * vec4(pair.position, 1);
// Apply skirts
height -= getTileVertexSkirtLength();
// Add the height in the direction of the normal
pair.position += pair.normal * height;
vec4 positionClippingSpace = modelViewProjectionTransform * vec4(pair.position, 1);
// Write output
fs_uv = in_uv;
fs_position = z_normalization(positionClippingSpace);
gl_Position = fs_position;
ellipsoidNormalCameraSpace = mat3(modelViewTransform) * pair.normal;
// Write output
fs_uv = in_uv;
fs_position = z_normalization(positionClippingSpace);
gl_Position = fs_position;
ellipsoidNormalCameraSpace = mat3(modelViewTransform) * pair.normal;
}

View File

@@ -26,14 +26,14 @@
#include "fragment.glsl"
Fragment getFragment() {
Fragment frag;
frag.color = getTileFragColor();
Fragment frag;
frag.color = getTileFragColor();
#if SHOW_CHUNK_EDGES
frag.color += patchBorderOverlay(fs_uv, vec3(1,0,0), 0.005);
frag.color += patchBorderOverlay(fs_uv, vec3(1,0,0), 0.005);
#endif // SHOW_CHUNK_EDGES
frag.depth = fs_position.w;
return frag;
frag.depth = fs_position.w;
return frag;
}

View File

@@ -49,39 +49,39 @@ out LevelWeights levelWeights;
vec3 bilinearInterpolation(vec2 uv) {
vec3 p0 = (1 - uv.x) * p00 + uv.x * p10;
vec3 p1 = (1 - uv.x) * p01 + uv.x * p11;
vec3 p = (1 - uv.y) * p0 + uv.y * p1;
return p;
vec3 p0 = (1 - uv.x) * p00 + uv.x * p10;
vec3 p1 = (1 - uv.x) * p01 + uv.x * p11;
vec3 p = (1 - uv.y) * p0 + uv.y * p1;
return p;
}
void main() {
// Position in cameraspace
vec3 p = bilinearInterpolation(in_uv);
// Position in cameraspace
vec3 p = bilinearInterpolation(in_uv);
// Calculate desired level based on distance to the vertex on the ellipsoid
// Before any heightmapping is done
float distToVertexOnEllipsoid = length(p);
float levelInterpolationParameter = getLevelInterpolationParameter(chunkLevel, distanceScaleFactor, distToVertexOnEllipsoid);
float distToVertexOnEllipsoid = length(p);
float levelInterpolationParameter = getLevelInterpolationParameter(chunkLevel, distanceScaleFactor, distToVertexOnEllipsoid);
// use level weight for height sampling, and output to fragment shader
levelWeights = getLevelWeights(levelInterpolationParameter);
// use level weight for height sampling, and output to fragment shader
levelWeights = getLevelWeights(levelInterpolationParameter);
// Get the height value
float height = getTileVertexHeight(in_uv, levelWeights);
// Get the height value
float height = getTileVertexHeight(in_uv, levelWeights);
// Apply skirts
height -= getTileVertexSkirtLength();
// Translate the point along normal
p += patchNormalCameraSpace * height;
// Apply skirts
height -= getTileVertexSkirtLength();
// Translate the point along normal
p += patchNormalCameraSpace * height;
vec4 positionClippingSpace = projectionTransform * vec4(p, 1);
// Write output
fs_uv = in_uv;
fs_position = z_normalization(positionClippingSpace);
gl_Position = fs_position;
ellipsoidNormalCameraSpace = patchNormalCameraSpace;
vec4 positionClippingSpace = projectionTransform * vec4(p, 1);
// Write output
fs_uv = in_uv;
fs_position = z_normalization(positionClippingSpace);
gl_Position = fs_position;
ellipsoidNormalCameraSpace = patchNormalCameraSpace;
}

View File

@@ -33,7 +33,7 @@
#include <modules/globebrowsing/tile/layeredtextures.h>
//////////////////////////////////////////////////////////////////////////////////////////
// LAYERED TEXTURE SHADER PROVIDER //
// LAYERED TEXTURE SHADER PROVIDER //
//////////////////////////////////////////////////////////////////////////////////////////
namespace openspace {

View File

@@ -662,8 +662,8 @@ namespace openspace {
dataDest, // Where to put data
io.write.region.numPixels.x, // width to write x in destination
io.write.region.numPixels.y, // width to write y in destination
_dataLayout.gdalType, // Type
_dataLayout.bytesPerPixel, // Pixel spacing
_dataLayout.gdalType, // Type
_dataLayout.bytesPerPixel, // Pixel spacing
-io.write.bytesPerLine); // Line spacing
}

View File

@@ -38,7 +38,7 @@
//////////////////////////////////////////////////////////////////////////////////////////
// TILE PROVIDER //
// TILE PROVIDER //
//////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -40,7 +40,7 @@
//////////////////////////////////////////////////////////////////////////////////////////
// TILE PROVIDER //
// TILE PROVIDER //
//////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -41,7 +41,7 @@
//////////////////////////////////////////////////////////////////////////////////////////
// TILE PROVIDER //
// TILE PROVIDER //
//////////////////////////////////////////////////////////////////////////////////////////
namespace openspace {

View File

@@ -45,7 +45,7 @@
//////////////////////////////////////////////////////////////////////////////////////////
// TILE PROVIDER //
// TILE PROVIDER //
//////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -28,10 +28,10 @@
namespace openspace{
class IswaKameleonGroup : public IswaDataGroup{
public:
IswaKameleonGroup(std::string name, std::string type);
~IswaKameleonGroup();
IswaKameleonGroup(std::string name, std::string type);
~IswaKameleonGroup();
virtual void clearGroup();
virtual void clearGroup();
std::vector<int> fieldlineValue();
void setFieldlineInfo(std::string fieldlineIndexFile, std::string kameleonPath);

View File

@@ -27,7 +27,7 @@
#include <fstream>
namespace {
const std::string _loggerCat = "DataProcessor";
const std::string _loggerCat = "DataProcessor";
}
namespace openspace {

View File

@@ -43,12 +43,12 @@ public:
private:
void initializeKameleonWrapper(std::string kwPath);
std::shared_ptr<KameleonWrapper> _kw;
std::string _kwPath;
std::vector<std::string> _loadedVariables;
bool _initialized;
float _slice;
// std::vector<float*> _data;
std::shared_ptr<KameleonWrapper> _kw;
std::string _kwPath;
std::vector<std::string> _loadedVariables;
bool _initialized;
float _slice;
// std::vector<float*> _data;
};
}// namespace

View File

@@ -38,9 +38,9 @@ public:
virtual std::vector<float*> processData(std::string data, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) override;
private:
// void initialize(int numOptions);
// void add(std::vector<std::vector<float>>& optionValues, std::vector<float>& sum);
// void calculateFilterValues(std::vector<int> selectedOptions);
// void initialize(int numOptions);
// void add(std::vector<std::vector<float>>& optionValues, std::vector<float>& sum);
// void calculateFilterValues(std::vector<int> selectedOptions);
};
}// namespace

View File

@@ -35,11 +35,11 @@ out vec4 worldPosition;
#include "PowerScaling/powerScaling_vs.hglsl"
void main() {
vPosition = vertPosition.xyz;
vPosition = vertPosition.xyz;
worldPosition = vec4(vertPosition.xyz, 0.0);
vec4 position = pscTransform(worldPosition, modelTransform);
worldPosition = vec4(vertPosition.xyz, 0.0);
vec4 position = pscTransform(worldPosition, modelTransform);
// project the position to view space
// project the position to view space
gl_Position = z_normalization(viewProjection * position);
}

View File

@@ -63,7 +63,7 @@ double SGCTWindowWrapper::averageDeltaTime() const {
}
double SGCTWindowWrapper::deltaTime() const {
return sgct::Engine::instance()->getDt();
return sgct::Engine::instance()->getDt();
}
glm::vec2 SGCTWindowWrapper::mousePosition() const {

View File

@@ -47,7 +47,7 @@ double WindowWrapper::averageDeltaTime() const {
}
double WindowWrapper::deltaTime() const {
return 0.0;
return 0.0;
}
glm::vec2 WindowWrapper::mousePosition() const {

View File

@@ -302,7 +302,7 @@ void InteractionHandler::orbit(const float &dx, const float &dy, const float &dz
}
//new camera position
relative = origin + relative_focus_coordinate;
relative = origin + relative_focus_coordinate;
psc target = relative + relative_focus_coordinate * dist * zoomSpeed;

View File

@@ -107,9 +107,9 @@ namespace openspace {
const std::string RenderEngine::KeyFontMono = "Mono";
const std::string RenderEngine::KeyFontLight = "Light";
const std::vector<RenderEngine::FrametimeType> RenderEngine::FrametimeTypes({
RenderEngine::FrametimeType::DtTimeAvg,
RenderEngine::FrametimeType::FPS,
RenderEngine::FrametimeType::FPSAvg
RenderEngine::FrametimeType::DtTimeAvg,
RenderEngine::FrametimeType::FPS,
RenderEngine::FrametimeType::FPSAvg
});
RenderEngine::RenderEngine()
@@ -126,7 +126,7 @@ RenderEngine::RenderEngine()
, _fadeDuration(2.f)
, _currentFadeTime(0.f)
, _fadeDirection(0)
, _frametimeType(FrametimeType::DtTimeAvg)
, _frametimeType(FrametimeType::DtTimeAvg)
// , _sgctRenderStatisticsVisible(false)
{
_onScreenInformation = {
@@ -735,12 +735,12 @@ scripting::LuaLibrary RenderEngine::luaLibrary() {
"bool",
"Toggles the showing of render information on-screen text"
},
{
"toggleFrametimeType",
&luascriptfunctions::toggleFrametimeType,
"int",
"Toggle showing FPS or Average Frametime in heads up info"
},
{
"toggleFrametimeType",
&luascriptfunctions::toggleFrametimeType,
"int",
"Toggle showing FPS or Average Frametime in heads up info"
},
{
"setPerformanceMeasurement",
&luascriptfunctions::setPerformanceMeasurement,

View File

@@ -104,16 +104,16 @@ int showRenderInformation(lua_State* L) {
* Cycle through showing FPS or Average Frametime in heads up info
*/
int toggleFrametimeType(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
const int type = lua_type(L, -1);
if (type != LUA_TNUMBER)
return luaL_error(L, "Expected argument of type 'number'");
int t = lua_tonumber(L, -1);
OsEng.renderEngine().toggleFrametimeType(t);
return 0;
const int type = lua_type(L, -1);
if (type != LUA_TNUMBER)
return luaL_error(L, "Expected argument of type 'number'");
int t = lua_tonumber(L, -1);
OsEng.renderEngine().toggleFrametimeType(t);
return 0;
}
/**

View File

@@ -36,7 +36,7 @@
namespace openspace {
//////////////////////////////////////////////////////////////////////////////////////
// CAMERA //
// CAMERA //
//////////////////////////////////////////////////////////////////////////////////////
namespace {
@@ -246,7 +246,7 @@ namespace openspace {
}
//////////////////////////////////////////////////////////////////////////////////////
// SGCT INTERNAL //
// SGCT INTERNAL //
//////////////////////////////////////////////////////////////////////////////////////
Camera::SgctInternal::SgctInternal()
: _viewMatrix()

View File

@@ -77,7 +77,7 @@ float PowerScaledScalar::lengthf() const {
}
double PowerScaledScalar::lengthd() const {
return static_cast<double>(_data[0]) * pow(k, static_cast<double>(_data[1]));
return static_cast<double>(_data[0]) * pow(k, static_cast<double>(_data[1]));
}
PowerScaledScalar& PowerScaledScalar::operator=(const PowerScaledScalar &rhs) {