Skip to content

Commit

Permalink
Merge pull request #5021 from AnalyticalGraphicsInc/ortho-3d
Browse files Browse the repository at this point in the history
Orthographic projection in 3D and Columbus view
  • Loading branch information
lilleyse authored Mar 15, 2017
2 parents 6d23614 + 9182136 commit ed034db
Show file tree
Hide file tree
Showing 47 changed files with 2,241 additions and 488 deletions.
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/development/Shadows.html
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@
var frustumSize = 55.0;
var frustumNear = 1.0;
var frustumFar = 400.0;
var frustum = new Cesium.OrthographicFrustum();
var frustum = new Cesium.OrthographicOffCenterFrustum();
frustum.left = -frustumSize;
frustum.right = frustumSize;
frustum.bottom = -frustumSize;
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Change Log

### 1.32 - 2017-04-03

* Deprecated
* The `left`, `right`, `bottom`, and `top` properties of `OrthographicFrustum` are deprecated and will be removed in 1.33. Use `OrthographicOffCenterFrustum` instead.
* Added `Camera.flyTo` and `Camera.flyToBoundingSphere` options [#5070](https://github.com/AnalyticalGraphicsInc/cesium/pull/5070)
* `flyOverLongitude` to select one of two possible on Globe paths which camera should fly.
* `flyOverLongitudeWeight` to set a threshold: how many times the `flyOverLongitude` way can be than shortest path.
Expand All @@ -15,6 +17,7 @@ Change Log
* Fixed an issue with `PinBuilder` where inset images could have low-alpha fringes against an opaque background. [#5099](https://github.com/AnalyticalGraphicsInc/cesium/pull/5099)
* Fixed a bug in `ModelAnimationCache` causing different animations to reference the same animation. [#5064](https://github.com/AnalyticalGraphicsInc/cesium/pull/5064)
* Fixed a bug that caused an exception in `CesiumInspectorViewModel` when using the NW / NE / SW / SE / Parent buttons to navigate to a terrain tile that is not yet loaded.
* Added support for an orthographic projection in 3D and Columbus view. Set `projectionPicker` to `true` in the options when creating a `Viewer` to add a widget that will switch projections. [#5021](https://github.com/AnalyticalGraphicsInc/cesium/pull/5021)

### 1.31 - 2017-03-01

Expand Down
30 changes: 24 additions & 6 deletions Source/Core/HeightmapTessellator.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ define([
var elementMultiplier = defaultValue(structure.elementMultiplier, HeightmapTessellator.DEFAULT_STRUCTURE.elementMultiplier);
var isBigEndian = defaultValue(structure.isBigEndian, HeightmapTessellator.DEFAULT_STRUCTURE.isBigEndian);

var granularityX = Rectangle.computeWidth(nativeRectangle) / (width - 1);
var granularityY = Rectangle.computeHeight(nativeRectangle) / (height - 1);
var rectangleWidth = Rectangle.computeWidth(nativeRectangle);
var rectangleHeight = Rectangle.computeHeight(nativeRectangle);

var granularityX = rectangleWidth / (width - 1);
var granularityY = rectangleHeight / (height - 1);

var radiiSquared = ellipsoid.radiiSquared;
var radiiSquaredX = radiiSquared.x;
Expand Down Expand Up @@ -337,10 +340,29 @@ define([

heightSample = (heightSample * heightScale + heightOffset) * exaggeration;

var u = (longitude - geographicWest) / (geographicEast - geographicWest);
u = CesiumMath.clamp(u, 0.0, 1.0);
uvs[index] = new Cartesian2(u, v);

maximumHeight = Math.max(maximumHeight, heightSample);
minimumHeight = Math.min(minimumHeight, heightSample);

if (colIndex !== col || rowIndex !== row) {
var percentage = 0.00001;
if (colIndex < 0) {
longitude -= percentage * rectangleWidth;
} else {
longitude += percentage * rectangleWidth;
}
if (rowIndex < 0) {
latitude += percentage * rectangleHeight;
} else {
latitude -= percentage * rectangleHeight;
}

cosLatitude = cos(latitude);
nZ = sin(latitude);
kZ = radiiSquaredZ * nZ;
heightSample -= skirtHeight;
}

Expand All @@ -365,10 +387,6 @@ define([
positions[index] = position;
heights[index] = heightSample;

var u = (longitude - geographicWest) / (geographicEast - geographicWest);
u = CesiumMath.clamp(u, 0.0, 1.0);
uvs[index] = new Cartesian2(u, v);

if (includeWebMercatorT) {
webMercatorTs[index] = webMercatorT;
}
Expand Down
11 changes: 0 additions & 11 deletions Source/Renderer/AutomaticUniforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,17 +530,6 @@ define([
}
}),

/**
* @private
*/
czm_inverseProjectionOIT : new AutomaticUniform({
size : 1,
datatype : WebGLConstants.FLOAT_MAT4,
getValue : function(uniformState) {
return uniformState.inverseProjectionOIT;
}
}),

/**
* An automatic GLSL uniform representing a 4x4 projection transformation matrix with the far plane at infinity,
* that transforms eye coordinates to clip coordinates. Clip coordinates is the
Expand Down
36 changes: 9 additions & 27 deletions Source/Renderer/UniformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define([
'../Core/Matrix4',
'../Core/Simon1994PlanetaryPositions',
'../Core/Transforms',
'../Scene/OrthographicFrustum',
'../Scene/SceneMode'
], function(
BoundingRectangle,
Expand All @@ -28,6 +29,7 @@ define([
Matrix4,
Simon1994PlanetaryPositions,
Transforms,
OrthographicFrustum,
SceneMode) {
'use strict';

Expand Down Expand Up @@ -80,9 +82,6 @@ define([
this._inverseProjectionDirty = true;
this._inverseProjection = new Matrix4();

this._inverseProjectionOITDirty = true;
this._inverseProjectionOIT = new Matrix4();

this._modelViewDirty = true;
this._modelView = new Matrix4();

Expand Down Expand Up @@ -147,6 +146,7 @@ define([
this._frustum2DWidth = 0.0;
this._eyeHeight2D = new Cartesian2();
this._resolutionScale = 1.0;
this._orthographicIn3D = false;

this._fogDensity = undefined;

Expand Down Expand Up @@ -393,17 +393,6 @@ define([
}
},

/**
* @memberof UniformState.prototype
* @private
*/
inverseProjectionOIT : {
get : function() {
cleanInverseProjectionOIT(this);
return this._inverseProjectionOIT;
}
},

/**
* @memberof UniformState.prototype
* @type {Matrix4}
Expand Down Expand Up @@ -834,7 +823,6 @@ define([
Matrix4.clone(matrix, uniformState._projection);

uniformState._inverseProjectionDirty = true;
uniformState._inverseProjectionOITDirty = true;
uniformState._viewProjectionDirty = true;
uniformState._inverseViewProjectionDirty = true;
uniformState._modelViewProjectionDirty = true;
Expand Down Expand Up @@ -896,6 +884,8 @@ define([
this._entireFrustum.x = camera.frustum.near;
this._entireFrustum.y = camera.frustum.far;
this.updateFrustum(camera.frustum);

this._orthographicIn3D = this._mode !== SceneMode.SCENE2D && camera.frustum instanceof OrthographicFrustum;
};

/**
Expand All @@ -913,7 +903,7 @@ define([
this._currentFrustum.x = frustum.near;
this._currentFrustum.y = frustum.far;

if (!defined(frustum.top)) {
if (defined(frustum._offCenterFrustum)) {
frustum = frustum._offCenterFrustum;
}

Expand Down Expand Up @@ -987,18 +977,10 @@ define([
if (uniformState._inverseProjectionDirty) {
uniformState._inverseProjectionDirty = false;

Matrix4.inverse(uniformState._projection, uniformState._inverseProjection);
}
}

function cleanInverseProjectionOIT(uniformState) {
if (uniformState._inverseProjectionOITDirty) {
uniformState._inverseProjectionOITDirty = false;

if (uniformState._mode !== SceneMode.SCENE2D && uniformState._mode !== SceneMode.MORPHING) {
Matrix4.inverse(uniformState._projection, uniformState._inverseProjectionOIT);
if (uniformState._mode !== SceneMode.SCENE2D && uniformState._mode !== SceneMode.MORPHING && !uniformState._orthographicIn3D) {
Matrix4.inverse(uniformState._projection, uniformState._inverseProjection);
} else {
Matrix4.clone(Matrix4.IDENTITY, uniformState._inverseProjectionOIT);
Matrix4.clone(Matrix4.ZERO, uniformState._inverseProjection);
}
}
}
Expand Down
Loading

0 comments on commit ed034db

Please sign in to comment.