# 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.

Box Triangulator

BoxTriangulator computes a SolidTriangulatorResult for a box centered at the origin. This result can be provided to the SolidPrimitive.set 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 (get / set). The following example uses a solid primitive to visualize a box. AxesEastNorthUp is used to create a ReferenceFrame for the primitive.

Java
```EarthCentralBody earth = CentralBodiesFacet.getFromContext().getEarth();
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.0, 1000.0, 2000.0));
SolidPrimitive solid = new SolidPrimitive();
solid.setReferenceFrame(referenceFrame);
solid.set(result);

SceneManager.render();
```
Ellipsoid Triangulator

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.

Java
```EarthCentralBody earth = CentralBodiesFacet.getFromContext().getEarth();
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.0, 1000.0, 1000.0));
SolidPrimitive solid = new SolidPrimitive();
solid.setReferenceFrame(referenceFrame);
solid.set(result);

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.

 Slices: 12. Stacks: 8. Slices: 24. Stacks: 8. Slices: 12. Stacks: 16.
Cylinder Triangulator

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:

Java
```SolidTriangulatorResult result = CylinderTriangulator.compute(4000.0, 1500.0, 1500.0, 180, CylinderFill.ALL);
```
Fill and Outline

By default, a solid's interior fill and outline are displayed. The fill can be customized using DisplayFill (get / set), Color (get / set), Translucency (get / set), and AffectedByLighting (get / set). The outline can be customized with DisplayOutline (get / set), OutlineColor (get / set), OutlineTranslucency (get / set), and OutlineWidth (get / set). The following images show three possible combinations of interior fill and outline:

 Fill: false. Outline Translucency: 0.5. OutlineWidth: 5. Color: Yellow. Affected by Lighting: true (default). Outline Color: Blue. Color: Yellow. Affected by Lighting: false. Outline Color: Blue.

The outline can be further customized using OutlineAppearance (get / set). 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.FRONT_LINES_ONLY to only display the outline on the front side of the solid:

 Front and Back Lines (default) Front Lines Only

OutlineAppearance.STYLIZE_BACK_LINES is an alternative to OutlineAppearance.FRONT_LINES_ONLY that can also be used to declutter the outline without eliminating the outline on the backside of the solid. When OutlineAppearance.STYLIZE_BACK_LINES 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.STYLIZE_BACK_LINES is used, the backside outline is displayed using BackLineColor (get / set), BackLineTranslucency (get / set), and BackLineWidth (get / set). The following example uses a lower translucency and smaller width to de-emphasis the backside outline:

Java
```solid.setColor(Color.YELLOW);
solid.setOutlineTranslucency(1.0f); // Default
solid.setOutlineWidth(2.0f);
solid.setOutlineAppearance(OutlineAppearance.STYLIZE_BACK_LINES);
solid.setBackLineTranslucency(0.5f);
solid.setBackLineWidth(1.0f); // Default
```
Silhouette

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 (get / set) to true to display a solid's silhouette and use SilhouetteColor (get / set), SilhouetteTranslucency (get / set), and SilhouetteWidth (get / set) to customize it.

 No silhouette (default) Silhouette enabled Silhouette enabled, different camera position