AGI Components with Insight3D Alpha 2008 r8
Display Conditions

Display conditions are used to limit when a primitive or globe inlay is rendered. This can be based on the distance from the viewer to the primitive, the distance from the viewer to a point, the viewer's altitude, pixel size, or the current time. 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 ORed together.

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 overview.

Five fine grain conditions are available.

  • Distance from viewer to primitive (AgGxDisplayConditionDistance). The primitive is rendered if the distance is within [Minimum Distance, Maximum Distance], which is defined by the user.

  • Distance from viewer to point (AgGxDisplayConditionDistanceToPoint). This allows multiple primitives to show/hide based on the viewer's distance from a point. For example, a filled country and surrounding wall may have different center positions, so the distance to primitive condition would result in each primitive turning on/off at a different viewer position.

  • Viewer Altitude (AgGxDisplayConditionAltitude). The primitive is rendered if the viewer's altitude on the primitive's central body is within [Minimum Altitude, Maximum Altitude].

  • Pixel Size (AgGxDisplayConditionPixelSize). The primitive is rendered if its bounding sphere's diameter, projected onto the screen, is within [Minimum Pixel Size, Maximum Pixel Size].

    To improve performance, this can be used to implement a level of detail algorithm that take 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 when it only occupies few pixels.
  • Time Interval (AgGxDisplayConditionTimeInterval). The primitive is rendered if the current time is within [Minimum Time, Maximum Time].

A display condition is applied to a primitive as shown in the following code example:

CopyC#
IAgGxDisplayConditionAltitude condition = new AgGxDisplayConditionAltitude();
condition.Initialize(0, 1000);  // Minimum Altitude, Maximum Altitude, in meters
primitive.DisplayCondition = condition;

When a primitive's DisplayCondition property is not null, the condition is evaluated before the primitive is rendered. The primitive is rendered only if the condition is met. In this case, the primitive will only be rendered if the viewer's altitude is within [0, 1000] meters.

The same display condition object can be assigned to multiple primitives.

Display Condition: Composite

These fine grain conditions can be combined with Boolean logic using composites, AgGxDisplayConditionComposite. Hierarchies of composites can represent expressions with parentheses, but 9 times out of 10, a simple AND or OR 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.

CopyC#
IAgGxDisplayConditionComposite composite = new AgGxDisplayConditionComposite();
IAgGxDisplayConditionTimeInterval t0 = new AgGxDisplayConditionTimeInterval();
IAgGxDisplayConditionTimeInterval t1 = new AgGxDisplayConditionTimeInterval();

t0.Initialize(0, 60);
t1.Initialize(180, 240);

composite.LogicOperation = AgGxBinaryLogicOperation.BinaryLogicOperationOR;
composite.Add(t0, false);
composite.Add(t1, false);

primitive.DisplayCondition = composite as IAgGxDisplayCondition;

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 composite of primitives and assign the composite condition to the composite primitive.