Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill poles #42

Merged
merged 33 commits into from
May 31, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5dd4b85
Initial submit of implementation to fill the north and south poles wh…
bagnell May 23, 2012
2a07357
Merge branch 'master' into fill_poles
bagnell May 23, 2012
7f9c8e0
Factor out some code from tile and add it to a new extent object in p…
bagnell May 23, 2012
2aea62c
Merge branch 'master' into fill_poles
bagnell May 23, 2012
baa0cff
Add frustum and occlusion culling to the poles. Fix some typos and ad…
bagnell May 24, 2012
7bf249f
Factor out common functions in the central body tile shaders that wil…
bagnell May 24, 2012
bc87f96
Merge branch 'master' into fill_poles
bagnell May 24, 2012
fab8a07
Add lighting to the poles.
bagnell May 24, 2012
6ff0683
Expose color members for the north/south pole.
bagnell May 24, 2012
113defb
Make the night color black if there is no night texture.
bagnell May 24, 2012
e600c1c
Change start intensity of the poles. The poles looked odd with Bing M…
bagnell May 24, 2012
98e9a50
Merge branch 'master' into fill_poles
bagnell May 24, 2012
0d7ba37
Fix pole quad computation for horizon views.
bagnell May 25, 2012
90bb2ee
Discard the fragment earlier if possible.
bagnell May 25, 2012
eb8ebc6
Merge branch 'master' into fill_poles
pjcozzi May 25, 2012
61a7609
Move function to compute window coordinates to transforms, add tests.
bagnell May 29, 2012
951a86e
Add agi_inverseProjection automatic uniform test.
bagnell May 29, 2012
0b077e8
Add tests for glsl built-in functions that transform between eye coor…
bagnell May 29, 2012
67fdf56
Combine Rectangle and AxisAlignedBoundingRectangle. Add Extent tests …
bagnell May 29, 2012
3048358
Change pole VA's usage to stream and fix the rectangle spec so it runs.
bagnell May 30, 2012
9adab0c
Change all extent object literals to use the new Extent object.
bagnell May 30, 2012
5835cfc
Merge branch 'master' into fill_poles
bagnell May 30, 2012
b516447
Fix broken tests.
bagnell May 30, 2012
b335653
Add a workaround to the shader used for the ground atmosphere from sp…
bagnell May 31, 2012
1d78239
Tweak shader to work correctly on AMD.
bagnell May 31, 2012
836a489
Don't destroy a pole VBO if it is not visible, just don't update or d…
bagnell May 31, 2012
b51cc5e
Changed Extent to accept extents over the international date line and…
bagnell May 31, 2012
9330963
Update CHANGES.md
bagnell May 31, 2012
4e1e6e4
Merge branch 'master' into fill_poles
bagnell May 31, 2012
b9f1b26
CHANGES.md tweaks.
pjcozzi May 31, 2012
aead19e
Merge branch 'master' into fill_poles
bagnell May 31, 2012
a837301
Fix broken tests and examples from merge.
bagnell May 31, 2012
ffbee3d
Change missed test to use Extent.
bagnell May 31, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Beta Releases
### b6 - TBA

* Breaking changes:
* Changed Tipsify.tipsify and Tipsify.calculateACMR to accept an object literal instead of three separate arguments. Supplying a maximum index and cache size is now optional.
* TBA
* Changed `Tipsify.tipsify` and `Tipsify.calculateACMR` to accept an object literal instead of three separate arguments. Supplying a maximum index and cache size is now optional.
* Added `CentralBody.northPoleColor` and `CentralBody.southPoleColor` to fill in the poles if they are not covered by a texture.

### b5 - 05/15/2012

