NASA World Wind

gov.nasa.worldwindx.examples.tutorial
Class Cube

java.lang.Object
  extended by gov.nasa.worldwindx.examples.ApplicationTemplate
      extended by gov.nasa.worldwindx.examples.tutorial.Cube
All Implemented Interfaces:
OrderedRenderable, Renderable

public class Cube
extends ApplicationTemplate
implements OrderedRenderable

Example of a custom Renderable that draws a cube at a geographic position. This class shows the simplest possible example of a Renderable, while still following World Wind best practices.

What happens when the cube is rendered:

1) Scene controller calls render in picking mode. 2) Scene controller calls render in normal rendering mode. 3) Scene controller calls render in ordered rendering mode.


Nested Class Summary
protected static class Cube.AppFrame
           
 
Nested classes/interfaces inherited from class gov.nasa.worldwindx.examples.ApplicationTemplate
ApplicationTemplate.AppPanel
 
Field Summary
protected  Extent extent
           
protected  double eyeDistance
          Distance from the eye point to the cube.
protected  long frameTimestamp
           
protected  PickSupport pickSupport
          Support object to help with pick resolution.
protected  Vec4 placePoint
          Cartesian position of the cube, computed from position.
protected  Position position
          Geographic position of the cube.
protected  double size
          Length of each face, in meters.
 
Constructor Summary
Cube(Position position, double sizeInMeters)
           
 
Method Summary
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.
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.
 double getDistanceFromEye()
          Returns the ordered renderable's distance from the current view's eye point.
protected  boolean intersectsFrustum(DrawContext dc)
          Determines whether the cube intersects the view frustum.
static void main(String[] args)
           
protected  void makeOrderedRenderable(DrawContext dc)
          Compute per-frame attributes, and add the ordered renderable to the ordered renderable list.
 void pick(DrawContext dc, Point pickPoint)
          Executes a pick of the ordered renderable.
 void render(DrawContext dc)
          Causes this Renderable to render itself using the provided draw context.
 
Methods inherited from class gov.nasa.worldwindx.examples.ApplicationTemplate
insertAfterPlacenames, insertBeforeCompass, insertBeforeLayerName, insertBeforePlacenames, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extent

protected Extent extent

eyeDistance

protected double eyeDistance
Distance from the eye point to the cube.


frameTimestamp

protected long frameTimestamp

pickSupport

protected PickSupport pickSupport
Support object to help with pick resolution.


placePoint

protected Vec4 placePoint
Cartesian position of the cube, computed from position.


position

protected Position position
Geographic position of the cube.


size

protected double size
Length of each face, in meters.

Constructor Detail

Cube

public Cube(Position position,
            double sizeInMeters)
Method Detail

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.

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.

drawUnitCube

protected void drawUnitCube(DrawContext dc)
Draw a unit cube, using the active modelview matrix to orient the shape.

Parameters:
dc - Current draw context.

endDrawing

protected void endDrawing(DrawContext dc)
Restore drawing state changed in beginDrawing to the default.

Parameters:
dc - Active draw context.

getDistanceFromEye

public double getDistanceFromEye()
Description copied from interface: OrderedRenderable
Returns the ordered renderable's distance from the current view's eye point. Intended to be used only to sort a list of ordered renderables according to eye distance, and only during frame generation when a view is active.

Specified by:
getDistanceFromEye in interface OrderedRenderable
Returns:
the distance of the ordered renderable from the current view's eye point.

intersectsFrustum

protected boolean intersectsFrustum(DrawContext dc)
Determines whether the cube intersects the view frustum.

Parameters:
dc - the current draw context.
Returns:
true if this cube intersects the frustum, otherwise false.

main

public static void main(String[] args)

makeOrderedRenderable

protected void makeOrderedRenderable(DrawContext dc)
Compute per-frame attributes, and add the ordered renderable to the ordered renderable list.

Parameters:
dc - Current draw context.

pick

public void pick(DrawContext dc,
                 Point pickPoint)
Description copied from interface: OrderedRenderable
Executes a pick of the ordered renderable.

Specified by:
pick in interface OrderedRenderable
Parameters:
dc - the current draw context.
pickPoint - the pick point.

render

public void render(DrawContext dc)
Description copied from interface: Renderable
Causes this Renderable to render itself using the provided draw context.

Specified by:
render in interface Renderable
Parameters:
dc - the DrawContext to be used
See Also:
DrawContext

NASA World Wind