The FPS and the Maya cameras are kinda useful for debugging, but not particularly good as game cameras, so I want to make my own. Thing is, I want to do it with as little editing of the Irrlicht files as possible, preferably no editing at all. Every solution I think of is causing problems though, and I wonder if I'm just approaching the Irrlicht API in the wrong way.
The first idea was to create my cGameCamera class, and have it contain an ICameraSceneNode*, to wrap up the Irrlicht stuff.
Code: Select all
// This is just example code to show what I mean
class cGameCamera
{
public:
ICameraSceneNode* mpMyCamNode;
void Init()
{
mpMyCamNode = scenemgr->createCameraSceneNode(blah);
}
void Update()
{
// Get user input
// Do some maths to generate new position and lookat coordinates
// Apply the position/lookat/whatever to mpMyCamNode
}
};The next thing I tried was to have cGameCamera derive from ICameraSceneNode. This turned out to be pretty wasteful because I would have to re-implement most of CCameraSceneNode, and copy/pasting chunks of code is never, ever a good idea.
So I decided to have it derive straight from CCameraSceneNode, and only change the bits I need to, which basically means just filling out the OnEvent function. This approach makes a mockery of Irrlicht having interfaces at all, and just felt wrong. I had to add new include paths just so my code could find CCameraSceneNode.h. Furthermore, in order to create my camera this way, I'd have to change the scene manager to give it a new function called something like createCameraSceneNodeNewGameCam(), and I don't want to change Irrlicht if I there is any way of avoiding it.
So, what's the best way for me to do this? I would rather have my camera class wrap an ICameraSceneNode* than derive from one, but I can't get input events. And if the only way is for me to derive from ICameraSceneNode or from CCameraSceneNode, how can I create my camera when the game initialise without changing the scene manager to add a new function?