Expand Down
12 changes: 6 additions & 6 deletions Examples/Sandbox/CodeSnippets/Polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
Sandbox.PolygonWithExtent = function (scene, ellipsoid, primitives) {
this.code = function() {
var polygon = new Cesium.Polygon(undefined);
polygon.configureExtent({
north : Cesium.Math.toRadians(90.0),
south : Cesium.Math.toRadians(50.0),
east : Cesium.Math.toRadians(180.0),
west : Cesium.Math.toRadians(-180.0)
});
polygon.configureExtent(new Cesium.Extent(
Cesium.Math.toRadians(-180.0),
Cesium.Math.toRadians(50.0),
Cesium.Math.toRadians(180.0),
Cesium.Math.toRadians(90.0)
));

primitives.add(polygon);
};
Expand Down
85 changes: 0 additions & 85 deletions Source/Core/AxisAlignedBoundingRectangle.js

This file was deleted.

261 changes: 261 additions & 0 deletions Source/Core/Extent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
/*global define*/
define([
'../Core/BoundingSphere',
'../Core/Cartesian3',
'../Core/Cartographic2',
'../Core/Cartographic3',
'../Core/DeveloperError',
'../Core/Ellipsoid',
'../Core/Math',
'../Core/Occluder',
'../Core/Rectangle'
], function(
BoundingSphere,
Cartesian3,
Cartographic2,
Cartographic3,
DeveloperError,
Ellipsoid,
CesiumMath,
Occluder,
Rectangle) {
"use strict";

/**
* Two-dimensional coordinates given in latitude and longitude.
*
* @name Extent
* @constructor
*
* @param {Number} north The northernmost latitude in the range [-Pi/2, Pi/2].
* @param {Number} east The easternmost longitude in the range [-Pi, Pi].
* @param {Number} south The southernmost latitude in the range [-Pi/2, Pi/2].
* @param {Number} west The westernmost longitude in the range [-Pi, Pi].
*
* @exception {DeveloperError} One of the parameters is out of range.
*/
function Extent(west, south, east, north) {
/**
* The northernmost latitude.
*
* @type Number
*/
this.north = north;

/**
* The southernmost latitude.
*
* @type Number
*/
this.south = south;

/**
* The westernmost longitude.
*
* @type Number
*/
this.west = west;

/**
* The easternmost longitude.
*
* @type Number
*/
this.east = east;

Extent.validate(this);
}

/**
* Returns a duplicate of this Extent.
*
* @return {Extent} A new Extent instance.
*/
Extent.prototype.clone = function() {
return new Extent(this.west, this.south, this.east, this.north);
};

/**
* Checks that an {@link Extent}'s members are in the proper ranges, north is greater than south and east is greater than west.
*
* @param {Extent} extent The extent to be checked for validity.
*
* @exception {DeveloperError} <code>extent</code> is required and must have north, south, east and west attributes.
* @exception {DeveloperError} <code>extent.north</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>].
* @exception {DeveloperError} <code>extent.south</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>].
* @exception {DeveloperError} <code>extent.east</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>].
* @exception {DeveloperError} <code>extent.west</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>].
*/
Extent.validate = function(extent) {
if (!extent ||
typeof extent.north === "undefined" ||
typeof extent.south === "undefined" ||
typeof extent.west === "undefined" ||
typeof extent.east === "undefined") {
throw new DeveloperError("extent is required and must have north, south, east and west attributes.", "extent");
}

if (extent.north < -CesiumMath.PI_OVER_TWO || extent.north > CesiumMath.PI_OVER_TWO) {
throw new DeveloperError("extent.north must be in the interval [-Pi/2, Pi/2].", "extent.north");
}

if (extent.south < -CesiumMath.PI_OVER_TWO || extent.south > CesiumMath.PI_OVER_TWO) {
throw new DeveloperError("extent.south must be in the interval [-Pi/2, Pi/2].", "extent.south");
}

if (extent.west < -CesiumMath.PI || extent.west > CesiumMath.PI) {
throw new DeveloperError("extent.west must be in the interval [-Pi, Pi].", "extent.west");
}

if (extent.east < -CesiumMath.PI || extent.east > CesiumMath.PI) {
throw new DeveloperError("extent.east must be in the interval [-Pi, Pi].", "extent.east");
}
};

function getPosition(lla, ellipsoid, time, projection) {
if (typeof time === 'undefined' || time === 0.0 || typeof projection === 'undefined') {
return ellipsoid.toCartesian(lla);
}

var twod = projection.project(lla);
twod = new Cartesian3(0.0, twod.x, twod.y);
return twod.lerp(ellipsoid.toCartesian(lla), time);
}

Extent._computePositions = function(extent, ellipsoid, time, projection) {
if (typeof extent === 'undefined') {
throw new DeveloperError("extent is required.", "extent");
}

Extent.validate(extent);

ellipsoid = ellipsoid || Ellipsoid.WGS84;
var positions = [];

var lla = new Cartographic3(extent.west, extent.north, 0.0);
positions.push(getPosition(lla, ellipsoid, time, projection));
lla.longitude = extent.east;
positions.push(getPosition(lla, ellipsoid, time, projection));
lla.latitude = extent.south;
positions.push(getPosition(lla, ellipsoid, time, projection));
lla.longitude = extent.west;
positions.push(getPosition(lla, ellipsoid, time, projection));

if (extent.north < 0.0) {
lla.latitude = extent.north;
} else if (extent.south > 0.0) {
lla.latitude = extent.south;
} else {
lla.latitude = 0.0;
}

for ( var i = 1; i < 8; ++i) {
var temp = -Math.PI + i * CesiumMath.PI_OVER_TWO;
if (extent.west < temp && temp < extent.east) {
lla.longitude = temp;
positions.push(getPosition(lla, ellipsoid, time, projection));
}
}

if (lla.latitude === 0.0) {
lla.longitude = extent.west;
positions.push(getPosition(lla, ellipsoid, time, projection));
lla.longitude = extent.east;
positions.push(getPosition(lla, ellipsoid, time, projection));
}

return positions;
};

/**
* DOC_TBA
*
* @param {Extent} extent DOC_TBA
* @param {Ellipsoid} ellipsoid DOC_TBA
* @param {Number} time DOC_TBA
* @param {Object} projection DOC_TBA
*
* @returns {BoundingSphere} DOC_TBA
*/
Extent.computeMorphBoundingSphere = function(extent, ellipsoid, time, projection) {
return new BoundingSphere(Extent._computePositions(extent, ellipsoid, time, projection));
};

/**
* DOC_TBA
*
* @param {Extent} extent DOC_TBA
* @param {Ellipsoid} ellipsoid DOC_TBA
* @returns {BoundingSphere} DOC_TBA
*/
Extent.compute3DBoundingSphere = function(extent, ellipsoid) {
return new BoundingSphere(Extent._computePositions(extent, ellipsoid));
};

/**
* DOC_TBA
*
* @param {Extent} extent DOC_TBA
* @param {Ellipsoid} ellipsoid DOC_TBA
*
* @returns {Object} DOC_TBA
*/
Extent.computeOccludeePoint = function(extent, ellipsoid) {
ellipsoid = ellipsoid || Ellipsoid.WGS84;
var positions = Extent._computePositions(extent, ellipsoid);
var bs = new BoundingSphere(positions);

// TODO: get correct ellipsoid center
var ellipsoidCenter = Cartesian3.ZERO;
if (!ellipsoidCenter.equals(bs.center)) {
return Occluder.getOccludeePoint(new BoundingSphere(ellipsoidCenter, ellipsoid.getMinimumRadius()), bs.center, positions);
}
return {
valid : false
};
};

/**
* DOC_TBA
*
* @param {Extent} extent DOC_TBA
* @param {Object} projection DOC_TBA
* @returns {Rectangle} DOC_TBA
*/
Extent.computeBoundingRectangle = function(extent, projection) {
if (typeof extent === 'undefined') {
throw new DeveloperError("extent is required.", "extent");
}

Extent.validate(extent);

if (typeof projection === 'undefined') {
throw new DeveloperError("projection is required.", "projection");
}

var lla = new Cartographic2(extent.west, extent.south);
var lowerLeft = projection.project(lla);
lla.longitude = extent.east;
lla.latitude = extent.north;
var upperRight = projection.project(lla);

var diagonal = upperRight.subtract(lowerLeft);
return new Rectangle(lowerLeft.x, lowerLeft.y, diagonal.x, diagonal.y);
};

/**
* DOC_TBA
*
* @param {Extent} extent DOC_TBA
* @param {Object} projection DOC_TBA
* @returns {BoundingSphere} DOC_TBA
*/
Extent.compute2DBoundingSphere = function(extent, projection) {
var rect = Extent.computeBoundingRectangle(extent, projection);
var center = new Cartesian3((2.0 * rect.x + rect.width) * 0.5, (2.0 * rect.y + rect.height) * 0.5, 0.0);
var radius = Math.sqrt(rect.width * rect.width + rect.height * rect.height) * 0.5;
return new BoundingSphere(center, radius);
};

return Extent;
});
Loading