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
or-ed 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 that they are quickly rejected. See the composite primitive overview.
Several fine grain conditions are available, including:
- Distance from camera to object (DistanceDisplayCondition).
The object is rendered if the distance is within [Minimum Distance,
Maximum Distance].
- Distance from camera to position (DistanceToPositionDisplayCondition).
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.
- Camera Altitude (AltitudeDisplayCondition).
The object is rendered if the camera's altitude on the given
central body is within [Minimum Altitude, Maximum Altitude].
- Pixel Size (PixelSizeDisplayCondition).
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].
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 when it only occupies few
pixels.
- Time Interval (TimeIntervalDisplayCondition).
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:
[C#] |
Copy Code
|
IAgStkGraphicsSceneManager
manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgStkGraphicsAltitudeDisplayCondition condition =
manager.Initializers.AltitudeDisplayCondition.InitializeWithAltitudes(0,
1000); // Minimum Altitude, Maximum Altitude
primitive.DisplayCondition = condition as
IAgStkGraphicsDisplayCondition;
|
|
When an object's DisplayCondition property is
not null, the condition is evaluated before the object is rendered.
The object is rendered only if the condition is met. In this case,
the primitive will only be rendered if the camera's altitude is
within [0, 1000] meters from the Earth's surface.
The same display condition instance can be assigned to multiple
objects.
Display Condition: Composite
Display conditions can be combined with Boolean logic using
composites,
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.
[C#] |
Copy Code
|
IAgStkGraphicsSceneManager
manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgDate start1 = root.ConversionUtility.NewDate("UTCG", "30 May
2008 14:00:00.000");
IAgDate end1 = root.ConversionUtility.NewDate("UTCG", "30 May 2008
14:30:00.000");
IAgDate start2 = root.ConversionUtility.NewDate("UTCG", "30 May
2008 15:00:00.000");
IAgDate end2 = root.ConversionUtility.NewDate("UTCG", "30 May 2008
15:30:00.000");
IAgStkGraphicsTimeIntervalDisplayCondition time1 =
manager.Initializers.TimeIntervalDisplayCondition.InitializeWithTimes(start1,
end1);
IAgStkGraphicsTimeIntervalDisplayCondition time2 =
manager.Initializers.TimeIntervalDisplayCondition.InitializeWithTimes(start2,
end2);
IAgStkGraphicsCompositeDisplayCondition composite =
manager.Initializers.CompositeDisplayCondition.Initialize();
composite.Add((IAgStkGraphicsDisplayCondition)time1);
composite.Add((IAgStkGraphicsDisplayCondition)time2);
composite.LogicOperation =
AgEStkGraphicsBinaryLogicOperation.eStkGraphicsBinaryLogicOperationOr;
primitive.DisplayCondition = composite as
IAgStkGraphicsDisplayCondition;
|
|
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.
STK Programming Interface 11.0.1