STK Graphics PrimitivesSend comments on this topic.
IAgStkGraphicsTriangleMeshPrimitive Interface

Description

Renders a triangle mesh in the 3D scene. Examples of triangle meshes include polygons on the globe (e.g. states or countries), terrain and imagery extents, ellipses, and extrusions.

Public Methods

Public Method SetDefines the triangle mesh using an indexed triangle list specified by positions, normals, and indices. The mesh is rendered in the primitive's Reference Frame.
Public Method SetTriangulatorDefines the triangle mesh using the specified triangulator. The mesh is rendered in the primitive's Reference Frame.
Public Method SetWithOptionalParametersDefines the triangle mesh using an indexed triangle list specified by positions, normals, indices, and optionalParameters. The mesh is rendered in the primitive's Reference Frame.

Public Properties

Public Property CentralBodyClippedGets or sets whether individual points will be clipped by the central body.
Public Property CullFaceGets or sets whether front and/or back-facing triangles may be culled. This is used in combination with Triangle Winding Order for culling.
Public Property LightingGets or sets whether the primitive is lit.
Public Property RenderBackThenFrontFacesGets or sets whether the primitive is rendered in two passes to improve the visual quality for translucent, convex meshes.
Public Property SetHintGets the primitive's Set Hint. See the Set Hint Performance Overview for selecting an appropriate value to construct the primitive with.
Public Property ShadeModelGets or sets the shading model for the mesh.
Public Property TextureGets or sets the texture to be drawn on the triangle mesh. Textures can be obtained from SceneManager.Textures.
Public Property TextureFilterGets or sets the filter used for the Texture associated with this triangle mesh.
Public Property TriangleWindingOrderGets or sets the orientation of front-facing triangles. This is used in combination with Cull Face for culling.
Public Property TwoSidedLightingGets or sets whether the primitive's translucent geometry will be lit from both sides of the surface.
Public Property WireframeGets or sets whether the primitive is rendered in wireframe. This is useful for debugging.

Interfaces

Implemented Interface
IAgStkGraphicsPrimitive

CoClasses that Implement IAgStkGraphicsTriangleMeshPrimitive

Example

Draw a filled STK area target
[C#]
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;

IAgStkGraphicsSurfaceTriangulatorResult triangles =
    manager.Initializers.SurfacePolygonTriangulator.Compute("Earth", ref positions);

IAgStkGraphicsTriangleMeshPrimitive mesh = manager.Initializers.TriangleMeshPrimitive.Initialize();
mesh.SetTriangulator((IAgStkGraphicsTriangulatorResult)triangles);
((IAgStkGraphicsPrimitive)mesh).Color = Color.Red;
manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);
Draw a filled circle on the globe
[C#]
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
Array center = new object[] { 39.88, -75.25, 0.0 };

IAgStkGraphicsSurfaceShapesResult shape = manager.Initializers.SurfaceShapes.ComputeCircleCartographic("Earth", ref center, 10000);
Array positions = shape.Positions;
IAgStkGraphicsSurfaceTriangulatorResult triangles = manager.Initializers.SurfacePolygonTriangulator.Compute("Earth", ref positions);

IAgStkGraphicsTriangleMeshPrimitive mesh = manager.Initializers.TriangleMeshPrimitive.Initialize();
mesh.SetTriangulator((IAgStkGraphicsTriangulatorResult)triangles);
((IAgStkGraphicsPrimitive)mesh).Color = Color.White;
((IAgStkGraphicsPrimitive)mesh).Translucency = 0.5f;

manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);
Draw a filled ellipse on the globe
[C#]
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
Array center = new object[] { 38.85, -77.04, 3000.0 }; // Washington, DC

IAgStkGraphicsSurfaceShapesResult shape = manager.Initializers.SurfaceShapes.ComputeEllipseCartographic(
    "Earth", ref center, 45000, 30000, 45);
Array positions = shape.Positions;

IAgStkGraphicsSurfaceTriangulatorResult triangles = manager.Initializers.SurfacePolygonTriangulator.Compute(
    "Earth", ref positions);
IAgStkGraphicsTriangleMeshPrimitive mesh = manager.Initializers.TriangleMeshPrimitive.Initialize();
mesh.SetTriangulator((IAgStkGraphicsTriangulatorResult)triangles);
((IAgStkGraphicsPrimitive)mesh).Color = Color.Cyan;

manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);
Draw a filled rectangular extent on the globe
[C#]
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;

Array extent = new object[]
{
    -94, 29,
    -89, 33
};

IAgStkGraphicsSurfaceTriangulatorResult triangles = manager.Initializers.SurfaceExtentTriangulator.ComputeSimple(
        "Earth", ref extent);

IAgStkGraphicsTriangleMeshPrimitive mesh = manager.Initializers.TriangleMeshPrimitive.Initialize();
mesh.SetTriangulator((IAgStkGraphicsTriangulatorResult)triangles);
((IAgStkGraphicsPrimitive)mesh).Color = Color.Salmon;
mesh.Lighting = false;  /* Turn off lighting for the mesh so the color we assigned will always be consistent */ 

manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);
Draw an extrusion around a STK area target
[C#]
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;

IAgStkGraphicsExtrudedPolylineTriangulatorResult triangles =
    manager.Initializers.ExtrudedPolylineTriangulator.ComputeWithAltitudes(
    "Earth", ref positions, 10000, 25000);
IAgStkGraphicsTriangleMeshPrimitive mesh = manager.Initializers.TriangleMeshPrimitive.Initialize();
mesh.SetTriangulator((IAgStkGraphicsTriangulatorResult)triangles);
((IAgStkGraphicsPrimitive)mesh).Color = Color.Red;
((IAgStkGraphicsPrimitive)mesh).Translucency = 0.4f;

manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);
Draw a filled polygon with a hole on the globe
[C#]
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;

IAgStkGraphicsSurfaceTriangulatorResult triangles = manager.Initializers.SurfacePolygonTriangulator.ComputeWithHole(
    "Earth", ref positions, ref holePositions);

IAgStkGraphicsTriangleMeshPrimitive mesh = manager.Initializers.TriangleMeshPrimitive.Initialize();
mesh.SetTriangulator((IAgStkGraphicsTriangulatorResult)triangles);
((IAgStkGraphicsPrimitive)mesh).Color = Color.Gray;
((IAgStkGraphicsPrimitive)mesh).Translucency = 0.5f;
manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);

