New camera class trouble.

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
malahaas
Posts: 4
Joined: Mon Jan 14, 2008 9:26 pm
Location: Salem, MA

New camera class trouble.

Post by malahaas »

Hi, I've been trying to write my own camera class but have run into an issue that I am unsure how to resolve.

The real problem I'm having is that OnAnimate isn't being called. I used the FPSCamera as a model since what I'd like to create is similar (Hence referencing OnAnimate).

In order to narrow the list of what could cause the problem in my camera, I decided to copy the source code for CCameraSceneNode and CCameraFPSSceneNode into my own files and try to add an FPS camera like so:

(FPSCamera is my class name for the CCameraFPSSceneNode code)

FPSCamera camera = new FPSCamera(0, smgr, device->getTimer(),
device->getCursorControl(), -1,
100.0f, 300.0f, 0.f,
0, 0, true );

smgr->setActiveCamera(camera)

You'll notice that I pass device->getTimer() into the constructor. I added this because the source for CCameraFPSSceneNode uses os::Timer::getTime(), which I do not have access to. I therefore simply added a member variable pointer to ITimer and set it to device->getTImer(). (this doesn't matter since OnAnimate() isn't getting called anyway).

I've come to the conclusion that the difference between my code and just using the built-in addCameraSceneNodeFPS() is that CSceneManager passes 'this' into parent if none is set. My problem is, I can't pass my pointer to the SceneManager, since it is of type ISceneManager, which does not inherit from ISceneNode, whereas CSceneManager does. Perhaps I am missing something here, but that's the only cause I could come up with for why my camera renders everything fine, but won't move.

Any help would be greatly appreciated. I'd also like to know if ISceneManager not inheriting from ISceneNode was intentional, and if so, was curious as to what the reason was.

Thanks in advance.
malahaas
Posts: 4
Joined: Mon Jan 14, 2008 9:26 pm
Location: Salem, MA

Post by malahaas »

Hi,

I've found that passing smgr->getRootSceneNode() as parent fixes my issues. Strange since that doesnt seem to be the way that the addCamera...() methods work in the CSceneManager class... However, can't complain if it works. I definately love what I've used so far of Irrlicht.

Thanks
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

I've found that passing smgr->getRootSceneNode() as parent fixes my issues. Strange since that doesnt seem to be the way that the addCamera...() methods work in the CSceneManager class
It is exactly the way scene manager works. It adds node to child list of root scene node. Irrlicht than goes through that list once scenemanager->drawAll() is called and calls certain functions in nodes it finds (like OnAnimate()). Thats the way manager keeps track of nodes. If you just create wild node, how can scene manager knows it even exist? Samegoes for GUI environment by the way.
malahaas
Posts: 4
Joined: Mon Jan 14, 2008 9:26 pm
Location: Salem, MA

Post by malahaas »

arras wrote:
I've found that passing smgr->getRootSceneNode() as parent fixes my issues. Strange since that doesnt seem to be the way that the addCamera...() methods work in the CSceneManager class
It is exactly the way scene manager works. It adds node to child list of root scene node. Irrlicht than goes through that list once scenemanager->drawAll() is called and calls certain functions in nodes it finds (like OnAnimate()). Thats the way manager keeps track of nodes. If you just create wild node, how can scene manager knows it even exist? Samegoes for GUI environment by the way.
Thanks for the response. It makes sense, but when I was looking at SceneManager's source code, it passes "this" (itself) which I can't do since ISceneManager doesn't inherit from ISceneNode the way that CSceneManager does. I find that strange is all, and wondered if there was a reason the matching interface didn't inherit the same way.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The scene manager inherits from scene node as well, and that'S the part that is passed via 'this'. So you're supposed to pass getRootSceneNode().
Post Reply