Click or drag to resize

Display Conditions

Display conditions are used to limit when a primitive, globe overlay, or screen overlay is rendered. This can be based on the distance from the camera to an object, such as a primitive or globe overlay, the distance from the camera to a position, the camera's altitude, pixel size, the current time, or other conditions. These fine grain conditions can be combined using Boolean logic with a composite, that is, a condition of conditions. For example, several time intervals can be combined.

For efficient evaluation, primitives that share the same condition can be combined using a composite primitive. For example, 1,000 models with the same condition can be combined in a composite primitive so they are quickly rejected. See the Composite Primitive topic for more information.

Available Conditions

Several types of conditions are available, including:

  • DistanceDisplayCondition - visibility depending on the distance from camera to an object. The object is rendered if the distance is within [Minimum Distance, Maximum Distance].

    Distance Display Condition
  • DistanceToPositionDisplayCondition - visibility depending on the distance from camera to a position. This allows multiple objects to show/hide based on the camera's distance to a position. For example, a filled country and surrounding wall may have different center positions, so the distance condition would result in each object turning on/off at a different camera position.

    Distance To Point Display Condition
  • AltitudeDisplayCondition - visibility depending on camera altitude. The object is rendered if the camera's altitude on the given central body is within [Minimum Altitude, Maximum Altitude].

    Altitude Display Condition
  • PixelSizeDisplayCondition - visibility depending on pixel size. The object is rendered if its bounding sphere's diameter, projected onto the screen, (or in the case of screen overlays, the area of its bounding rectangle) is within [Minimum Pixel Size, Maximum Pixel Size].

    Pixel Size Display Condition

    To improve performance, this can be used to implement a level of detail algorithm that takes into account the field of view. Several primitives with varying degrees of detail (e.g. number of vertices) are created, each with a pixel size display condition. The most detailed primitive has a pixel interval with the highest pixel sizes. Less detailed primitives have display conditions with smaller pixel sizes. When the primitive occupies many pixels, a detailed primitive is rendered. When a primitive occupies few pixels, a less detailed primitive is rendered, since a user is unlikely to notice the difference between a high detail and low detail primitive in that case.

  • TimeIntervalDisplayCondition - visibility depending on time. The object is rendered if the current animation time is within [Minimum Time, Maximum Time].

A display condition is applied to an object as shown in the following code example:

Java
AltitudeDisplayCondition condition = new AltitudeDisplayCondition(0.0, 1000.0);  // Minimum Altitude, Maximum Altitude, in meters
primitive.setDisplayCondition(condition);

When an object has a non-null display condition property, the condition is evaluated before the object is rendered, and the object is rendered only if the condition is met. The same display condition instance can be assigned to multiple objects. In the above example, the primitive will only be rendered if the camera's altitude is within [0, 1000] meters from the Earth's surface.

Composite Display Condition

Display conditions can be combined with Boolean logic using CompositeDisplayCondition. Hierarchies of composites can represent expressions with parentheses, but 9 times out of 10, simple and / or combinations of conditions will do the trick.

The following example creates a composite of conditions that allows the primitive to be rendered during two time intervals.

Java
CompositeDisplayCondition composite = new CompositeDisplayCondition();
composite.setLogicOperation(BinaryLogicOperation.OR);
composite.add(new TimeIntervalDisplayCondition(getAnimation().getStartTime(), getAnimation().getStartTime().addSeconds(60.0)));
composite.add(new TimeIntervalDisplayCondition(getAnimation().getStartTime().addSeconds(180.0), getAnimation().getStartTime().addSeconds(240.0)));

primitive.setDisplayCondition(composite);

If a large number of conditions are added to a composite, the composite can become expensive to compute, especially if a large number of primitives have a reference to the same composite. In this case, it is recommended to put the primitives into a CompositePrimitive and assign the display condition to the composite primitive.