How to manage the Frame Listener

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
giogix2
Gnoblar
Posts: 9
Joined: Sat May 23, 2015 6:58 pm
x 3

How to manage the Frame Listener

Post by giogix2 »

Hi,
A few months ago i built an application with Ogre 3d 1.9 with other guys. This is the link to the github page https://github.com/giogix2/PlanetGenerator.
We had no experience with Ogre 3d, so the code is pretty messy.
I am now doing some code restyling, in particular I'm struggling with the Frame Listener.

In the application there are the following 3 classes: initOgre, PSphere and GeneratorFrameListener.
  • PSphere: The main class which represent the Planet (the main entity)
  • GeneratorFrameListener: Class which manage the Frame Listener (keyboard/mouse inpunt, camera movements, etc.). This class has been adapted using the exampleFrameListener.h file, contained in OGRE_FOLDER/include/Ogre.
  • initOgre: This class manage the initialization of the scene in Ogre. Moreover it creates both the PSphere and GeneratorFrameListener objects. More precisely it creates the planet (that is the PSphere object) and it pass the PSphere object directly to the GeneratorFrameListener object.
I know that the class initOgre is totally useless, in fact in these days what I'm trying to remove it and move all the content to a function (still called initOgre) inside of the PSphere class.

My question are:
  • Is it a good practice to create a class to manage the Frame Listener? Or is it better to integrate the Frame Listener in the entity class, as it is done the the application in the basic Tutorial (http://www.ogre3d.org/tikiwiki/tiki-ind ... =Tutorials). Anyway I've noticed that in the book Ogre 3D 1.7 - Beginner's programming, they create a class (still ExampleFrameListener) just to manage the Frame Listener.
  • If you answer yes to the previous question, do you think that it's a good practice to pass the PSphere object (which represents the entity attached to the main node) to the GeneratorFrameListener object? Notice that I'm not passing only the node to which the object is attached, but the object itself (because I can better manage the sub-nodes)
  • If I integrate the Frame Listener in the PSphere class, and then I need to create many PSphere objects, I have many frame listeners which is bad rigth? (I read this in other posts)
I want to do things properly, because otherwise in the future it could become impossible to fix things.
Please let me know
Thanks
Post Reply