Using the engine to display other game's data

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.

Using the engine to display other game's data

Postby Ray Koopa » Mon Aug 28, 2017 2:50 pm

Hey there, I need some beginners guidance :o

I've been evaluating several engines and libraries to see how far they support me in loading and displaying data stored in another game's proprietary file formats (custom model format, custom texture format) as the goal is to write a simplistic and small level editor for that game.

So far, a lot of engines fail the tests quickly, primarily focussing data fetched from a content pipeline or otherwise converted file formats specific to the engine, which is not an option. Implementing custom formats there seems like a hack ontop of an otherwise unrequired abstraction layer.
It looks like Irrlicht provides more "raw" methods when it comes to implementing custom data formats (like said proprietary ones), and does not annoy with a content pipeline or comparable. Since I'm also focussing to implement code in C#, Irrlicht Lime looks like quite a rare gem in the pile of otherwise overengineered or dead C# engines / libraries.

However, I stumbled upon a small problem. I'm not _exactly_ sure how I'd implement loading the custom model format.
I read that in C++, I should implement my own IMeshLoader, but this interface doesn't exist in Irrlicht Lime, only a concrete MeshLoader class from which I apparently can't inherit.
Another way looked like I should set up an SMeshBuffer instance with the vertices and triangles.
What of the two would be the recommended way?

How would implementing a custom texture format look like? Is it possible to create raw byte array and tell the engine how to interprete pixels out of it?

Thanks for any guidance help in advance.
Ray Koopa
Posts: 1
Joined: Mon Aug 28, 2017 2:41 pm

Re: Using the engine to display other game's data

Postby CuteAlien » Mon Aug 28, 2017 3:46 pm

Irrlicht has a few levels of abstraction.

The lowest one is the IVideoDriver which basically a unifying wrapper around opengl / DirectX. Especially IVideoDriver::drawIndexedTriangleList is basically the command which is used in the end to send 3d geometry data to the graphic card. So ignoring all Irrlicht structures you could use in theory:
And that would allow you to draw geometry with materials at certain places.

The next layer above that is IVideoDriver::drawMeshBuffer which handles a few things:
Each meshbuffer has a material+geometry so - Irrlicht can send those for you.
Meshbuffers can be made static - in which case vertex buffer objects are created on the graphic-card so the geometry no longer must be send each frame, but only once.
You can create MeshBuffers in several ways - SMeshBuffer is one of them (and the most common one).

Next layer above meshbuffers would be meshes. They are usually an array of meshbuffers (because most models have more than just one material so they need several meshbuffers). But they can also be more complicated and for example calculate the current meshes through some animation parameters and stuff.
A pretty simple one is SMesh which is usually sufficient when you just have static meshes. If you have skin (bone) - animations you will likely need ISkinnedMesh. For others you might create your own. What they have in common is that they are derived from IMesh or IAnimatedMesh or ISkinnedMesh. Which in the end all have a function to return the meshbuffers for the current frame.
Those mesh-formats are created by meshloaders. You don't have to derive from a meshloader interface to create them. Using registered meshloaders has just the advantage that you can load meshes with ISceneManager::getMesh. But you can create them with any code you like.
Also you don't really _need_ meshes - they just make some things easier - especially on the next abstractionn level.

Next on is SceneNode's. Those are used for rendering a scenegraph. SceneNode's are mainly objects which have some position in the 3D World. There are scenenodes which work with the different mesh-formats (so you can think of nodes as instances of the meshes). But you can also create your own SceneNodes which can draw things in any way you like by calling any of the VideoDriver functions directly in their draw() function. So if you want SceneNodes which work without meshbuffers - that's also possible.

So how to start: Using SMesh and SMeshBuffer is a good start for static meshes. As Irrlicht has useful functions to draw those and use them in a SceneGraph. So basically - split your geometry up so that you have one material per geometry object. Put those in a meshbuffer. Then put all your meshbuffers in a mesh. At that point you can draw them directly with the videodriver - or create a MeshSceneNode (with SceneManager) and draw them with the SceneManager.
IRC: #irrlicht on
Code snippets, patches&stuff:
Free racer created with Irrlicht:
User avatar
Posts: 8468
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Return to Beginners Help

Who is online

Users browsing this forum: No registered users and 1 guest