Class Cube
- java.lang.Object
-
- gov.nasa.worldwindx.examples.ApplicationTemplate
-
- gov.nasa.worldwindx.examples.tutorial.Cube
-
- All Implemented Interfaces:
Renderable
public class Cube extends ApplicationTemplate implements Renderable
Example of a customRenderable
that draws a cube at a geographic position. This class shows the simplest possible example of a custom Renderable, while still following WorldWind best practices. See https://worldwind.arc.nasa.gov/java/tutorials/build-a-custom-renderable/ for a complete description of this example.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Cube.AppFrame
protected class
Cube.OrderedCube
This class holds the Cube's Cartesian coordinates.-
Nested classes/interfaces inherited from class gov.nasa.worldwindx.examples.ApplicationTemplate
ApplicationTemplate.AppPanel
-
-
Field Summary
Fields Modifier and Type Field Description protected Cube.OrderedCube
currentFramesOrderedCube
protected long
frameTimestamp
protected PickSupport
pickSupport
Support object to help with pick resolution.protected Position
position
Geographic position of the cube.protected double
size
Length of each face, in meters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
beginDrawing(DrawContext dc)
Setup drawing state in preparation for drawing the cube.protected void
drawOrderedRenderable(DrawContext dc, PickSupport pickCandidates)
Set up drawing state, and draw the cube.This method is called when the cube is rendered in ordered rendering mode.protected void
drawUnitCube(DrawContext dc)
Draw a unit cube, using the active modelview matrix to orient the shape.protected void
endDrawing(DrawContext dc)
Restore drawing state changed in beginDrawing to the default.protected boolean
intersectsFrustum(DrawContext dc, Cube.OrderedCube orderedCube)
Determines whether the cube intersects the view frustum.static void
main(java.lang.String[] args)
protected Cube.OrderedCube
makeOrderedRenderable(DrawContext dc)
Compute per-frame attributes, and add the ordered renderable to the ordered renderable list.void
render(DrawContext dc)
Causes thisRenderable
to render itself using the provided draw context.-
Methods inherited from class gov.nasa.worldwindx.examples.ApplicationTemplate
insertAfterPlacenames, insertBeforeCompass, insertBeforeLayerName, insertBeforePlacenames, start
-
-
-
-
Field Detail
-
position
protected Position position
Geographic position of the cube.
-
size
protected double size
Length of each face, in meters.
-
pickSupport
protected PickSupport pickSupport
Support object to help with pick resolution.
-
frameTimestamp
protected long frameTimestamp
-
currentFramesOrderedCube
protected Cube.OrderedCube currentFramesOrderedCube
-
-
Constructor Detail
-
Cube
public Cube(Position position, double sizeInMeters)
-
-
Method Detail
-
render
public void render(DrawContext dc)
Description copied from interface:Renderable
Causes thisRenderable
to render itself using the provided draw context.- Specified by:
render
in interfaceRenderable
- Parameters:
dc
- theDrawContext
to be used- See Also:
DrawContext
-
intersectsFrustum
protected boolean intersectsFrustum(DrawContext dc, Cube.OrderedCube orderedCube)
Determines whether the cube intersects the view frustum.- Parameters:
dc
- the current draw context.orderedCube
- The cube to check.- Returns:
- true if this cube intersects the frustum, otherwise false.
-
makeOrderedRenderable
protected Cube.OrderedCube makeOrderedRenderable(DrawContext dc)
Compute per-frame attributes, and add the ordered renderable to the ordered renderable list.- Parameters:
dc
- Current draw context.- Returns:
- The resulting cube.
-
drawOrderedRenderable
protected void drawOrderedRenderable(DrawContext dc, PickSupport pickCandidates)
Set up drawing state, and draw the cube.This method is called when the cube is rendered in ordered rendering mode.- Parameters:
dc
- Current draw context.pickCandidates
- The pick candidates list.
-
beginDrawing
protected void beginDrawing(DrawContext dc)
Setup drawing state in preparation for drawing the cube. State changed by this method must be restored in endDrawing.- Parameters:
dc
- Active draw context.
-
endDrawing
protected void endDrawing(DrawContext dc)
Restore drawing state changed in beginDrawing to the default.- Parameters:
dc
- Active draw context.
-
drawUnitCube
protected void drawUnitCube(DrawContext dc)
Draw a unit cube, using the active modelview matrix to orient the shape.- Parameters:
dc
- Current draw context.
-
main
public static void main(java.lang.String[] args)
-
-