In my attempt to create my first 3D game using Ogre I started writing a general “Object” class.
The constructor:
Object( const char* mesh, Ogre::SceneManager*& sm )
{
...
_sn = sm->getRootSceneNode()->createChildSceneNode( _sn_name );
_ent = sm->createEntity( _ent_name, mesh );
_sn->attachObject(_ent);
...
}
_sn being a SceneNode* and _ent an Entity* (both private).
The problem is that nothing gets drawn to the screen!
But if I use:
Ogre::Entity *map = mSceneMgr->createEntity("map","map.mesh");
Ogre::SceneNode *sc = mSceneMgr->getRootSceneNode()->createChildSceneNode("mapNode");
sc->attachObject(map);
outside of a class, the object gets drawn and everything works.
What’s wrong with my approach and how can I fix it?
Managed to fix this.
In my destructor I had the scene manager call detachAllObjects(). Commenting/removing that solved the problem obviously