New to Irrlicht... Need help with XML defined objects

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.
Post Reply
primem0ver
Posts: 57
Joined: Sat Oct 11, 2014 11:07 pm

New to Irrlicht... Need help with XML defined objects

Post by primem0ver »

I have run into an interesting problem where the engine seems at odds with the design of my project. Apparently everything in this engine is done through interfaces.

Since my project is so general and dynamic in nature, I need to be able to define almost everything through XML. Meshes, Shapes, Objects, Cameras, Lights, and even non-HTML named colors will be created using xml definitions. The problem is that EVERYTHING in this engine seems to be an interface. After looking around some, I can't find any code where the interfaces are actually implemented. I want to be able to create these objects independent of a scene at load time and there doesn't seem to be a way to do that.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: New to Irrlicht... Need help with XML defined objects

Post by CuteAlien »

The interfaces are implemented internally - you can see the implementations in source/Irrlicht if you look at the source-code.
But you don't them for that. You can create an objects using interfaces - sometimes even in more than one way. SceneNodes, cameras and lights are created via ISceneManager (all the add functions), while gui-elements are created via IGUIEnvironment (again with the add functions). You could also work with factories, but for this case it would only complicate matters. Meshes - depends on what you need. You can create them with ISceneManager if you load them from file or you can custom create them yourself (those have the implementation Interfaces you search for available).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
primem0ver
Posts: 57
Joined: Sat Oct 11, 2014 11:07 pm

Re: New to Irrlicht... Need help with XML defined objects

Post by primem0ver »

I thought of using the scene manager. But that seems like a waste because I would essentially be adding each object parsed in xml to the scene and then removing it just for the sake of having an object to store. Isn't there a better way?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: New to Irrlicht... Need help with XML defined objects

Post by CuteAlien »

Yeah, creating objects is not separate from adding to the scene. So in such cases it's often necesary to call add, then grab() it yourself and then remove() from the scene. You could create a second scenemanager if you want (ISceneManager has some function to create another one). Then it won't conflict with your scene and it doesn't matter if you add/remove stuff, but not sure if that is better. For gui it's even more tricky as no additional IGUIEnvironment's can be created.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply