The contribution examples

The following examples do not directly illustrates one of the functions of the library. Some are very simple while others are much more involved. Feel free to browse the files and to cut and paste as you wish. Only a short description is here given, the source code is available in the examples/contribs directory.

3dsViewer

3dsViewer

The LGPL lib3ds library is used to load and display a 3ds scene.

You need to install the lib3ds library (version 1.2) in order to compile this file. See http://lib3ds.sourceforge.net/.

The current version (Ver 1.2, Dec 2002) of the lib3ds library is flawed and a patched version is available on the Unix installation page. Otherwise you will get the following message :

3dsViewer.cpp:62: `lib3ds_file_bounding_box' undeclared (first use this function)

Alternately, you can add the following line in lib3ds/file.h :

extern LIB3DSAPI void lib3ds_file_bounding_box(Lib3dsFile *file, Lib3dsVector min, Lib3dsVector max);

Press 'L' (load) to load a new 3DS scene.

agora

agora

Implementation of the game of Agora.

Agora is a strategy game for two players. The code is rather complex and can be divided in two parts : a QGLViewer implementation for the viewer and an artificial intelligence that allows you to play against the computer.

You should find the rules of the game on the web. Questions relative to the artificial intelligence implementation should be asked to Jean-Guillaume dot Dumas at imag dot fr.

anaglyph

anaglyph

Displays a scene in pseudo-stereo using anaglyph.

The anaglyph stereo mode displays simultaneously two colored views of the scene. You need to wear glasses with colored lenses (here red and blue) to view the stereo image. Each eye then sees the associated view, creating the stereo illusion.

All that is needed is to use the loadModelViewMatrixStereo() and loadProjectionMatrixStereo() camera functions to set appropriate GL_MODELVIEW and GL_PROJECTION matrices.

backgroundImage

backgroundImage

Displays a background image in the viewer.

This example is derivated from the textureViewer example. It displays a background image in the viewer using a texture. The texture is simply map to a quad, drawn before the rest of the scene. The depth buffer is flushed after the drawing. startScreenCoordinatesSystem() enables an easy pixel coordinate placement of the quad.

This example was created by Sylvain Paris. Thanks to him.

draw3DText

draw3DText

An icosahedron is used to illustrate the draw3DText() function.

Use this function to draw text as if it was a normal object of your 3D scene. You simply have to define the text position and its normal.

Attention : The draw3DText() function is deprecated since it requires the GLUT library, which is no longer needed by libQGLViewer. This example is kept in case Qt introduces an appropriate 3d drawing function.

eventRecorder

eventRecorder

Records a scenario that can be replayed and converted into a movie.

An EventRecorder is associated to a QGLViewer. When the EventRecorder isRecording(), the different events that are sent to the qglviewer() are recorded in an internal data structure. The EventRecorder then can replay these events with an identical timing in order to reproduce the recorded scenario. Snapshots can optionally be captured during playback, and the resulting image series can be converted into a movie.

quarto

quarto

A simulation of the game of Quarto.

See the rules.txt file for explanations.

This program was originally coded by Matthieu Richard.

textureViewer

textureViewer

Loads an image file and texture maps a polygon with it.

Pedagogical example that shows how to apply a texture on a 3D object. Inpired from the Qt texture example.

The Qt QImage class and its convertToGLFormat() function are used to load any image format. The image is resized so that its dimensions are powers of two if needed. Feel free to cut and paste.

thumbnail

thumbnail

Displays an alternative 3D view in a corner thumbnail.

This example shows how a thumbnail can be inserted in a corner of the viewer to display an alternative display. This can be useful for data structure inspection, different rendering (as illustrated here) or debugging. It uses glViewport and glScissor to restrict the drawing area.

This example was created by Sylvain Paris.

x3dViewer

x3dViewer

The X3DToolkit library is used to load and display an x3d scene.

You need to install the X3DToolKit library in order to compile this file. See the X3DToolKit web site

Press L (load) to load a new 3DS scene.

Go back to the examples main page

Valid XHTML 1.0! Valid CSS! Last modified on Wednesday, December 1, 2004.