Click here to Skip to main content
13,197,548 members (50,964 online)
Click here to Skip to main content
Add your own
alternative version


21 bookmarked
Posted 14 Aug 2007

Visualizing Points with NZR

, 14 Aug 2007
Rate this:
Please Sign up or sign in to vote.
An article on visualizing points in 3D

Point Data with different Glyph types


If you live in Boston, then going to the Fire & Ice Restaurant is a treat. You can create your own special dish from a wide assortment of ingredients and sauces without having to go through the hassle of preparing the ingredients. NZR Visualization Framework borrows a page from Fire & Ice by offering a developer the ability to tailor visualizations of a wide assortment of data types in a 3D window without having to learn OpenGL or some other complicated visualization library. This tutorial focuses on visualizing point data with NZR and highlights the simplicity of doing so.

Something as innocuous as points can have considerable sophistication when it comes to rendering them in 3D space. Visualizing point data is commonly needed when developing algorithms, scientific data gathering, financial modeling, etc. The developer typically has to either learn a complicated graphics package or rely on canned applications. NZR is a new visualization framework announced by SoftServ Int'l. Corp. that decouples all data-rendering complexity for the developer and offers a very simple API for rendering various types of data. Here I will present visualization of point data using NZR Lite, which implements a subset of NZR features. You are encouraged to try out the different attribute settings to explore the applicability to your needs.

Using the Code

Point visualization consists of the following steps:

  1. Instantiate the point data structure.
  2. Call newObject() to set the default values locally, i.e. in your program.
  3. Modify attributes locally.
  4. Call createObject() to instantiate the object in NZR memory.
  5. Populate the point data array.
  6. Call writeObject() to transfer the point data to NZR.
  7. Set the camera at the correct 3D position.
  8. Call render() to render the data.

NZR has different types of cursors to facilitate viewing the data. The main NZR window has a panel that displays camera settings at any point. These settings can be used to establish the right parameters for programmatically setting the camera.

The first example displays the point data using CONE glyphs that have been scaled based on the intensity associated with each point.

#include <span class="code-string">"nzrLiteClient.h"</span>

pPointLocations = new nzr_points;

// Set the default values locally
myNZRClient->newObject(pPointLocations);  // set default values 

// The default values are the Reference Position of 
// the points in 3D window space
// , the scale of Points, the color of Points, the opacity of the Points
// , Light Model Parameters and the orientation of Points in the 3D window.
// Any of the above default display attributes can be changed

pPointLocations->cmnd.display.colorR    = 10;
pPointLocations->cmnd.display.colorG    = 10; 
pPointLocations->cmnd.display.colorB    = 10;  

// The points can be visualized using glyphs, which are 
// geometrical shapes representing a point
pPointLocations->glyphType = CONE;  
pPointLocations->glyphScale = (float) 0.05; // Sets the scale of glyphs

// A glyph can be further scaled using either 
// intensity or vector value associated with each point
pPointLocations->glyphScaleMode = INTENSITY;  // could also be set to VECTOR

myNZRClient->createObject(pPointLocations);   // creates the new object

// Initialize an array of points
float alpha = 20.0;
float beta = (float) 0.02;

for( int t = 0; t < NUMBER_OF_POINTS; t++)
    inputArray[t].x = (float) alpha*sin(t/(float) 10.0);
    inputArray[t].y = (float) alpha*cos(t/(float) 10.0);
    inputArray[t].z = (float) beta*t;         // z value
    inputArray[t].intensity = (float) (t%10); // change the intensity value
    inputArray[t].vx = 0;
    inputArray[t].vy = 0;
    inputArray[t].vz = 1.0;  // point the glyph in + z direction

// Now write the point values to NZR
myNZRClient->writeObject(pPointLocations, (void *) &inputArray[0]); 

// Camera is used to set the viewpoint. 
pMyCamera = new nzr_camera;
myNZRClient->newObject(pMyCamera);  // set default values

// Over ride the camera settings
pMyCamera->FocalPointX  = 0;
pMyCamera->FocalPointY  = 0;
pMyCamera->FocalPointZ  = 0;
pMyCamera->posX         = 0;
pMyCamera->posY         = 0;
pMyCamera->posZ         = 100;
pMyCamera->ClippingNear = 97;
pMyCamera->ClippingFar  = 103;
myNZRClient->setCamera(pMyCamera); // set camera parameter

// Now render the point data on NZR display which will make it visible

Link the program with nzrLiteClientLibR.lib. That is all. NZR Lite should be running with sc doc opened before running the example. There are a couple of helper functions available to delete either individual objects or all objects in the scene. Background color can also be programmatically set.

At times, there is a need to represent vector data associated with a point, e.g. visualizing the dynamics of a golf swing. The second example shows how this can be done and additional point data presented with a second set of points, but visualized with a different glyph type. Here vector data is being visualized by enabling glyphScaleMode to VECTOR and populating the vector data as shown below.

pPointVectors->glyphScaleMode = VECTOR; 
pPointVectors->glyphType = ARROW;
for( int t = 0; t < NUMBER_OF_POINTS; t++) 
    inputArray[t].vx = (float) 12*sin((float)t/20.0);    // x value
    inputArray[t].vy = (float) 12*cos((float)t/20.0);    // y value
    inputArray[t].vz = (float) 0;    // z value

Complex point data can employ a similar strategy of using a combination of color, glyph type, scale mode and opacity to visually convey sophisticated data values.

Points of Interest

I have also included rendering polylines in the library that you could experiment with. I will cover visualizing lines with NZR at some later time.


  • August 2007: Initial release


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171020.1 | Last Updated 14 Aug 2007
Article Copyright 2007 by ImranHKhan
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid