Irrlicht 3D stuff


Things related to the Irrlicht 3D engine. Also check the IRC: #irrlicht on irc.libera.chat
H-Craft Championship, a game done with the Irrlicht engine: www.irrgheist.com.



Last edit: 30.September 2021


Examples and code-snippets with Irrlicht.
My playground repository for all kind of experiments with Irrlicht: irr-playground.
Source-code for H-Craft Championship, my free 3D Sci-Fi Racer: H-Craft Source.


Note: Most of the stuff below is a bit outdated and made long time ago. Newer code-snippets are generally in the irr-playground repository.


Stringtables with Irrlicht.
Both implementations need tinyXml to work.

First A simple stringtable implementation:
string_table_simple.cpp
string_table_simple.h

A more complex stringtable implementation that supports strings with parameters. It also needs tinyXml to work.
Additionally it needs a few more files, I hope I didn't forget any:
string_table.cpp
string_table.h
globals.h
helper_str.cpp
helper_str.h
convert_utf.h
convert_utf.c


Multiple timers.
Sometimes you need more than one timer in your game. For example you have often one global timer which runs always, while you mostly also need a game-timer which must be paused while your game is in pause-mode. That's why i made a wrapper around the irrlicht timer. You can create several instances of this timer class. You need to call Tick() for each instance regularly.
timer.cpp
timer.h


Truetypefonts from zgock from this post.
NOTE: In newer projects I use the CGUITTFont in the above mentioned playground repository instead. I haven't tested this code here for a few years.
My version contains a few bugfixes (mostly for memory leaks, but also for font-height) and is adapted to a newer Irrlicht version.
To get it working you also need to link freetype (http://www.freetype.org/) to your project. I tested it with freetype 2.3.5.
gui_freetype_font.cpp
gui_freetype_font.h

For more comfort I have created two more classes. The simpler one is a fontmanager which you can just drop in your project and it will make the memory-management for the fonts easier.
font_manager.cpp
font_manager.h

If you also need serialization (loading and saving the gui-elements together with fonts) the fontmanager won't be enough. To do that we need a fontfactory. That is not supported so far in Irrlicht so you will have to patch Irrlicht itself when you need that (there are reasons why this patch isn't yet in Irrlicht). Once you have patched Irrlicht you can use the the factory, which looks and works rather similar to the fontmanager.
font_factory.patch(for svn 2407 older versions can be found in my older patch series)
gui_font_factory.cpp
gui_font_factory.h


COctTreeSceneNodeTriangleSelector does use the octree which is already available when creating an COctTreeSceneNode. Usually that octree is only used for rendering the scenenode, but with my class it can also be used for the triangle selector. The reason for this was that creating COctTreeTriangleSelector, which is usually used, takes a very long time for complex models. I had also to make some changes in COctTreeSceneNode so i put those files here also. Then engineversion i use myself is currently a mix of Irrlicht 0.14 to Irrlicht 1.2 and svn so i can't guarantee that this code will run. But chances are high that it will work if you copy those files in irrlicht svn or 1.1 sources and add the COctTreeSceneNodeTriangleSelector files to the irrlicht project. But you should backup of the old COctTreeSceneNode sources before!
COctTreeSceneNode.cpp
COctTreeSceneNode.h
COctTreeSceneNodeTriangleSelector.cpp
COctTreeSceneNodeTriangleSelector.h


Lightmaps from Maya to Irrlicht.
There are a few ways to create and import lightmaps in irrlicht, but none of those worked for us (btw. if you don't know what lightmaps are check it here). What we did was to create the lightmaps in the modeller and export the scene as .obj files once with the lightmap texture and once as the usual scene. I wrote a small tool to merge those two .obj files (resulting in a file called .lmo) and modified the .obj loader so it can work with those .lmo files.

Converter for obj to lmo:
Compile with g++ obj2lmo.cpp -o obj2lmo
Call it as follows: obj2lmo yourmap.obj yourlightmap.obj texture_lightmap.tga and it will create a file called yourmap.lmo
obj2lmo.cpp

You can just add the lmo loader by adding the files to your project and calling sceneManager->addExternalMeshLoader for it. You will also need to add fast_atof.h to the project which can be found in the irrlicht sources.
CLMOMeshFileLoader.cpp
CLMOMeshFileLoader.h


Scripts
b3d_export.patch is a patch for B3D_Exporter_2.06 from Gandalf. Unfortunately his website www.gandaldf.com is gone. You still can get a patched script from me: b3d_export.py (patched)
My patch adds 2 changes to the original script:
1. It allows animation export from first to last frame (before it always used the current settings of the timeline).
2. Export of specific b3d nodes can be enable/disabled. For example to export without animations "Animation Nodes" can be disabled. Or to export only animations disable "Texture Nodes", "Brush Nodes" and "Mesh Nodes". This allows to export base-mesh and animations separately.

This exporter no longer works with newer Blender versions (> 2.50). The best current b3d exporter I know of is developed by the SuperTuxKart developers. Last I checked it could be found here: http://sourceforge.net/p/supertuxkart/code/HEAD/tree/media/trunk/blender_25


Free ugly models
I'm no modeler, but maybe good enough for some quick testing? No restrictions whatever for using them, thought I'd recommend finding nicer ones for any real projects :-)

easy_room
Based on my own rooms. Textures are mostly based on www.cgtextures.com and some small ones just from browsing google until I found something which looked good enough to use. The .zip should contain (hopefully) all Blender files as well as an .obj usable directly in Irrlicht.
easy_room easy_room.zip

adam
My first ever human model. Everything is made from scratch. Unfortunately it sometimes shows, especially for the animations. Exported as b3d files. adam_base.b3d contains the mesh in a T-Pose and all adam_ani*.b3d files contain only animation data. adam_ani.blend contains the current blender file and adam_mirrormod.blend contains the last mesh which still has the mirror modifier applied.
adam_idle adam090214.zip



Old patches
Patches I was using for Irrlicht (svn 2701 and later which is around the 1.6 release)
Patches I was using for Irrlicht (svn 2407 and later)
Patches I was using for Irrlicht (svn 1517 and later)
Patches used for Star Sonata (svn 808)