Which classes do I extend?

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
PredaNoob
Posts: 12
Joined: Mon Sep 12, 2011 2:59 pm

Which classes do I extend?

Post by PredaNoob »

This is a bit of a newbie question, but if for example, I want to extend the scene manager, and add a function; do I extend my class (inherit) from ISceneManager or CSceneManager?

Because I'm trying this in MySceneManager.h:

Code: Select all

#include <CSceneManager.h>
 
class RTSSceneManager : public CSceneManager
{
        virtual ICameraSceneNode* addCameraSceneNodeRTS(ISceneNode* parent = 0,
                        const core::vector3df& position = core::vector3df(0,0,0),
                        const core::vector3df& lookat = core::vector3df(0,0,100),
                        s32 id=-1, bool makeActive=true) = 0;
};
 
and it's giving me this error
fatal error C1083: Cannot open include file: 'CSceneManager.h': No such file or directory
It works if I use ISceneManager instead of CSceneManager, but then won't I have to re implement CSceneManager over again?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Which classes do I extend?

Post by hybrid »

Yes, there's no way to alter the scene manager itself except for changing the files directly and recompile Irrlicht. But you simply don't need to add this function to the scene manager. Just call new MyCameraSceneNodeRTS or whatever your class is called and the rest happens correctly. Just make sure that you add a parent in each call, there's no way to automatically fill in the scene manager in this case
PredaNoob
Posts: 12
Joined: Mon Sep 12, 2011 2:59 pm

Re: Which classes do I extend?

Post by PredaNoob »

I see. In that case I'll just make MyCameraSceneNodeRTS add a regular CameraSceneNode to the scene manager and make it listen to key events then alter the CameraSceneNode's position, rotation. (or is that the wrong way to do it?)

Thank you for your help!
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Which classes do I extend?

Post by CuteAlien »

You can maybe take a look how Irrlicht implements cameras. There is only one camera-class and the control is done with animators derived from ISceneNodeAnimator.
And those animators can overload isEventReceiverEnabled and return true in it to receive events.
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
PredaNoob
Posts: 12
Joined: Mon Sep 12, 2011 2:59 pm

Re: Which classes do I extend?

Post by PredaNoob »

Thank you for the tip! I followed your advice and got the camera up and running like I want. :)
Post Reply