Example Code

3D Picture Interaction - 3D Surface Editor

Code and Documents

Attachment


Summary:

This is an example of how to make an interaction with 3D Picture control. It may be treated as an example of use of Pick Model, WindowToObjectCoords and SetBillboardParams methods related to 3D Picture control (which are not covered by any of examples shipped with LabVIEW) as well as example of many others methods and properties related to this control includig creating and manipulating of simple 3D objects and meshes. As edited surface is represented by 3D spline, the code may be also treated as an example for spline interpolation routines.

Function:

The application is an interactive editor of 3D surface defined as 2D array of nodes. The space between nodes is filled with 3D mesh calculated by spline iterpolation between the nodes. User edits nodes' coordinates interactively by clicking and dragging directly on 3D Picture control. Surface edition starts with simple 3x3 flat set of nodes which may be dragged in any direction and the number of nodes may be changed in order to get a complex 3D surface.

Steps to execute code:

  1. Unpack the archive anywhere, open and run "3D Surface Editor.vi"
  2. Click and drag nodes to move them and change the shape of the surface
  3. By clicking and dragging anywhere else you may rotate the model - all rules for standard spherical controller applies here
  4. Nodes are always moved in the plane parallel to the plane of view
  5. The number of control nodes (and complexity of the surface) may be changed with "rows" and "columns"controls
  6. Current coordinates of all nodes are being updated in the 2D Array control

Screenshots:

3D Surface Editor_FP.png

<object id="scPlayer" width="888" height="684" type="application/x-shockwave-flash" data="http://content.screencast.com/users/vugie/folders/Jing/media/bfecc6f6-0256-4d10-8477-23f0a6e4518a/ji..." >  <param name="movie" value="http://content.screencast.com/users/vugie/folders/Jing/media/bfecc6f6-0256-4d10-8477-23f0a6e4518a/ji..." />  <param name="quality" value="high" />  <param name="bgcolor" value="#FFFFFF" />  <param name="flashVars" value="thumb=http://content.screencast.com/users/vugie/folders/Jing/media/bfecc6f6-0256-4d10-8477-23f0a6e4518a/Fi..." />  <param name="allowFullScreen" value="true" />  <param name="scale" value="showall" />  <param name="allowScriptAccess" value="always" />  <param name="base" value="http://content.screencast.com/users/vugie/folders/Jing/media/bfecc6f6-0256-4d10-8477-23f0a6e4518a/" />  Unable to display content. Adobe Flash is required. </object>

VI Snippet:

3D Surface Editor_BD.png

Pick Node_BD.png

Create Mesh Params_BD.png

VI attached below

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

Comments
Glenn's_Alias
Member
Member
on

Excellent example, very helpful!  Thank you!.

viScience
Active Participant
Active Participant
on

Awesome example of the power of the 3D picture control.

Intaris
Proven Zealot Proven Zealot
Proven Zealot
on

I've looked at this example multiple times in the past.

The documentation and examples for LV's 3D picture is woefully lacking. (As of 2012 at least).

Do you think you could take the time to write a nugget on the NI forums outlining how to get working with the 3D picture?  I've considered it myself a few times but you seem to understand it's workings a lot better than I.

vugie
Member
Member
on

I do not have too much time for this, but I recommend you searching lavag.org forums with "3d Picture" term (with quotes). Many issues were discussed there.

Jannis
Member
Member
on

Lots of clever tricks, clean programming, well documented.Thank You!

Contributors