A li’l more about SoQt and Coin3D

Getting acquainted with SoQt

SoQt requires the Coin3D library. It does not come with Qt. The Qt’s free license prohibits the building of SoQt along with Qt. So it says SoQt has to be built separately on the system. To be able to use SoQt, you must have Coin3D and Qt working on your systems.

By using the combination of Coin3D, Qt and SoQt for your 3D applications, you have a framework for writing completely portable software across the whole range of UNIX, Linux, Microsoft Windows and Mac OS X operating systems. Coin3D, Qt and SoQt creates minimum of hassle for developers when working on multiplatform software, with the resulting large gains in productivity.

Beginning with the name of SoQt itself, we know it is the binding between Qt and Coin3D library. Considering Coin3D library, it is free and opensource implementation of OpenInventor which is capable of easy construction of 3D scenes, animation and provides user interaction with the scene. SoQt is compatible with Open Inventor. All Inventor classes follow a naming convention.

The basic classes in Inventor are prefixed using letters Sb. A few of them are listed below:

  • SbBool: Boolean value
  • SbColor: RGB color value
  • SbLine: directed 3D line
  • SbCylinder: cylinder
  • SbSphere: sphere, and so on.

In order to be able to use any of the basic types, the corresponding header files are included.

The letters So refer to scene object. All the other classes in Inventor are prefixed by these letters.
eg., SoCone, SoTransform etc.
The names of methods and variables follow camel-casing. eg. setSceneGraph()

SoQt, like Coin and Qt, provides the programmer with a high-level application programmer’s interface (API) in C++. The library primarily includes a class-hierarchy of viewer components of varying functionality and complexity, with various modes for the end-user to control the 3D-scene camera interaction.

Working of Coin3D

The node is the basic building block used to create three dimensional scene databases in Inventor.
Each node holds a piece of information, such as a surface material, shape description, geometric
transformation, light, or camera. All 3D shapes, attributes, cameras, and light sources present in a
scene are represented as nodes.

An ordered collection of nodes is referred to as a scene graph. This scene graph is stored in the Inventor database. Inventor takes care of storing and managing the scene graph in the database. The database can contain more than one scene graph. After you have constructed a scene graph, you can apply a number of operations or actions to it, including rendering, picking, searching, computing a bounding box, and writing to a file.

Classes of database primitives include:

  • Nodes– Shape nodes, Property nodes, Group nodes
  • Engines:Engines are objects that can be connected to other objects in the scene graph and used to animate parts of the scene or constrain certain parts of the scene in relation to other parts.
  • Sensors:A sensor is an object that detects when something in the database changes and calls a function supplied by the application. Sensors can respond to specified timing requirements or to changes in the scene graph data.


  • Group nodes: These nodes are used to collect child objects. The class for these nodes is SoGroup. This class has various sub-classes under it having different characteristics.
  • Shape nodes: They are used to represent 3D geometric objects.
  • Property nodes: They are used to represent qualitative features of the objects in the scene.


I am referring to an example in my previous post.
#include <Inventor/Qt/SoQt.h>: The SoQt class takes care of Qt initialisation.
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>: A number of viewers are available to view the 3D object generated. They are:

  • Constrained Viewer
  • Examiner Viewer
  • Fly Viewer
  • Plane Viewer
  • Full Viewer

I am using Examiner Viewer here. It is the general purpose viewer that has a convenient interface for repositioning and reorientation of the camera, by panning, rotating and zooming its position.

#include <Inventor/nodes/SoBaseColor.h>: SoBaseColor is a class used to define an object’s base color. The color is specified in RGB format. It falls under property nodes.

#include <Inventor/nodes/SoCone.h>: This is the node for cone shape. It comes under the category of shape nodes.

#include <Inventor/nodes/SoSeparator.h>: It is subclass of SoGroup class. It is used to isolate the effects of nodes in the scene.

QWidget * mainwin = SoQt::init(argc, argv, argv[0]);: Here the initilisation to the SoQt library is done.

SoSeparator * root = new SoSeparator;
: The root node of the scene graph is created here.

SoBaseColor * col = new SoBaseColor;
col->rgb = SbColor(2, 3, 0);
: The base color of the object is set.

root->addChild(new SoCone);: A cone is added to the scene as a child to the root node.

SoQtExaminerViewer * eviewer = new SoQtExaminerViewer(mainwin);
: The ExaminerViewer class of the viewer is used for display of objects.

SoQt::show(mainwin);: This pops up the main window.

SoQt::mainLoop();: Cleans up all static data allocated by the SoQt library on initialization.

In this post, I discussed a few more details about SoQt and working of Coin3D. Will be posting something interesting soon. Keep reading!

Qt with Coin3D

Well, I do not know how many of you have heard of Qt and Coin3D. In this post, I will be telling you about these and how these two can be used together.

What is Qt?
Qt is a cross-platform application framework that is widely used for developing application software with a graphical user interface (GUI).

Qt can be implemented using following tools:
1.Qt Creator, a cross-platform IDE for C++ and QML. Qt Designer’s GUI layout/design functionality is integrated into this relatively new IDE, although Qt Designer can still be called as a standalone tool.
2.Qmake, a tool that automates the generation of Makefiles for development project across different platforms.


  1. Download the source file from http://qt-project.org/downloads according to your system.
  2. Next step is to run the .run file.
  3. First place it in your home directory.
  4. Type in terminal: sudo chmod a+x file-name.run.
  5. Execute ./file-name.run in terminal.
    In my case, I ran qt-opensource-linux-x64-5.2.1.run file and had qt-5.2.1 working on my system.

What is Coin3D?
Check for its installation in my previous post http://kamalpreetgrewal.wordpress.com/2014/03/13/coin3d/.

What is SoQt?
In order to implement Coin3D in Qt, SoQt is required. It acts as glue between Coin3D and Qt.
Type sudo apt-get install libsoqt4-dev in terminal. Now you have SoQt installed.

I had to use Coin3D with Qt. In order to accomplish this, I had to be clear how SoQt and Coin3D work.
The basic working principle is scenegraphs.

What is a scenegraph?
A graphical scene is logically represented using scenegraphs. A scene graph can be defined as collection of nodes in a graph or tree structure. I will be discuusing these in another post.
I created a simple program for cone. The program is:

#include <Inventor/Qt/SoQt.h>

include <Inventor/Qt/viewers/SoQtExaminerViewer.h>

include <Inventor/nodes/SoBaseColor.h>

include <Inventor/nodes/SoCone.h>

include <Inventor/nodes/SoSeparator.h>

int main(int argc, char * argv)
// Initializes SoQt library
mainwin = SoQt::init(argc, argv, argv[0]);

// Make a dead simple scene graph by using the Coin library.
SoSeparator * root = new SoSeparator;

SoBaseColor * col = new SoBaseColor;
col-&gt;rgb = SbColor(2, 3, 0);

root-&gt;addChild(new SoCone);

// Use one of the convenient SoQt viewer classes.
SoQtExaminerViewer * eviewer = new SoQtExaminerViewer(mainwin);

// Pop up the main window.
// Loop until exit.

// Clean up resources.
delete eviewer;

return 0;


The next step is open terminal and go to directory where you saved the file.
Follow these steps in terminal:

  1. qmake -project : generates cone.pro file
  2. qmake : generates Makefile
  3. make : In case of some errors regarding SoQt missing (or something similar), open Makefile. Go to LIBS. Append this line with -lSoQt -lCoin and you are done. Again run make.
  4. ./cone

An Examiner Viewer window will show a cone. That’s it. You used Coin3D with Qt. Yeah, was not tough so far. 😀 In case of any queries, do comment.