Using the Level of Detail node

Use the Level of Detail node when you want to show different appearances of the same object, or different object, based on the viewing distance of the Level of Detail node.

Each child of a Level of Detail node sets a single appearance and a constraint when that appearance is selected and shown. The constraint can be either:

  • Minimum distance from the preview camera. You set the constraint by setting the value of the Minimum Distance property. Lower values set the child node to be selected when the preview camera is closer to the object. Higher values set the child node to be selected when the preview camera is further away from the object. Kanzi shows the child whose distance value is the next largest compared to the Level of Detail node’s distance to the preview camera.

  • Minimum coverage of the screen. You set the constraint by setting the value of the Minimum Area property. The coverage of the screen is measured in range [0…10], where 0 means that the object does not cover the screen at all, and 10 means that the object completely covers the screen. Kanzi shows the child whose area value is the next largest compared to the Level of Detail node’s bounding box projection area to the screen.

Note that the Level of Detail nodes affect only rendering, which is why you cannot use them in layouts. The size of the Level of Detail node is the size of its largest child, even if that child is not visible at the current Level of Detail node.

Creating a Level of Detail node

To create a Level of Detail node:

  1. In the Node Tree, press Alt and right-click the 3D node where you want to create a Level of Detail node and select Level of Detail.

    For example, create a Level of Detail node in the Scene node.

  2. In the Properties, set the Type property to either:

    • Distance to create a Level of Detail node that shows its child nodes based on Level of Detail node’s distance from the preview camera.

    • Perspective to create a level of detail that shows its child nodes whose area value is the next largest compared to the Level of Detail node’s bounding box projection area to the screen.

    For example, set Type to Distance.

  3. In the Node Tree, add child nodes to the Level of Detail node.

    For example, add a Sphere, a Box, and a Plane node.

    For each item you add to the Level of Detail node, based on the type of Level of Detail node you selected, Kanzi Studio adds either the Minimum Distance or Minimum Area property.

  4. Select each node you added to the Level of Detail node and in the Properties, depending on the Level of Detail node you selected, set either the Minimum Distance or Minimum Area property value to define when the Level of Detail node shows each item.

    For example, if you set Type to Distance, in the Node Tree select:

    1. Sphere and set its Minimum Distance property to 0.

    2. Box and set its Minimum Distance property to 10.

    3. Plane and set its Minimum Distance property 20.

    When you move the Level of Detail node or the preview camera along the z axis, Kanzi shows the child node whose distance value is the next largest compared to the Level of Detail node’s distance to the preview camera.

Using the Level of Detail node in the API

To create a distance Level of Detail node with three levels of detail:

// Create a level of detail selector node named LOD selector.
LevelOfDetail3DSharedPtr lodSelector = LevelOfDetail3D::create(domain, "LOD selector");

// Add three levels of detail, one child for each level.
lodSelector->addChild(lodHigh);
lodSelector->addChild(lodMedium);
lodSelector->addChild(lodLow);

// Set the level of detail selector node to show its child objects based on the
// level of detail selector node's distance from the preview camera.
lodSelector->setType(LevelOfDetail3D::LodTypeDistance);
// Use low level of distance child (lodLow) when the preview camera distance is
// at least 10.0f.
LevelOfDetail3D::setMinimumDistance(*lodLow, 10.0f);
// Use medium level of distance child (lodMedium) when the preview camera distance
// is at least 5.0f, but less than 10.0f.
LevelOfDetail3D::setMinimumDistance(*lodMedium, 5.0f);
// Use high level of distance child (lodHigh) when preview camera distance is
// less than 5.0f.
LevelOfDetail3D::setMinimumDistance(*lodHigh, 0.0f);

For details, see the LevelOfDetail3D class.

Level of Detail property types and messages

For a list of the available property types and messages for the Level of Detail node, see Level of Detail.

See also

Using the Empty Node nodes