IAgStkGraphicsPolylinePrimitive boundaryLine = manager.Initializers.PolylinePrimitive.Initialize();
Array boundaryPositionsArray = triangles.BoundaryPositions;
boundaryLine.Set(ref boundaryPositionsArray);
((IAgStkGraphicsPrimitive)boundaryLine).Color = Color.Red;
boundaryLine.Width = 2;
manager.Primitives.Add((IAgStkGraphicsPrimitive)boundaryLine);

IAgStkGraphicsPolylinePrimitive holeLine = manager.Initializers.PolylinePrimitive.Initialize();
holeLine.Set(ref holePositions);
((IAgStkGraphicsPrimitive)holeLine).Color = Color.Red;
holeLine.Width = 2;
manager.Primitives.Add((IAgStkGraphicsPrimitive)holeLine);
Draw a filled STK area target
[Visual Basic .NET]
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager

Dim triangles As IAgStkGraphicsSurfaceTriangulatorResult = manager.Initializers.SurfacePolygonTriangulator.Compute("Earth", positions)

Dim mesh As IAgStkGraphicsTriangleMeshPrimitive = manager.Initializers.TriangleMeshPrimitive.Initialize()
mesh.SetTriangulator(DirectCast(triangles, IAgStkGraphicsTriangulatorResult))
DirectCast(mesh, IAgStkGraphicsPrimitive).Color = Color.Red
manager.Primitives.Add(DirectCast(mesh, IAgStkGraphicsPrimitive))

Draw a filled circle on the globe
[Visual Basic .NET]
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager
'$lat$new latitude$
'$lon$new longitude$
'$alt$new altitude$
Dim center As Array = New Object() {39.88, -75.25, 0.0}

'$planetName$Name of the planet to place primitive$
'$radius$The radius of the circle.$
Dim shape As IAgStkGraphicsSurfaceShapesResult = manager.Initializers.SurfaceShapes.ComputeCircleCartographic("Earth", center, 10000)
Dim positions As Array = shape.Positions
Dim triangles As IAgStkGraphicsSurfaceTriangulatorResult = manager.Initializers.SurfacePolygonTriangulator.Compute("Earth", positions)

Dim mesh As IAgStkGraphicsTriangleMeshPrimitive = manager.Initializers.TriangleMeshPrimitive.Initialize()
mesh.SetTriangulator(DirectCast(triangles, IAgStkGraphicsTriangulatorResult))
DirectCast(mesh, IAgStkGraphicsPrimitive).Color = Color.White
DirectCast(mesh, IAgStkGraphicsPrimitive).Translucency = 0.5F

