Example Code

Turn 3D Object Translucent in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This example makes use of the Color Change.vi to change the color and alpha (opacity) value of a 3D object built in LabVIEW.

 

Description

A cylinder is the 3D object generated for this VI, using Create Cylinder.vi from the geometries palette. You could change this to another shape if desired.

 

The color and transparency are then set with Color Change.vi. Here, the alpha value refers to the degree of opacity of an object and can be a value between 0 and 1; 0 being completely translucent and 1 being completely opaque. It is necessary for the cylinder to be an 'object' to to allow us to display the cylinder in a 3D picture control, so

Create object.vi is used.

 

A property node is used to set the Blending.Mode to On, which is required in order for the 'alpha' value to be applied. Then we call the Set Drawable method of the SceneObject invoke node on our cylinder, to allow us to display it in a 3D scene. In the original version of this example, the 'Set Geometry' method was used in this invoke node. However this method is now obsolete, and Set Drawable gives us the same functionality. Finally, the cylinder is displayed in a 3D picture control.

 

These two front panel screenshots demonstrate the difference between an Alpha value of .8 and .2:

 

point8 alpha.PNGpoint2 alpha.PNG

 


 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Download and open Color Change Opacity 2012 NIVerified.vi
  2. On the front panel, select an alpha value between 0 and 1, where 0 = transparent and 1 solid.
  3. Select the desired color of the object by clicking on the orange color block control.
  4. Run the VI.
  5. Change the alpha value and run the VI again to observe the difference.
  6. Observe how the settings affect the object.

 

Additional Information or References

 

Block Diagram of the VI

Change opacity of a 3D object LV2012 - NI verified.png

 

 

 

 

 

 

 

 

 

 

 

 

**This document has been updated to meet the current required format for the NI Code Exchange. **

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
HunterSeeker
Member
Member
on

Could you please add ascreenshot of your front panel.