Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / Win32

Simple Real Time Data Visualization in 3D using NZR: System Monitor Application

3.67/5 (3 votes)
3 Feb 2009CPOL4 min read 48.2K   1.3K  
Visualizing Real Time Data in 3D
Image 1

Introduction

If you develop algorithms, debug real time systems, handle large data or generate scientific data, you could use NZR to your advantage. Generally if you try to instrument your code, the instrumentation slows down the system and modifies its behavior. The System Monitor application is an interesting way of easing you to the NZR API. This application visualizes the CPU usage and IP traffic on your PC. It also captures the desktop window and displays it on a 3D model of the PC. The CPU usage of four processes is displayed using nzrVolume object. Color and opacity mapping is used to highlight the different processes. The IP traffic on the wire is shown in two ways. The packet length vs. time is graphed using nzrGraph object. The IP source and destination addresses are mapped as points in a 3D space, where the first three octets are mapped as x, y and z positions. The fourth octet is used to color the associated glyph and text. This program displays every packet that is on the wire connected to your PC.

By separating the 3D visualizing code from the application code, all the complexity of 3D visualization has been encapsulated in the NZR application. This only leaves a very thin server library and a header file to realize the interface. The application code is now very clean and the developer can focus on higher order things in her application.

Preparation

Before compiling and running this application, you will need to download:

  • NZR 2.0 from here
  • WinPcap driver for IP traffic sniffing from here 

Using the Code 

NZR is a Window's application that exposes a 3D space to other Windows applications. A C++ library with an associated application programmers interface (API) exposes a simple interface to enable placing a variety of objects in the NZR's space. These objects are:

  • nzrDisplay: This object allows the control of display attributes of objects that can be rendered. These attributes are position, color, scale, opacity, lighting model and orientation.

Displayable Objects

Each displayable object has two verbs that allow inserting and removing it from the NZR 3D space. They are "place" and "remove".

  • nzrText: Used for displaying text 
  • nzrImage: Used for displaying images or other two dimensional data
  • nzrPoints: For displaying points
  • nzrGraphs: Used for displaying one dimensional data
  • nzrVolume: Used for displaying three dimensional data
  • nzrSphere: For displaying spheres
  • nzrPolyline: Used for displaying an arbitrarily shaped line in three dimensions
  • nzrOutline: Used for displaying a three dimensional outline
  • nzrFile: This is used to insert a JPEG or 3ds file into the NZR space

Support Objects

  • nzrLocalServer: Every application needs to instantiate this object. It moves the data from the server application to NZR. NZR is considered a visualization client and the nzr application is considered a data server. The server pushes the data to the client. nzrLocalServer has two useful member functions. The first one is "clearAll()" which clears all objects in the NZR space. The second is "render()" which makes all that has been placed visible in the NZR space.
  • nzrCamera: This object is used to set the viewpoint in the NZR space. The optimal values can be interactively established by setting the viewpoint and then reading the camera values from the dialog box in the scDoc window.
  • nzrBackground: Used to set the background color.
  • nzrLight: Used for setting the lights in the scene. The color, intensity, focal point and position can be selected. There are three types of lights available, namely headlight, scenelight and cameralight. 

Code Pattern

The flow of using an nzr object is as follows:

  • Instantiate the object and connect it with the nzrLocalServer object.
  • Set the display attributes using the nzrDisplay object.
  • Set the object specific attributes.
  • Place the object in the NZR™s 3D space using the place function associated with each object. 
  • After all the objects have been placed, call the render function associated with the server. 

Extra Help

The code is heavily commented. There are also a number of tutorials for visualizing individual objects available on the SoftServ™s (www.softserv-intl.us) web site that should ease understanding and experimentation with the API.

NOTE: Please make sure that you have downloaded NZR and WinPcap driver. NZR should be running with one sc Doc open BEFORE the system monitor application can be run. To open sc Doc, just open a new file. You will be prompted for the type of doc. Select the sc doc type and a window will open which will be most black. You can also open a sc doc by typing "new sc" in the NZR's console window. Only one sc Doc should be opened at any one time. It would also help to have some network traffic running as the packet sniffer call is a blocking call. The code was kept deliberately simple to highlight the visualization aspects.

History

  • 26th January, 2009: Initial post
  • 2nd February, 2009: Made minor modifications to article

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)