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 customRenderablethat 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 classCube.AppFrameprotected classCube.OrderedCubeThis 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.OrderedCubecurrentFramesOrderedCubeprotected longframeTimestampprotected PickSupportpickSupportSupport object to help with pick resolution.protected PositionpositionGeographic position of the cube.protected doublesizeLength of each face, in meters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbeginDrawing(DrawContext dc)Setup drawing state in preparation for drawing the cube.protected voiddrawOrderedRenderable(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 voiddrawUnitCube(DrawContext dc)Draw a unit cube, using the active modelview matrix to orient the shape.protected voidendDrawing(DrawContext dc)Restore drawing state changed in beginDrawing to the default.protected booleanintersectsFrustum(DrawContext dc, Cube.OrderedCube orderedCube)Determines whether the cube intersects the view frustum.static voidmain(java.lang.String[] args)protected Cube.OrderedCubemakeOrderedRenderable(DrawContext dc)Compute per-frame attributes, and add the ordered renderable to the ordered renderable list.voidrender(DrawContext dc)Causes thisRenderableto 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:RenderableCauses thisRenderableto render itself using the provided draw context.- Specified by:
renderin interfaceRenderable- Parameters:
dc- theDrawContextto 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)
-
-