Scene graph

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
joe70
Gnoblar
Posts: 9
Joined: Thu Apr 05, 2018 5:57 pm
x 1

Scene graph

Post by joe70 »

Hi, Ogre developers

I'm checking the next code for create a scene. I don't understand how many nodes and entities there are when go out (when for ends) . I think that overwrites them every time (for each iteration).
I have watched the mesh and blend files and all the col_box(1, 2, 3, 4, 5) and col_suelo have the origin in the same place (0, 0, 0).

Can you help me drawing the scene graph?

kind Regards





// ground, movable object
SceneNode *nodecol = _sceneManager->createSceneNode("Col_Suelo");
Entity *entcol = _sceneManager->createEntity("Col_Suelo", "Col_Suelo.mesh");
entcol->setQueryFlags(STAGE);
nodecol->attachObject(entcol);
nodecol->setVisible(false);
_sceneManager->getRootSceneNode()->addChild(nodecol);

std::stringstream sauxnode, sauxmesh;
string s = "Col_Box";
for (int i=1; i<6; i++) {
sauxnode << s << i; sauxmesh << s << i << ".mesh";
SceneNode *nodebox = _sceneManager->createSceneNode(sauxnode.str());
Entity *entboxcol = _sceneManager->createEntity(sauxnode.str(), sauxmesh.str());
entboxcol->setQueryFlags(STAGE); // Escenario
nodebox->attachObject(entboxcol);
nodebox->setVisible(false);
nodecol->addChild(nodebox);
sauxnode.str(""); sauxmesh.str(""); // Limpiamos el stream
}
longer
Kobold
Posts: 37
Joined: Tue Aug 19, 2014 10:46 am
x 5

Re: Scene graph

Post by longer »

cache them at your class member. so you can overwrites them.

I don't understand your intention too much.
If the following are helpful?

Code: Select all

class A
{
public:
	typedef std::map<std::string, Ogre::Node*> NodeMapType;
	NodeMapType d_NodeMap;

	void youScene()
	{
		for (int i=1; i<6; i++) 
		{
			sauxnode << s << i; sauxmesh << s << i << ".mesh";
			SceneNode *nodebox = _sceneManager->createSceneNode(sauxnode.str());
			Entity *entboxcol = _sceneManager->createEntity(sauxnode.str(), sauxmesh.str());
			entboxcol->setQueryFlags(STAGE); // Escenario
			nodebox->attachObject(entboxcol);
			nodebox->setVisible(false);
			nodecol->addChild(nodebox);
			sauxnode.str(""); sauxmesh.str(""); // Limpiamos el stream

			// cache them
			this->d_NodeMap[sauxnode] = nodebox;
		}
	}
	void overwrites()
	{
		for(NodeMapType::iterator it = this->d_NodeMap.begin();
			it != this->d_NodeMap.end();++it)
		{
			SceneNode* nodebox = it->second;

			// update
			nodebox->setPosition(Ogre::Vector3(1, 1, 1));
		}
	}
};
Post Reply