AGI STK Graphics 11 Send comments on this topic.
IAgStkGraphicsCompositePrimitive Collection





Description

A primitive that is composed of multiple other primitives. Since composites can contain other composites, they are commonly used to build hierarchies of primitives to efficiently evaluate display conditions.

Primitives in a composite must have the same Reference Frame.

Public Methods

Public Method Add Adds a primitive to the composite.
Public Method Clear Removes all primitives from the composite.
Public Method Contains Determines whether the composite contains a primitive.
Public Method Remove Removes a primitive from the composite.

Public Properties

Public Property Count Gets the number of primitives in the composite.
Public Property TranslucentPrimitivesSortOrder Gets or sets the sort order for translucent primitives in this composite. This determines a trade-off between rendering speed and quality. It is only recommended to use PrimitivesSortOrderBackToFront when translucent primitives along the same line of sight cause blending artifacts.

Example

Create layers of primitives
[C#] Copy Code
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager; 
 
Random r = new Random(); 
const int modelCount = 25
 
Array positions = Array.CreateInstance(typeof(object), modelCount * 3); 
 
// 
// Create the models 
// 
IAgStkGraphicsCompositePrimitive models = manager.Initializers.CompositePrimitive.Initialize(); 
 
for (int i = 0; i < modelCount; ++i) 

    double latitude = 35 + 1.5 * r.NextDouble(); 
    double longitude = -(80 + 1.5 * r.NextDouble()); 
    double altitude = 0
    Array position = new object[3]{latitude, longitude, altitude}; 
 
    positions.SetValue(latitude, 3 * i); 
    positions.SetValue(longitude, (3 * i) + 1); 
    positions.SetValue(altitude, (3 * i) + 2); 
 
    IAgStkGraphicsModelPrimitive model = manager.Initializers.ModelPrimitive.InitializeWithStringUri(modelFile); 
    model.SetPositionCartographic("Earth"ref position); 
    model.Scale = Math.Pow(102); 
    models.Add((IAgStkGraphicsPrimitive)model); 

 
// 
// Create the markers 
// 
IAgStkGraphicsMarkerBatchPrimitive markers = manager.Initializers.MarkerBatchPrimitive.Initialize(); 
markers.RenderPass = AgEStkGraphicsMarkerBatchRenderPass.eStkGraphicsMarkerBatchRenderPassTranslucent; 
 
markers.Texture = manager.Textures.LoadFromStringUri(markerFile); 
markers.SetCartographic("Earth"ref positions); 
 
// 
// Create the points 
// 
IAgStkGraphicsPointBatchPrimitive points = manager.Initializers.PointBatchPrimitive.Initialize(); 
points.PixelSize = 5
Array colors = Array.CreateInstance(typeof(object), modelCount); 
for (int i = 0; i < colors.Length; i++) 
    colors.SetValue(Color.Orange.ToArgb(), i); 
points.SetCartographicWithColorsAndRenderPass("Earth"ref positions, ref colors, AgEStkGraphicsRenderPassHint.eStkGraphicsRenderPassHintOpaque); 
 
// 
// Set the display Conditions 
// 
IAgStkGraphicsAltitudeDisplayCondition near = manager.Initializers.AltitudeDisplayCondition.InitializeWithAltitudes(0500000); 
((IAgStkGraphicsPrimitive)models).DisplayCondition = (IAgStkGraphicsDisplayCondition)near; 
 
IAgStkGraphicsAltitudeDisplayCondition medium = manager.Initializers.AltitudeDisplayCondition.InitializeWithAltitudes(5000002000000); 
((IAgStkGraphicsPrimitive)markers).DisplayCondition = (IAgStkGraphicsDisplayCondition)medium; 
 
IAgStkGraphicsAltitudeDisplayCondition far = manager.Initializers.AltitudeDisplayCondition.InitializeWithAltitudes(20000004000000); 
((IAgStkGraphicsPrimitive)points).DisplayCondition = (IAgStkGraphicsDisplayCondition)far; 
 
manager.Primitives.Add((IAgStkGraphicsPrimitive)models); 
manager.Primitives.Add((IAgStkGraphicsPrimitive)markers); 
manager.Primitives.Add((IAgStkGraphicsPrimitive)points); 
 

Create layers of primitives
[Visual Basic .NET] Copy Code
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager

Dim r As New Random()
Dim holder As Integer = 25
Dim modelCount As Integer = 25

Dim positions As Array = Array.CreateInstance(GetType(Object), modelCount * 3)

'
' Create the models
'
Dim models As IAgStkGraphicsCompositePrimitive = manager.Initializers.CompositePrimitive.Initialize()

For i As Integer = 0 To modelCount - 1
    Dim latitude As Double = 35 + 1.5 * r.NextDouble()
    Dim longitude As Double = -(80 + 1.5 * r.NextDouble())
    Dim altitude As Double = 0
    Dim position As Array = New Object() {latitude, longitude, altitude}

    positions.SetValue(latitude, 3 * i)
    positions.SetValue(longitude, (3 * i) + 1)
    positions.SetValue(altitude, (3 * i) + 2)

    Dim model As IAgStkGraphicsModelPrimitive = manager.Initializers.ModelPrimitive.InitializeWithStringUri(modelFile)
    model.SetPositionCartographic("Earth", position)
    model.Scale = Math.Pow(10, 2)
    models.Add(model)
Next

'
' Create the markers
'
Dim markers As IAgStkGraphicsMarkerBatchPrimitive = manager.Initializers.MarkerBatchPrimitive.Initialize()
markers.RenderPass = AgEStkGraphicsMarkerBatchRenderPass.eStkGraphicsMarkerBatchRenderPassTranslucent

markers.Texture = manager.Textures.LoadFromStringUri(markerFile)
markers.SetCartographic("Earth", positions)

'
' Create the points
'
Dim points As IAgStkGraphicsPointBatchPrimitive = manager.Initializers.PointBatchPrimitive.Initialize()
points.PixelSize = 5
DirectCast(points, IAgStkGraphicsPrimitive).Color = Color.Orange
Dim colors As Array = Array.CreateInstance(GetType(Object), modelCount)
For i As Integer = 0 To colors.Length - 1
    colors.SetValue(Color.Orange.ToArgb(), i)
Next
points.SetCartographicWithColorsAndRenderPass("Earth", positions, colors, AgEStkGraphicsRenderPassHint.eStkGraphicsRenderPassHintOpaque)

'
' Set the display Conditions
'
Dim near As IAgStkGraphicsAltitudeDisplayCondition = manager.Initializers.AltitudeDisplayCondition.InitializeWithAltitudes(0, 500000)
DirectCast(models, IAgStkGraphicsPrimitive).DisplayCondition = DirectCast(near, IAgStkGraphicsDisplayCondition)

Dim medium As IAgStkGraphicsAltitudeDisplayCondition = manager.Initializers.AltitudeDisplayCondition.InitializeWithAltitudes(500000, 2000000)
DirectCast(markers, IAgStkGraphicsPrimitive).DisplayCondition = DirectCast(medium, IAgStkGraphicsDisplayCondition)

Dim far As IAgStkGraphicsAltitudeDisplayCondition = manager.Initializers.AltitudeDisplayCondition.InitializeWithAltitudes(2000000, 4000000)
DirectCast(points, IAgStkGraphicsPrimitive).DisplayCondition = DirectCast(far, IAgStkGraphicsDisplayCondition)

manager.Primitives.Add(DirectCast(models, IAgStkGraphicsPrimitive))
manager.Primitives.Add(DirectCast(markers, IAgStkGraphicsPrimitive))
manager.Primitives.Add(DirectCast(points, IAgStkGraphicsPrimitive))


See Also

CoClasses that Implement IAgStkGraphicsCompositePrimitive

© 2016 All Rights Reserved.

STK Programming Interface 11.0.1