Description
A triangle mesh primitive for meshes on the
surface that need to conform to terrain.
Object Model
Public Methods
Public Properties
RenderingMethod |
Gets the rendering method
used to render the mesh. |
SetHint |
Gets the primitive's
Set
Hint. See the Set Hint
Performance Overview for selecting an appropriate value to
construct the primitive with. |
Texture |
Gets or sets the texture
applied to this primitive when rendering. |
TextureFilter |
Gets or sets the filter
used when a Texture
is applied to this primitive. |
TextureMatrix |
Gets or sets the matrix
used to transform texture coordinates when a Texture
is applied to this primitive. |
TransparentTextureBorder |
Gets or set the boolean
that defines if the color obtained from texture coordinates beyond
the texture border should be considered transparent or not. This is
typically used in conjunction with the a Texture
Matrix. |
TriangleWindingOrder |
Gets the orientation of
front-facing triangles in the mesh. |
Wireframe |
Gets or sets whether the
primitive is rendered in wireframe. This is useful for
debugging. |
Example
Draw a filled STK
area target on terrain
[C#] |
Copy Code
|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgStkGraphicsTerrainOverlay overlay = scene.CentralBodies.Earth.Terrain.AddUriString(
terrainFile);
IAgStkGraphicsSurfaceTriangulatorResult triangles =
manager.Initializers.SurfacePolygonTriangulator.Compute("Earth", ref positions);
IAgStkGraphicsSurfaceMeshPrimitive mesh = manager.Initializers.SurfaceMeshPrimitive.Initialize();
((IAgStkGraphicsPrimitive)mesh).Color = Color.Purple;
mesh.Set(triangles);
manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);
|
|
Draw a filled,
dynamically textured extent on terrain
[C#] |
Copy Code
|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgStkGraphicsProjectionRasterStreamPluginActivator activator =
manager.Initializers.ProjectionRasterStreamPluginActivator.Initialize();
IAgStkGraphicsProjectionRasterStreamPluginProxy proxy =
activator.CreateFromDisplayName("ProjectionRasterStreamPlugin.CSharp");
Type plugin = proxy.RealPluginObject.GetType();
plugin.GetProperty("RasterPath").SetValue(proxy.RealPluginObject, rasterFile, null);
IAgStkGraphicsRasterStream rasterStream = proxy.RasterStream;
rasterStream.UpdateDelta = 0.025;
IAgStkGraphicsRendererTexture2D texture = manager.Textures.FromRaster((IAgStkGraphicsRaster)rasterStream);
Array extent = ((IAgStkGraphicsGlobeOverlay)overlay).Extent;
IAgStkGraphicsSurfaceTriangulatorResult triangles = manager.Initializers.SurfaceExtentTriangulator.ComputeSimple("Earth", ref extent);
IAgStkGraphicsSurfaceMeshPrimitive mesh = manager.Initializers.SurfaceMeshPrimitive.Initialize();
((IAgStkGraphicsPrimitive)mesh).Translucency = 0.2f;
mesh.Texture = texture;
mesh.Set(triangles);
manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);
|
|
Draw a filled,
textured extent on terrain
[C#] |
Copy Code
|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
Array overlayExtent = ((IAgStkGraphicsGlobeOverlay)overlay).Extent;
IAgStkGraphicsSurfaceTriangulatorResult triangles =
manager.Initializers.SurfaceExtentTriangulator.ComputeSimple("Earth", ref overlayExtent);
IAgStkGraphicsRendererTexture2D texture = manager.Textures.LoadFromStringUri(
textureFile);
IAgStkGraphicsSurfaceMeshPrimitive mesh = manager.Initializers.SurfaceMeshPrimitive.Initialize();
((IAgStkGraphicsPrimitive)mesh).Translucency = 0.3f;
mesh.Texture = texture;
mesh.Set(triangles);
manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);
|
|
Draw a moving water
texture using affine transformations
[C#] |
Copy Code
|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
Array cartographicExtent = new object[]
{
-96,
22,
-85,
28
};
IAgStkGraphicsSurfaceTriangulatorResult triangles =
manager.Initializers.SurfaceExtentTriangulator.ComputeSimple("Earth", ref cartographicExtent);
IAgStkGraphicsRendererTexture2D texture = manager.Textures.LoadFromStringUri(
textureFile);
IAgStkGraphicsSurfaceMeshPrimitive mesh = manager.Initializers.SurfaceMeshPrimitive.Initialize();
((IAgStkGraphicsPrimitive)mesh).Translucency = 0.3f;
mesh.Texture = texture;
mesh.TextureFilter = manager.Initializers.TextureFilter2D.LinearRepeat;
mesh.Set(triangles);
manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);
internal void TimeChanged(IAgStkGraphicsScene scene, AgStkObjectRoot root, double TimeEpSec)
{
if (m_Primitive != null)
{
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
m_Translation = (float)TimeEpSec;
m_Translation /= 1000;
Matrix transformation = new Matrix();
transformation.Translate(-m_Translation, 0);
Array transformationArray = Array.CreateInstance(typeof(object), transformation.Elements.Length);
for (int i = 0; i < transformationArray.Length; ++i)
{
transformationArray.SetValue((object)transformation.Elements.GetValue(i), i);
}
((IAgStkGraphicsSurfaceMeshPrimitive)m_Primitive).TextureMatrix =
manager.Initializers.TextureMatrix.InitializeWithAffineTransform(ref transformationArray);
}
}
|
|
Draw a filled STK
area target on the globe
[C#] |
Copy Code
|
IAgStkGraphicsSceneManager manager = ((IAgScenario)root.CurrentScenario).SceneManager;
IAgStkGraphicsRendererTexture2D texture = manager.Textures.LoadFromStringUri(
textureFile);
IAgStkGraphicsSurfaceMeshPrimitive mesh = manager.Initializers.SurfaceMeshPrimitive.Initialize();
mesh.Texture = texture;
Array cartographicExtent = new object[]
{
-0.386182,
42.929871,
-0.333891,
42.973438
};
IAgStkGraphicsSurfaceTriangulatorResult triangles = manager.Initializers.SurfaceExtentTriangulator.ComputeSimple("Earth", ref cartographicExtent);
mesh.Set(triangles);
((IAgStkGraphicsPrimitive)mesh).Translucency = 0.0f;
Array c0 = new object[] { -0.386182, 42.938583 };
Array c1 = new object[] { -0.375100, 42.929871 };
Array c2 = new object[] { -0.333891, 42.944780 };
Array c3 = new object[] { -0.359980, 42.973438 };
mesh.TextureMatrix = manager.Initializers.TextureMatrix.InitializeWithRectangles(
ref c0, ref c1, ref c2, ref c3);
mesh.TransparentTextureBorder = true;
manager.Primitives.Add((IAgStkGraphicsPrimitive)mesh);
|
|
Draw a filled STK
area target on terrain
[Visual Basic .NET] |
Copy Code
|
Dim manager As
IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario,
IAgScenario).SceneManager
Dim overlay As IAgStkGraphicsTerrainOverlay =
scene.CentralBodies.Earth.Terrain.AddUriString( _
terrainFile)
Dim triangles As IAgStkGraphicsSurfaceTriangulatorResult =
manager.Initializers.SurfacePolygonTriangulator.Compute("Earth",
positions)
Dim mesh As IAgStkGraphicsSurfaceMeshPrimitive =
manager.Initializers.SurfaceMeshPrimitive.Initialize()
DirectCast(mesh, IAgStkGraphicsPrimitive).Color = Color.Purple
mesh.Set(triangles)
manager.Primitives.Add(DirectCast(mesh,
IAgStkGraphicsPrimitive))
|
|
Draw a filled,
dynamically textured extent on terrain
[Visual Basic .NET] |
Copy Code
|
Dim manager As
IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario,
IAgScenario).SceneManager
Dim activator As
IAgStkGraphicsProjectionRasterStreamPluginActivator =
manager.Initializers.ProjectionRasterStreamPluginActivator.Initialize()
Dim proxy As IAgStkGraphicsProjectionRasterStreamPluginProxy
= activator.CreateFromDisplayName("ProjectionRasterStreamPlugin.VBNET")
Dim plugin As Type =
proxy.RealPluginObject.[GetType]()
plugin.GetProperty("RasterPath").SetValue(proxy.RealPluginObject,
rasterFile, Nothing)
Dim rasterStream As IAgStkGraphicsRasterStream =
proxy.RasterStream
rasterStream.UpdateDelta = 0.025
Dim texture As IAgStkGraphicsRendererTexture2D =
manager.Textures.FromRaster(DirectCast(rasterStream,
IAgStkGraphicsRaster))
Dim extent As Array =
DirectCast(overlay, IAgStkGraphicsGlobeOverlay).Extent
Dim triangles As IAgStkGraphicsSurfaceTriangulatorResult =
manager.Initializers.SurfaceExtentTriangulator.ComputeSimple("Earth",
extent)
Dim mesh As IAgStkGraphicsSurfaceMeshPrimitive =
manager.Initializers.SurfaceMeshPrimitive.Initialize()
DirectCast(mesh, IAgStkGraphicsPrimitive).Translucency = 0.2F
mesh.Texture = texture
mesh.Set(triangles)
manager.Primitives.Add(DirectCast(mesh,
IAgStkGraphicsPrimitive))
|
|
Draw a filled,
textured extent on terrain
[Visual Basic .NET] |
Copy Code
|
Dim manager As
IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario,
IAgScenario).SceneManager
Dim overlayExtent As Array =
DirectCast(overlay, IAgStkGraphicsGlobeOverlay).Extent
Dim triangles As IAgStkGraphicsSurfaceTriangulatorResult =
manager.Initializers.SurfaceExtentTriangulator.ComputeSimple("Earth",
overlayExtent)
Dim texture As IAgStkGraphicsRendererTexture2D =
manager.Textures.LoadFromStringUri( _
textureFile)
Dim mesh As IAgStkGraphicsSurfaceMeshPrimitive =
manager.Initializers.SurfaceMeshPrimitive.Initialize()
DirectCast(mesh, IAgStkGraphicsPrimitive).Translucency = 0.3F
mesh.Texture = texture
mesh.Set(triangles)
manager.Primitives.Add(DirectCast(mesh,
IAgStkGraphicsPrimitive))
|
|
Draw a moving water
texture using affine transformations
[Visual Basic .NET] |
Copy Code
|
Dim manager As
IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario,
IAgScenario).SceneManager
Dim cartographicExtent As Array =
New Object() {-96, 22, -85, 28}
Dim triangles As IAgStkGraphicsSurfaceTriangulatorResult =
manager.Initializers.SurfaceExtentTriangulator.ComputeSimple("Earth",
cartographicExtent)
Dim texture As IAgStkGraphicsRendererTexture2D =
manager.Textures.LoadFromStringUri( _
textureFile)
Dim mesh As IAgStkGraphicsSurfaceMeshPrimitive =
manager.Initializers.SurfaceMeshPrimitive.Initialize()
DirectCast(mesh, IAgStkGraphicsPrimitive).Translucency = 0.3F
mesh.Texture = texture
mesh.TextureFilter =
manager.Initializers.TextureFilter2D.LinearRepeat
mesh.Set(triangles)
manager.Primitives.Add(DirectCast(mesh,
IAgStkGraphicsPrimitive))
Friend Sub TimeChanged(scene As IAgStkGraphicsScene, root As AgStkObjectRoot, TimeEpSec As Double)
If m_Primitive
IsNot Nothing Then
Dim manager As
IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario,
IAgScenario).SceneManager
m_Translation =
CSng(TimeEpSec)
m_Translation /=
1000
Dim transformation As
New Matrix()
transformation.Translate(-m_Translation,
0)
Dim transformationArray As Array =
Array.CreateInstance(GetType(Object), transformation.Elements.Length)
For i As Integer = 0 To
transformationArray.Length - 1
transformationArray.SetValue(DirectCast(transformation.Elements.GetValue(i),
Object), i)
Next
DirectCast(m_Primitive,
IAgStkGraphicsSurfaceMeshPrimitive).TextureMatrix =
manager.Initializers.TextureMatrix.InitializeWithAffineTransform(transformationArray)
End
If
End Sub
|
|
Draw a filled STK
area target on the globe
[Visual Basic .NET] |
Copy Code
|
Dim manager As
IAgStkGraphicsSceneManager = DirectCast(root.CurrentScenario,
IAgScenario).SceneManager
Dim texture As IAgStkGraphicsRendererTexture2D =
manager.Textures.LoadFromStringUri( _
textureFile)
Dim mesh As IAgStkGraphicsSurfaceMeshPrimitive =
manager.Initializers.SurfaceMeshPrimitive.Initialize()
mesh.Texture = texture
Dim cartographicExtent As Array =
New Object() {-0.386182, 42.929871, -0.333891,
42.973438}
Dim triangles As IAgStkGraphicsSurfaceTriangulatorResult =
manager.Initializers.SurfaceExtentTriangulator.ComputeSimple("Earth",
cartographicExtent)
mesh.Set(triangles)
DirectCast(mesh, IAgStkGraphicsPrimitive).Translucency = 0.0F
Dim c0 As
Array = New Object()
{-0.386182, 42.938583}
Dim c1 As
Array = New Object()
{-0.3751, 42.929871}
Dim c2 As
Array = New Object()
{-0.333891, 42.94478}
Dim c3 As
Array = New Object()
{-0.35998, 42.973438}
mesh.TextureMatrix =
manager.Initializers.TextureMatrix.InitializeWithRectangles(c0, c1,
c2, c3)
mesh.TransparentTextureBorder = True
manager.Primitives.Add(DirectCast(mesh,
IAgStkGraphicsPrimitive))
|
|
Draw a new
Surface Mesh
[MATLAB] |
Copy Code
|
% IAgScenario scenario: Scenario object
manager = scenario.SceneManager;
cartesianPts = {6030.721052;1956.627139;-692.397578;
5568.375825;2993.600713;-841.076362;
5680.743568;2490.379622;-1480.882721}; % X,Y,Z (km)
triangles = manager.Initializers.SurfacePolygonTriangulator.Compute('Earth',cartesianPts);
surfaceMesh = manager.Initializers.SurfaceMeshPrimitive.Initialize();
surfaceMesh.Color = 255; % red
surfaceMesh.Set(triangles);
manager.Primitives.Add(surfaceMesh);
manager.Render;
|
|
See Also
CoClasses that Implement
IAgStkGraphicsSurfaceMeshPrimitive