Solid Primitive |
SolidPrimitive is used to visualize solids, such as boxes, ellipsoids, and cylinders, computed using a triangulator. The solid primitive can display the interior fill, the outline with various appearances, and the silhouette.
BoxTriangulator computes a SolidTriangulatorResult for a box centered at the origin. This result can be provided to the SolidPrimitiveSet method to visualize the interior fill and outline of the box. Since the box is centered at the origin and axis aligned, it should be positioned and oriented using the primitive's ReferenceFrame. The following example uses a solid primitive to visualize a box. AxesEastNorthUp is used to create a ReferenceFrame for the primitive.
EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth; Cartographic position = new Cartographic(Trig.DegreesToRadians(-80.577778), Trig.DegreesToRadians(28.488889), 1000); PointCartographic origin = new PointCartographic(earth, position); AxesEastNorthUp axes = new AxesEastNorthUp(earth, origin); ReferenceFrame referenceFrame = new ReferenceFrame(origin, axes); SolidTriangulatorResult result = BoxTriangulator.Compute(new Cartesian(1000, 1000, 2000)); SolidPrimitive solid = new SolidPrimitive { ReferenceFrame = referenceFrame }; solid.Set(result); SceneManager.Primitives.Add(solid); SceneManager.Render();
EllipsoidTriangulator computes a SolidTriangulatorResult for an ellipsoid centered at the origin. Its use is similar to the box triangulator, although the Cartesian passed to the Compute method defines the ellipsoid's X, Y, and Z radii in meters, as opposed to the box's X, Y, and Z length. The following example uses a solid primitive to visualize an ellipsoid. Note that the code is nearly identical to the box example.
EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth; Cartographic position = new Cartographic(Trig.DegreesToRadians(-80.577778), Trig.DegreesToRadians(28.488889), 4000); PointCartographic origin = new PointCartographic(earth, position); AxesEastNorthUp axes = new AxesEastNorthUp(earth, origin); ReferenceFrame referenceFrame = new ReferenceFrame(origin, axes); SolidTriangulatorResult result = EllipsoidTriangulator.Compute(new Cartesian(2000, 1000, 1000)); SolidPrimitive solid = new SolidPrimitive { ReferenceFrame = referenceFrame }; solid.Set(result); SceneManager.Primitives.Add(solid); SceneManager.Render();
For more fine grain control over the shape of the ellipsoid, use the Compute method that takes a number of slices around the z axis and number of stacks along the z axis. As shown below, more slices and stack provide a more precise ellipsoid, but use more memory.
CylinderTriangulator computes a SolidTriangulatorResult for a cylinder centered at the origin. The simplest Compute method overload takes two arguments: the length of the cylinder along the z axis and the cylinder's radius, both in meters. An additional method overload takes different radii for the bottom and top caps, the number of slices around the z axis, and if the cylinder includes a bottom cap, top cap, and/or wall. This allows creation of a wide range of shapes, as shown below:
The cylinder for the leftmost image is created with the following code:
SolidTriangulatorResult result = CylinderTriangulator.Compute(4000, 1500, 1500, 180, CylinderFill.All);
By default, a solid's interior fill and outline are displayed. The fill can be customized using DisplayFill, Color, Translucency, and AffectedByLighting. The outline can be customized with DisplayOutline, OutlineColor, OutlineTranslucency, and OutlineWidth. The following images show three possible combinations of interior fill and outline:
The outline can be further customized using OutlineAppearance. By default, the outline for both the front side of the solid and the backside are displayed. For some solids, such as ellipsoids with a high number of slices and stacks, the outline on the backside can clutter the visualization. Use OutlineAppearance.FrontLinesOnly to only display the outline on the front side of the solid:
OutlineAppearance.StylizeBackLines is an alternative to OutlineAppearance.FrontLinesOnly that can also be used to declutter the outline without eliminating the outline on the backside of the solid. When OutlineAppearance.StylizeBackLines is used, the backside outline is displayed using a different color, translucency, and width as the front side outline. This can be used to de-emphasis the backside outline by giving it any combination of a lighter color, lower translucency, or smaller width. When OutlineAppearance.StylizeBackLines is used, the backside outline is displayed using BackLineColor, BackLineTranslucency, and BackLineWidth. The following example uses a lower translucency and smaller width to de-emphasis the backside outline:
solid.Color = Color.Yellow; solid.OutlineTranslucency = 1.0f; // Default solid.OutlineWidth = 2.0f; solid.OutlineAppearance = OutlineAppearance.StylizeBackLines; solid.BackLineTranslucency = 0.5f; solid.BackLineWidth = 1.0f; // Default
A silhouette is the outline of an object from the camera's point of view. Displaying a solid's silhouette is a useful visual cue for differentiating the solid from the background. Set DisplaySilhouette to true to display a solid's silhouette and use SilhouetteColor, SilhouetteTranslucency, and SilhouetteWidth to customize it.