Deriving from Irrlicht implementations:

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
cubicool
Posts: 10
Joined: Sun Jan 29, 2006 7:15 pm

Deriving from Irrlicht implementations:

Post by cubicool »

I just had a quick question about style. Let's say I want to write a custom Camera scene node, Foobar. Obviously I can't do:

Code: Select all

class Foobar : public scene::ICameraSceneNode {
// ...stuff...
};
...without also defining every pure virtual function (which is just impractical). What I'd like to do then instead is to derive from the CCameraSceneNode class, which makes much more sense. However, in a standard Irrlicht setup, the headers necessary to do that aren't in the standard include directory--unless I'm missing something.

Of course, there are a number of workarounds for this, and I'm just curious what other people do. I thought about creating a directory called "Irrlicht/class", where I'll put the implementation headers, with their include directories modified accordingly. Then, I'll be able to have code like:

Code: Select all

// I've setup Irrlicht as a standard Linux shared library,
// with it's own space in $(PREFIX)/include
include <Irrlicht/class/CCameraSceneNode.h>

class Foobar : public scene::CCameraSceneNode {
// ...stuff...
};
Is there better way? I want to build my own engine on top of Irrlicht w/out having to modify the distributed Irrlicht as much as possible, so that, for the most part, newer versions of Irrlicht can simply "fall into place" without having to maintain a crap-ton of patches for every version.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

I think you're supposed to add your code and recompile the engine, but i'm also a pussy when it comes to messing with the engine. Instead I just make a copy of CWhateverSceneNode.cpp/h and stick it with my project, this works with minimal changes most of the time, but gets a bit awkward when there's several files intermingled. Ugly and sometimes messy but at least I don't need to worry about updates to the engine.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

Why re-invent the wheel? You can just make a class that contains a CameraSceneNode and supports your methods for how it should behave. If you want a camera controller, no need to reuse the node implementation.
Guest

Post by Guest »

I had the same question... I'm not sure if I understand your solution, pfo. Do you mean something like this?

class viewcam
{
viewcam(ISceneNode* parent,ISceneManager* smgr,s32 id,
const core::vector3df& position=core::vector3df(0,0,0),
const core::vector3df& rotation=core::vector3df(0,0,0)) : camera(parent,smgr,id,position,rotation,scale){
}

~viewcam(){camera->drop();}
...stuff...
private:
ICameraSceneNode* camera;
}

Wouldn't I then be unable to access the private members of camera?

Sorry for the newbieness, I don't know much C++.
xterminhate
Posts: 206
Joined: Thu Sep 01, 2005 9:26 pm
Location: France

Post by xterminhate »

Extract the .h/.cpp you need from Irrlicht source archive and compile your project with them. That's all.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
Post Reply