Scene Manager?

May 15, 2013 at 7:14 PM
Hi,
Im kind of new to C++ and this engine (i like beans), so how would i solve the problem of adding an actor to the scene from another class?

Should i make the m_pScene public?
Should i make the Actor public so i can add it from the main class?
Should i create another class to manage this stuff?
May 15, 2013 at 7:24 PM
Edited May 15, 2013 at 7:27 PM
give the "another class" a reference to the scene (through the constructor). Then you can add an actor to the scene from it.

something like this is common:
class AnotherClass {
     AnotherClass(Scene scene) {
           _scene = scene;
     }
}
In the main something like this:
Scene scene = new Scene();
AnotherClass anotherClass = new AnotherClass(scene);
Additional you can ask google -> "what is a factory pattern". Its a nice concept of doing this.

I think this is more a coding question and less a question of the engine.
May 17, 2013 at 5:57 PM
Hi, I'm not sure if using a singleton here is evil?
class SceneMgr
{
    public:
        static Glyph3::Scene* get();


    private:

        SceneMgr() {};                 
        SceneMgr(SceneMgr const&);            
        void operator=(SceneMgr const&);
};
Also, i get this linker error:
App.obj : error LNK2019: unresolved external symbol "public: static class Glyph3::Scene * __cdecl SceneMgr::get(void)" (?get@SceneMgr@@SAPAVScene@Glyph3@@XZ) referenced in function "public: virtual void __thiscall App::Initialize(void)" (?Initialize@App@@UAEXXZ)
Coordinator
May 18, 2013 at 1:51 PM
There isn't a need to make it a singleton, is there? What if you have an application where you want more than one scene? I meant to ask this earlier too - what operations do you want to do with your SceneMgr class? If it is managing a scene, then the methods of the Scene class should already be doing this. Or did you have something else in mind?

That link error looks like you didn't implement the static function - you are calling it but it doesn't appear visible to the App::Initialize method. Can you post that method?