Coin3D and Qt:
1
The Solution for Cross-platform 3D Application Development
KONGSBERG SIM
1 Introduction
Coin3D and Qt together present the easiest way to create powerful, cross-platform 3D applications. Kongsberg
SIM’s Coin3D is an OpenGL based, retained mode 3D graphics rendering library that is fully compatible with SGI’s
Open Inventor. Qt is a high-performance, cross-platform application development framework that makes developing
sophisticated user interfaces a snap. Both are fully cross-platform, allowing a single code-base to work on multiple
platforms, increasing developer productivity, reducing maintenance headaches, and saving money.
Coin3D consists of a core 3D rendering library (Coin), le import/export libraries and GUI-bindings.
This whitepaper will describe how to integrate Coin and Qt using SoQt. SoQt is the GUI-binding between Coin and Qt
that allows Qt applications to display complex 3D scenes with ease. Because Coin is fully compatible with SGI’s Open
Inventor, the de facto standard 3D graphics API for complex visualization applications, legacy Inventor applications
can be updated to use Coin. SoQt’s interface closely matches SGI’s original SoXt GUI bindings, making it easier to port
legacy X Windows Inventor applications to Qt.
2 First Steps with SoQt
Before delving into the details of SoQt and Coin, it is useful to see SoQt in action to illustrate just how simple it can be
to develop a 3D Qt application. The goal is to load an Open Inventor le containing a scene, display it, and provide user
interaction.
int main( int argc, char** argv ) {
// Initializes SoQt library (and implicitly also the Coin and Qt
// libraries). Returns a top-level / shell Qt window to use.
QWidget * mainwin = SoQt::init(argc, argv, argv[0]);
SoInput sceneInput;
if ( !sceneInput.openFile( “stagedancers.iv” ) )
return -1;
SoSeparator *root =SoDB::readAll( &sceneInput );
root->ref();
// Use one of the convenient SoQt viewer classes.
SoQtExaminerViewer * eviewer = new SoQtExaminerViewer(mainwin);
eviewer->setSceneGraph(root);
eviewer->show();
// Pop up the main window.
SoQt::show(mainwin);
// Loop until exit.
SoQt::mainLoop();
// Clean up resources.
delete eviewer;
root->unref();
return 0;
}
评论0