Configuring a Light Source for a 3D Scene

You can configure a light source to achieve visual effects such as sunlight or spotlights in a visible 3D scene. You can create three types of lights in a 3D scene: directional lights, positional lights, and spotlights. While the following procedure explains how to configure a directional light for a 3D scene, you can use similar steps to configure positional lights and spotlights.

Complete the following steps to configure a directional light for a 3D scene.

  1. Create a 3D scene, or open a VI that contains a 3D scene.
  2. Remove the wire that connects the 3D object to the 3D picture control terminal.
  3. Right-click the reference output of the Set Drawable method and select Create»Method for SceneObject Class»Light»Add Light from the shortcut menu to create the Light:Add Light method.
  4. Add the Light:Add Light method to the right of the Set Drawable method, and wire the reference output of the Set Drawable method to the reference input of the Light:Add Light method.
  5. Add the New Light VI to the block diagram.

     Add  Find
  6. Right-click the Light Number input of the New Light VI, select Create»Constant from the shortcut menu, and enter a number between 0 and 7, inclusive. This indexes, or sets the integer that identifies, the light. You cannot index more than 8 lights.
Note  LabVIEW cannot generate a light source if the index is undefined. By default, LabVIEW defines the light at index 0 as a directional light. If you configure a light at index 0, the light you configure overwrites the default light.
  1. Right-click the New Light Refnum output of the New Light VI and select Create»Property for SceneLight Class»Direction from the shortcut menu to create the Direction property.
  2. Add the Direction property to the right of the New Light VI, right-click the property, and select Change to Write from the shortcut menu.
  3. Wire the New Light Refnum output of the New Light VI to the reference input of the Direction property.
  4. Right-click the Direction input of the Direction property, select Create»Constant from the shortcut menu, and change the values of the constant to the x, y, and z coordinates that you want to use to define a direction for the light.
  5. Wire the reference output of the Direction property to the Light input of the Light:Add Light method.
  6. Wire the reference output of the Light:Add Light method to the 3D picture control terminal.

    The following block diagram shows a 3D scene with a configured directional light. The direction coordinates in this 3D scene add the light source beneath the 3D object.

  1. Wire error in and error out terminals on the block diagram.
  2. Run the VI to generate the 3D scene.

Refer to the Using Meshes VI in the labview\examples\Graphics and Sound\3D Picture Control directory for an example of configuring a light source for a 3D scene.

Open example  Find related examples