[2.1] Noob questions about scene nodes Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
Zemtriz
Gnoblar
Posts: 9
Joined: Fri Jul 13, 2018 8:17 pm

[2.1] Noob questions about scene nodes

Post by Zemtriz »

Ogre Version: 2.1
Operating System: Win10
Render System: OGL3+

Hello There,

I need to ask some noob questions as I want to understand it right.
I've got working EmptyScene and added there a cube to render as it is from another tutorials.
Here are steps how I added the cube:
Defined mSceneNode in EmptyProjectGamestate.h right below generateDebugText
Ogre::SceneNode *mSceneNode;
Added mSceneNode(0) in EmptyProjectGameState.cpp right after TutorialGameState( helpDescription ) inside this function:

Code: Select all

	EmptyProjectGameState::EmptyProjectGameState( const Ogre::String &helpDescription ) :
		TutorialGameState( helpDescription ),
		mSceneNode(0)
	{
    }
And added a cube:

Code: Select all

	void EmptyProjectGameState::createScene01(void)
    {
        mCameraController = new CameraController( mGraphicsSystem, false );

		Ogre::SceneManager *sceneManager = mGraphicsSystem->getSceneManager();

		Ogre::Item *item = sceneManager->createItem("Cube_d.mesh",
													Ogre::ResourceGroupManager::
													AUTODETECT_RESOURCE_GROUP_NAME,
													Ogre::SCENE_DYNAMIC);

		mSceneNode = sceneManager->getRootSceneNode(Ogre::SCENE_DYNAMIC)->
			createChildSceneNode(Ogre::SCENE_DYNAMIC);

		mSceneNode->attachObject(item);

        TutorialGameState::createScene01();
    }
Questions are:
Why do I need to add mSceneNode(0) in the beginning when it is defined in EmptyProjectGameState.h ?
If I will remove it from the EmptyProjectGameState.h then I can directly call it and the only edit will be in CreateScene01 so it will look like this:

Code: Select all

	void EmptyProjectGameState::createScene01(void)
    {
        mCameraController = new CameraController( mGraphicsSystem, false );

		Ogre::SceneManager *sceneManager = mGraphicsSystem->getSceneManager();

		Ogre::Item *item = sceneManager->createItem("Cube_d.mesh",
													Ogre::ResourceGroupManager::
													AUTODETECT_RESOURCE_GROUP_NAME,
													Ogre::SCENE_DYNAMIC);

		Ogre::SceneNode *mSceneNode = sceneManager->getRootSceneNode(Ogre::SCENE_DYNAMIC)->createChildSceneNode(Ogre::SCENE_DYNAMIC);

		mSceneNode->attachObject(item);

        TutorialGameState::createScene01();
    }
and it will work.

Is "mCameraController = new CameraController( mGraphicsSystem, false );" used for mouse movements?
Why we don't need to define root? "Ogre::Root *root = mGraphicsSystem->getRoot();"
Here "Ogre::SceneManager *sceneManager = mGraphicsSystem->getSceneManager();" we create a new scene node which belongs to root node, right?
Next to our newly created scene node we attach an object: "mSceneNode->attachObject(item);"
Then createScene01 is called to display everything up?

Why there is no destroySystems in EmptyProject.cpp ? Is destroySystems called when application is being closed also by cross button?

I'm really sorry for these types of questions and thank you very much for your effort help and tips.
Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 614
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 25

Re: [2.1] Noob questions about scene nodes

Post by Slicky »

Why do I need to add mSceneNode(0)
mSceneNode(0) is just initialising it to nothing. Current practice is to do mSceneNode(nullptr). Basically the same but a bit better.
Is "mCameraController = new CameraController( mGraphicsSystem, false );" used for mouse movements?
Yes this should provide camera rotation with the mouse and also from the keyboard. I don't remember if the keyboard automatically works,
Why we don't need to define root? "Ogre::Root *root = mGraphicsSystem->getRoot();"
That is not defining root. You are getting a pointer to root which then probably gets used to call a function available in root.
Here "Ogre::SceneManager *sceneManager = mGraphicsSystem->getSceneManager();" we create a new scene node which belongs to root node, right?
Yes I believe that is correct
Then createScene01 is called to display everything up?
Yes this is where you would add your items to the first scene.
Why there is no destroySystems in EmptyProject.cpp ?
I haven't looked at code for any of these answers but I am guessing that the clean up might be done in a base class lower than the class you are looking at.
Zemtriz
Gnoblar
Posts: 9
Joined: Fri Jul 13, 2018 8:17 pm

Re: [2.1] Noob questions about scene nodes

Post by Zemtriz »

Thank you very much Slicky
Post Reply