Levels of Detail (LOD) | Specifying the Beginning of the Hierarchy Tree

MDL Model File Hierarchy

MDL models are arranged in a hierarchy of components and primitives. In the hierarchy, the component is the parent of all primitives and subcomponents contained within. A primitive that refers to a component is the parent of that component.

The vehicle.mdl model file contains a simple hierarchy of components and primitives:

The vehicle.mdl model file

#######################################################################
# COPYRIGHT 1995-2002 Analytical Graphics, Inc. #
# This data is intended for use with STK (R) #
# products only. Any other use is expressly forbidden. #
#######################################################################

Component Solarpanel
          Polygon
                FaceColor NavyBlue
                NumVerts 4
                Data
                0 0 7
                0 5 7
                0 5 -7
                0 0 -7
          EndPolygon
EndComponent
Component Body
          Cylinder
                Translate -2 0 0
                FaceColor coral
                NumSides 6
                Face1Position 0 0 0
                Face1Radius 3
                Face1Normal -1 0 0
                Face2Position 4 0 0
                Face2Radius 3
                Face2Normal 1 0 0
          EndCylinder
EndComponent
Component Vehicle
Root
          Refer
              Translate 0 3 0
              Component Solarpanel
          EndRefer
          Refer
              Translate 0 -8 0
              Component Solarpanel
          EndRefer
          Refer
              Component Body
          EndRefer
EndComponent

Levels of Detail (LOD)

You can use the Component keyword to specify a model with only one level of detail, that is, a model that can only be built using all of the components in the model file. However, this type of model may impact system performance since the same amount of detail is drawn whether the model is 3 miles or 300,000 miles away from the viewer. To alleviate performance issues, models can also be specified using two levels of detail: Component1 and Component0. The Component1 command contains the data needed to draw a less complex model for viewing from a distance while Component0 contains the data needed to draw a fully detailed model for viewing up close. Component1 and Component0 are independent of one another. Both can contain generic Component commands; however, Component1 cannot contain Component0 commands and vice versa.

In the model file, Component blocks are set off with the keyword Component < ComponentName> to mark the beginning of the block and an EndComponent keyword to mark the end of the block. For models with two levels of detail, use the Component1 < ComponentName> or Component0 < Component Name> keyword.

All character strings in a model file are a maximum of 31 characters in length.

Following is a sample Truck.mdl file containing two levels of detail:

# LOD 0
      Component0 RightSide
          Extrusion
                FaceColor DarkOliveGreen
                Length 0.2
                NumVerts 9
                Data
                0 4.1 3
                0 5.5 5
                0 4.3 5
                0 4.3 6.6
                0 4.2 6.5
                0 0.2 6.5
                0 0 6.1
                0 0 4
                0 1 3
          EndExtrusion
      EndComponent

      Component0 RightSideFt
          Polygon
                FaceColor DarkOliveGreen
                NumVerts 9
                Data
                0 4.1 3
                0 5.5 5
                0 4.3 5
                0 4.3 6.6
                0 4.2 6.5
                0 0.2 6.5
                0 0 6.1
                0 4
                0 1 3
          EndPolygon
      EndComponent

      Component0 RightSideStr
          Refer
          ;Component RightSide
          EndRefer
          Refer
          Component           RightSideFt
          EndRefer
          Refer
          Component RightSideBk
          EndRefer
      EndComponent
.
.
.
Component0 SA10Truck
Root
Refer
      Rotate 0 0 90
      Translate 15 -4 0
      Component Body
EndRefer
EndComponent
# LOD 1
Component1 RightSide
      Cylinder
            FaceColor DarkOliveGreen
            Length 0.2
            NumVerts 9
            Data
            0 4.1 3
            0 5.5 5
            0 4.3 5
            0 4.3 6.6
            0 4.2 6.5
            0 0.2 6.5
            0 0 6.1
            0 0 4
            0 1 3
      EndExtrusion
EndComponent
Component1 RightSideFt
      Polygon
            FaceColor DarkOliveGreen
            NumVerts 9
            Data
            0 4.1 3
            0 5.5 5
            0 4.3 5
            0 4.3 6.6
            0 4.2 6.5
            0 0.2 6.5
            0 0 6.1
            0 0 4
            0 1 3
      EndPolygon
EndComponent
.
.
.
Component1 SA10Truck
Root
Refer Rotate 0 0 90
Translate 15 -4 0

Component Body
EndRefer
EndComponent

When viewing a model defined with multiple levels of detail, you can specify which level of detail should be displayed in the 3D window using the Models page of the object's 3D Graphics properties.

The Truck.mdl model shows how two levels of detail can be used:

Specifying the Beginning of the Hierarchy Tree

A model file is not necessarily ordered sequentially from the beginning of the file. The Root designator, which must be contained in one and only one component, signifies the top of the hierarchy for the model. The hierarchy begins with the component specified as Root and traverses down the hierarchy, building each of the components included in the model file.

For those model files that contain multiple levels of detail, one and only one Root designator is allowed for each level of detail. If a model file contains only one level of detail, the Root designator is still required to indicate the top of the tree.

The Root command for the Component1 detail level of the Truck.mdl model:

Component1 SA10Truck
Root
Refer

Rotate 0 0 90
Translate 15 -4 0

Component Body
EndRefer
EndComponent

If more than one Root command is specified for a Component (or Component1, Component0), the model may be drawn incorrectly.