I tried today to implement some very simple LOD feature. Of course I searched the web before I tried to reinvent the wheel, but I didn't found what I searched for so I decided to write it by myself. It was more an exercise for me than something like a real feature.
Actually, I didn't want to write much stuff from scratch... that's why I use Irrlicht. And I actually like this engine. There's much love in it . But sometimes I'm very frustrated when I intend to implement new stuff.
Like so many people before, I wanted to do some kind of solar system. Now, when I get really far, planets become small and I don't see any reason to render them at full quality. Till now I used a simple call to ISceneManager::addSphereSceneNode().
So this is what I basically tried:
I knew that I had to inherit from ISceneNode, so I did that. I implemented the required stuff and compiled. Unfortunately ISceneNode has no default constructor. And there's nothing like a ISphereSceneNode. How can I profit from the ISceneManager factory then? ISceneNode has a copy constructor... suddenly I had that genius idea:
Code: Select all
class PlanetSceneNode : public ISceneNode
{
PlanetSceneNode::PlanetSceneNode (ISceneManager* Scene, f32 Radius)
: ISceneNode(*Scene->addSphereSceneNode(Radius,16))
{
}
virtual ~PlanetSceneNode () {
UNDEFINED_DTOR_WARNING;
}
virtual void render() {
this->render();
}
virtual const aabbox3d<f32>& getBoundingBox() const {
return this->getBoundingBox();
}
};
So each time I think that I've finally found the 'right design' for my class, I get another afterthought why it possibly cannot work. For example, I thought then, OK, whatever, I'll create a few instances with ISceneManager::addSphereSceneNode(), store them in my own class and switch between on render() calls and so on. But this means big overhead, and I would have to inherit from ISceneNode and implement ALL virtual functions anyways. This is would be so much unneeded code.
Very frustrating. It seems that it's a pain in the *** to build UPON existing features of Irrlicht. I would have to modify the engine each time (if I don't want to rewrite big parts of it) and recompile it. But this is utterly nonsense.
It's not the problem for me to actually do the LOD stuff - I would surely get it done somehow. But I'm rather speaking about the problem of building upon Irrlicht without the need of modifying the engine itself. I don't like to change the engine code, I have a bad feeling about it.
So, please help me.
What am I doing wrong here?
What is the 'correct' way to do it?
Thanks for reading!