manager.Primitives.Add(DirectCast(mesh, IAgStkGraphicsPrimitive))
Draw a filled ellipse on the globe
[Visual Basic .NET]
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager
Dim washingtonDC As Array = New Object() {38.85, -77.04, 3000.0}

Dim shape As IAgStkGraphicsSurfaceShapesResult = manager.Initializers.SurfaceShapes.ComputeEllipseCartographic("Earth", washingtonDC, 45000, 30000, 45)
Dim positions As Array = shape.Positions

Dim triangles As IAgStkGraphicsSurfaceTriangulatorResult = manager.Initializers.SurfacePolygonTriangulator.Compute("Earth", positions)
Dim mesh As IAgStkGraphicsTriangleMeshPrimitive = manager.Initializers.TriangleMeshPrimitive.Initialize()
mesh.SetTriangulator(DirectCast(triangles, IAgStkGraphicsTriangulatorResult))
DirectCast(mesh, IAgStkGraphicsPrimitive).Color = Color.Cyan

manager.Primitives.Add(DirectCast(mesh, IAgStkGraphicsPrimitive))
Draw a filled rectangular extent on the globe
[Visual Basic .NET]
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager

Dim extent As Array = New Object() {-94, 29, -89, 33}

Dim triangles As IAgStkGraphicsSurfaceTriangulatorResult = manager.Initializers.SurfaceExtentTriangulator.ComputeSimple("Earth", extent)

Dim mesh As IAgStkGraphicsTriangleMeshPrimitive = manager.Initializers.TriangleMeshPrimitive.Initialize()
mesh.SetTriangulator(DirectCast(triangles, IAgStkGraphicsTriangulatorResult))
DirectCast(mesh, IAgStkGraphicsPrimitive).Color = Color.Salmon
mesh.Lighting = False

manager.Primitives.Add(DirectCast(mesh, IAgStkGraphicsPrimitive))
Draw an extrusion around a STK area target
[Visual Basic .NET]
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager

Dim triangles As IAgStkGraphicsExtrudedPolylineTriangulatorResult = manager.Initializers.ExtrudedPolylineTriangulator.ComputeWithAltitudes("Earth", positions, 10000, 25000)
Dim mesh As IAgStkGraphicsTriangleMeshPrimitive = manager.Initializers.TriangleMeshPrimitive.Initialize()
mesh.SetTriangulator(DirectCast(triangles, IAgStkGraphicsTriangulatorResult))
DirectCast(mesh, IAgStkGraphicsPrimitive).Color = Color.Red
DirectCast(mesh, IAgStkGraphicsPrimitive).Translucency = 0.4F

manager.Primitives.Add(DirectCast(mesh, IAgStkGraphicsPrimitive))
Draw a filled polygon with a hole on the globe
[Visual Basic .NET]
Dim manager As IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario, IAgScenario).SceneManager

Dim triangles As IAgStkGraphicsSurfaceTriangulatorResult = manager.Initializers.SurfacePolygonTriangulator.ComputeWithHole("Earth", positions, holePositions)

Dim mesh As IAgStkGraphicsTriangleMeshPrimitive = manager.Initializers.TriangleMeshPrimitive.Initialize()
mesh.SetTriangulator(DirectCast(triangles, IAgStkGraphicsTriangulatorResult))
DirectCast(mesh, IAgStkGraphicsPrimitive).Color = Color.Gray
DirectCast(mesh, IAgStkGraphicsPrimitive).Translucency = 0.5F
manager.Primitives.Add(DirectCast(mesh, IAgStkGraphicsPrimitive))

Dim boundaryLine As IAgStkGraphicsPolylinePrimitive = manager.Initializers.PolylinePrimitive.Initialize()
Dim boundaryPositionsArray As Array = triangles.BoundaryPositions
boundaryLine.Set(boundaryPositionsArray)
DirectCast(boundaryLine, IAgStkGraphicsPrimitive).Color = Color.Red
boundaryLine.Width = 2
manager.Primitives.Add(DirectCast(boundaryLine, IAgStkGraphicsPrimitive))

Dim holeLine As IAgStkGraphicsPolylinePrimitive = manager.Initializers.PolylinePrimitive.Initialize()
holeLine.Set(holePositions)
DirectCast(holeLine, IAgStkGraphicsPrimitive).Color = Color.Red
holeLine.Width = 2
manager.Primitives.Add(DirectCast(holeLine, IAgStkGraphicsPrimitive))

See Also

© 2024 Analytical Graphics, Inc. All Rights Reserved.