Design concepts


Jump to: navigation, search

This page explains the fundamental concepts behind the design of H3DAPI applications. If you can't wait to get started with H3DAPI, well, by all means! We recommend that you understand these concepts at some point in your H3DAPI adventures, as it might be useful for haptics application development with H3DAPI. H3D has a unique design that is powerful when used the right way, and we think that you might want to exercise that power!



X3D introduces a structural division in the scene-graph concept - the use of Nodes and Fields. Fields are data containers that know how to store and manipulate data properties. Nodes are essentially containers and managers of fields - all node functionality is implemented in terms of fields. Understanding when and how to use Nodes and Fields is essential in building an X3D based application. There are three levels of programming for H3D - using C++, X3D or Python. X3D and Python are high level interfaces to the API, while C++ gives you a somewhat raw access to the API. Each has appropriate strengths and weaknesses that are discussed below. The SenseGraphics recommended design approach is to break the application up into generic functional units that can be encapsulated as fields and scene-graph nodes - this maximizes reusability and encourages good application design. Geometry and scene-graph structure for a particular application is then defined using X3D. Finally, application / user-interface behavior is described using Python.


Fields are the fundamental building blocks of X3D and thus H3D. In its simplest form, a Field is simply an event handling mechanism. Fields are arranged into a directed graph (called the field network) where events are passed from field to field according to how the field network has been constructed. Field connections are defined as routes and can be either a one-one, many-to-one or many-to-many connection. The field layer in H3D takes care of event handling and performs optimized lazy-evaluation of the field network where possible. Fields have also been extended to be data containers that can store and pass data along the field network. Fields that are data containers can enforce strict typing to ensure to help minimize bugs in the field network. The default behavior of a data container field is to simply propagate the input data forward to all outgoing connections, but a special update() function can be customized to perform any arbitrary operation on the data as it flows through the network.

Some fields use the update() function without being a data container, often to perform operations such as OpenGL rendering and display list cache management. In this manner all logic operations of a Node can be encapsulated as a series of fields.


Nodes are the traditional building blocks of scene-graph APIs. In H3D, nodes should be viewed as containers and managers for fields and field networks. In theory, an entire application could be written in H3D using only the field network. However, the field network becomes rapidly unmanageable in anything other than a trivial application.


The strength of C++ is that it is a compiled language that can be used to create highly efficient code. When writing haptic rendering algorithms or using OpenGL, C++ is the obvious choice. The main weakness of C++ is the relatively slow development time, stemming chiefly from the compile-test-debug cycle that means finding and fixing bugs can often take a long time. Any function that can be considered time critical should be encapsulated as a C++ node or field in the API.


The X3D file format is used by H3D as an easy way to define geometry and arrange scene-graph elements such as a user interface. H3D has a full XML enabled X3D parser and automatically supports predefined X3D nodes as well as any new nodes developed for your application / toolkit. Using X3D you can avoid long lines of unmanageable C++ scene-graph descriptions that are hard to read, maintain and debug.


Python is an interpreted language meaning that you do not need to compile your python scripts to run them. Therefore, you avoid the compile phase of the compile-test-debug cycle, which allows rapid prototyping of application functionality.

Python is ideal for defining fields that control simple non time-critical behavioral properties such as UI. It can also be effective for prototyping complex time-critical fields that can be ported to C++ after prototyping.

Finally, it has an extensive library of extensions to simplify tasks such as file management, network communication and database access.

Personal tools
go to