Skip to content

Commit 1469d47

Browse files
zglueckDavid Collins
authored andcommitted
Add 3D capability to Ellipse shapes (#209)
* Add element buffer cache * Fix element buffer cache * Store element buffer in render resource cache * Refactor buffer retrieval from cache * Refactor buffer retrieval and reassembly * Rename assembly function * Rename variables * Simplify buffer retrieval logic * Switch to Range object for managing buffer indices * Add initial 3d capabilities * Add extrusion property and getter/setters * Add extrude vertex generation * Fix spelling of function assembleElementsToCache function * Add extruded sides * Add vertical lines * Fix rendering state issues with extrusion * Clean up naming * Update Ellipse tutorial for 3D ellipses * Remove extra lines * Fix bounding sector calculation for 3D ellipse * Change scratch variable names to match convention * Change scratch variable names to match convention * Change scratch variable names to match convention, see notes - Previous commit message did not include notes on the refactor to use a generic element buffer - The extruded elements are always computed and incorporated into an element buffer - The vertex array now uses a plain float array in order to provide indexed assignment * Cleanup of comments and spelling * Additional comments and cleanup * Refactor spine computation into a function * Add optional Range objects to BufferObject * Change interval count determination method name * Change interval property name * Remove unnecessary local variable assignment * Update property name formatting * Move spine radius initialization * Utilize simplified globe radius value * Refactor index offset to function and refine addVertex * Utilize static client vertex array * Update documentation * Initial addition of texture capability * Revert single vertex array and clean up formatting * Fix documentation
1 parent 120f46a commit 1469d47

File tree

4 files changed

+277
-126
lines changed

4 files changed

+277
-126
lines changed

worldwind-tutorials/src/main/assets/ellipse_tutorial.html

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ <h1>Ellipse Tutorial</h1>
2424
Demonstrates how to add an Ellipse to a RenderableLayer.
2525
</p>
2626
<p>
27-
This example renders four different ellipses on the globe.
27+
This example renders six different ellipses on the globe.
2828
<ul>
2929
<li>The Northwestern ellipse demonstrates the default styling and configuration.</li>
3030
<li>The Northeastern ellipse uses custom attributes.</li>
31-
<li>The Southwestern ellipse has a 45 degree heading.</li>
32-
<li>The Southeastern ellipse displays a circle.</li>
31+
<li>The Western ellipse has a 45 degree heading.</li>
32+
<li>The Eastern ellipse displays a circle.</li>
33+
<li>The Southwestern ellipse is at an altitude of 200km.</li>
34+
<li>The Southeastern ellipse is at an altitude of 200km, extrude, and custom attributes.</li>
3335
</ul>
3436
</p>
3537
<h2>Example</h2>
@@ -90,6 +92,20 @@ <h3>EllipseFragment.java</h3>
9092
ellipse.setFollowTerrain(true); // cause the ellipse geometry to follow the terrain surface
9193
tutorialLayer.addRenderable(ellipse);
9294

95+
// Create an ellipse with the default attributes, an altitude of 200 km, and a 500km major-radius and a 300km
96+
// minor-radius.
97+
ellipse = new Ellipse(new Position(25, -120, 200e3), 500000, 300000);
98+
tutorialLayer.addRenderable(ellipse);
99+
100+
// Create an ellipse with custom attributes that make the interior 50% transparent and an extruded outline with
101+
// vertical lines
102+
attrs = new ShapeAttributes();
103+
attrs.setInteriorColor(new Color(1, 1, 1, 0.5f)); // 50% transparent white
104+
attrs.setDrawVerticals(true);
105+
ellipse = new Ellipse(new Position(25, -100, 200e3), 500000, 300000, attrs);
106+
ellipse.setExtrude(true);
107+
tutorialLayer.addRenderable(ellipse);
108+
93109
return wwd;
94110
}
95111
}

worldwind-tutorials/src/main/java/gov/nasa/worldwindx/EllipseFragment.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ public WorldWindow createWorldWindow() {
6161
ellipse.setFollowTerrain(true); // cause the ellipse geometry to follow the terrain surface
6262
tutorialLayer.addRenderable(ellipse);
6363

64+
// Create an ellipse with the default attributes, an altitude of 200 km, and a 500km major-radius and a 300km
65+
// minor-radius.
66+
ellipse = new Ellipse(new Position(25, -120, 200e3), 500000, 300000);
67+
tutorialLayer.addRenderable(ellipse);
68+
69+
// Create an ellipse with custom attributes that make the interior 50% transparent and an extruded outline with
70+
// vertical lines
71+
attrs = new ShapeAttributes();
72+
attrs.setInteriorColor(new Color(1, 1, 1, 0.5f)); // 50% transparent white
73+
attrs.setDrawVerticals(true);
74+
ellipse = new Ellipse(new Position(25, -100, 200e3), 500000, 300000, attrs);
75+
ellipse.setExtrude(true);
76+
tutorialLayer.addRenderable(ellipse);
77+
6478
return wwd;
6579
}
6680
}

worldwind/src/main/java/gov/nasa/worldwind/render/BufferObject.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
package gov.nasa.worldwind.render;
77

88
import android.opengl.GLES20;
9+
import android.util.SparseArray;
910

1011
import java.nio.Buffer;
1112

1213
import gov.nasa.worldwind.draw.DrawContext;
14+
import gov.nasa.worldwind.geom.Range;
1315
import gov.nasa.worldwind.util.Logger;
1416

1517
public class BufferObject implements RenderResource {
@@ -24,6 +26,8 @@ public class BufferObject implements RenderResource {
2426

2527
protected Buffer buffer;
2628

29+
public SparseArray<Range> ranges = new SparseArray<>();
30+
2731
public BufferObject(int target, int size, Buffer buffer) {
2832
this.bufferTarget = target;
2933
this.bufferLength = (buffer != null) ? buffer.remaining() : 0;

0 commit comments

Comments
 (0)