A tutorial by geoff.
In this tutorial we'll learn how to create custom meshes and deal with them with Irrlicht. We'll create an interesting heightmap with some lighting effects. With keys 1,2,3 you can choose a different mesh layout, which is put into the mesh buffers as desired. All positions, normals, etc. are updated accordingly.
Ok, let's start with the headers (I think there's nothing to say about it)
This is the type of the functions which work out the colour.
Here comes a set of functions which can be used for coloring the nodes while creating the mesh.
The type of the functions which generate the heightmap. x and y range between -0.5 and 0.5, and s is the scale of the heightmap.
A simple class for representing heightmaps. Most of this should be obvious.
The only difficult part. This considers the normal at (x, y) to be the cross product of the vectors between the adjacent points in the horizontal and vertical directions.
s is a scaling factor, which is necessary if the height units are different from the coordinate units; for example, if your map has heights in metres and the coordinates are in units of a kilometer.
A class which generates a mesh from a heightmap.
Our event receiver implementation, taken from tutorial 4.
Much of this is code taken from some of the examples. We merely set up a mesh from a heightmap, light it with a moving light, and allow the user to navigate around it.
Create the custom mesh and initialize with a heightmap
Just a usual render loop with event handling. The custom mesh is a usual part of the scene graph which gets rendered by drawAll.
That's it! Just compile and play around with the program.
|The Irrlicht Engine is a cross-platform high performance realtime 3D engine written in C++. It features a powerful high level API for creating complete 3D and 2D applications such as games or scientific visualizations. It comes with an excellent documentation and integrates all state-of-the-art features for visual representation such as dynamic shadows, particle systems, character animation, indoor and outdoor technology, and collision detection. All this is accessible through a well designed C++ interface, which is extremely easy to use.|
|Its main features are:|
|There are lots of common special effects available in the Irrlicht Engine. They are not difficult to use, in most cases the programmer only has to switch them on. The engine is constantly extended with new effects, here is list of effects which are currently implemented:|
|The Irrlicht Engine supports 5 rendering APIs, which are 4 more than most other 3D engines do:|
When using the Irrlicht engine, the programmer needs not know, which API the engine is using, it is totally abstracted. He only needs to tell the engine which API the engine should prefer.
Materials and Shaders
|To be able to create realistic environments quickly, there are lots of common built in materials available in the engine. Some materials are based on the fixed function pipeline (light mapped geometry for example) and some are relying on the programmable pipeline (normal mapped/parallax per pixel lighted materials for example) todays 3d hardware is offering. It is possible to mix these types of materials in a scene without problems and when using a material which needs features the hardware is not able to do, the engine provides fall back materials. However, if the built in materials are not enough, it is possible to add new materials to Irrlicht at runtime, without the need of modifying/recompiling the engine. Currently supported shader languages for this are:|
|The Irrlicht Engine is platform independent, currently there is official support for:|
For the serious mobile developer there are work-in-progress OpenGL ES drivers, which have enabled the Irrlicht community to develop iPhone, Android and Nokia Symbian ports. The Engine works with all supported platforms in the same way. The programmer only has to write the game/application code once, and it will run on all supported platforms without the need to change one single line of code.
|Rendering in the Irrlicht Engine is done using a hierarchical scene graph. Scene nodes are attached to each other and follow each others movements, cull their children to the viewing frustum, and are able to do collision detection. A scene node can for example be a camera, an indoor or outdoor level, a skeletal animated character, animated water, a geomipmap terrain, or something completely different.In this way, the Irrlicht engine can seamlessly mix indoor and outdoor scenes together, gives the programmer full control over anything which is going on in the scene. It is very easily extensible because the programmer is able to add his own scene nodes, meshes, texture loaders, GUI elements, and so on.The geometry creator gives easy access to simple gemetrical bodies, such as cylinder, cube, etc. Objects can be rendered as polygons, wireframe, or points, using triangles, lines, point and point sprite primitives.|
|Currently there are two types of character animation implemented:|
The programmer doesn’t need to know about all this, if he doesn’t want to. All he has to do is to load the files into the engine and let it animate and draw them.
|Lots of common file formats are supported, and are able to be loaded (and partially also saved) directly from within the engine. In this way, you don’t need to convert your media before using it with the Irrlicht Engine, saving development time. The internal ressource management of Irrlicht provides simple access to all file formats and takes care of fetching already loaded meshes or textures from its own cache instead from disk if the data was already loaded before. The list of all supported formats is constantly growing, and there are many community-made plugins which add new formats without having to recompile the engine.If you need the Irrlicht Engine to be able to load a file format which it cannot currently handle, simply ask for it by raising a feature request on our issue tracker.Currently supported textures file formats:|
Currently supported mesh file formats:
Supported Render Features
Irrlicht supports all general render features needed for high quality rendering of materials and effects. Besides a few exceptions, all features are supported in all hardware accelerated APIs, and some are supported by the software renderers as well. The following list contains all supported render features of the current version of the Irrlicht Engine. Please ask for extending this set to certain features required.
Currently supported render features:
- Predefined materials
- Solid with alpha blending 2nd texture
- Light maps with configurable pre-multiplication and additional dynamic light support
- Detail map
- Sphere map
- Environment reflection
- Transparency by adding the texture
- Transparency by using the texture alpha
- Transparency by using the texture alpha without blending
- Transparency by using the vertex alpha
- Normal maps
- Parallax maps
- Flexible blend mode rendering
- Material Colors (ambient, diffuse, emissive, specular)
- Line thickness (only OpenGL)
- ZBuffer write/test modes
- Per mesh anti-aliasing settings
- Alpha to Coverage
- Color masking
- Vertex colors with configurable interpretation
- Wireframe/Point cloud rendering
- Gouraud/Flat shading
- Lighting mode configurable
- Backface/Frontface culling
- Fog enabling per mesh
- Automatic normals normalization
- Texture coordinates repeat/clamp modes
- Per texture filtering (bilinear, trilinear, anisotropic)
- Texture LOD Bias
- Texture matrices
- Arbitrary number of multi-textures