Sto cercando di svolgere alcuni esercizi di base con OGRE. Quello di cui posto prevede la simulazione di un gruppo di mosche in volo, effettuata scrivendo il relativo codice all'interno della classe Fly; il problema è che non mi riconosce mosche.begin e mosche.end verso la fine del main, probabilmente perché non riesce a richiamare dove è definito 'mosche'. Deve esserci un errore formale da qualche parte, perché la sostanza funziona, mettendo tutto nel main infatti l'esecuzione è corretta. Come potrei risolvere?

Grazie in anticipo.

Fly.h

codice:
#pragma once



#include "Ogre.h"



class Fly

{

public:

	Fly(Ogre::SceneNode * node, float inc1, float inc2, float inc3);

	virtual ~Fly(void);

	

	void update() ;



	void cs(/*const std::string& dir_name*/) ;



private:

	Ogre::SceneNode * m_pNode ;

	float m_incx ;

	float m_incy ;

	float m_incz ;

};
Fly.cpp

codice:
#include "Fly.h"

#include "OGREStarter.h"

#include "Ogre.h"

#include <cstdlib>	// per il rand()

#include <ctime>		// per il time()

#include <string>

#include <list>



using namespace std;



Fly::Fly(Ogre::SceneNode * node, float inc1,float inc2,float inc3): m_pNode(node), m_incx(inc1),m_incy(inc2),m_incz(inc3)

{	

	

}



Fly::~Fly(void)

{

}



void Fly::cs(/*const std::string& dir_name*/) {

OGREStarter starter;

	starter.addResourceDir("primitives");



	Ogre::SceneManager * scene_manager = starter.getSceneManager() ;

	Ogre::SceneNode * root = scene_manager->getRootSceneNode() ;

// Da spostare

	list<Fly> mosche ;



	int n_pyramids = 30 ;

	for(int i=0 ; i<n_pyramids ; i++) {

		Ogre::SceneNode * pyramid_node = scene_manager->createSceneNode() ;

		// Il nome lo componiamo concatenando una stringa ed un numero

		// ATT!!! Non posso sommare direttamente un numero, devo convertirlo in stringa

		string entity_name = "mosca_" + Ogre::StringConverter::toString(i) ;

		Ogre::Entity * pyramid = scene_manager->createEntity(entity_name, "pyramid.mesh") ;

		pyramid_node->attachObject(pyramid) ;

		pyramid_node->setScale(0.2f, 0.2f, 0.2f) ;

		float x = -2 + 4 * (1.0f * rand() / RAND_MAX) ;

		float y = -2 + 4 * (1.0f * rand() / RAND_MAX) ;

		float z = -2 + 4 * (1.0f * rand() / RAND_MAX) ;

		pyramid_node->setPosition(x, y, z) ;

		root->addChild(pyramid_node) ;



		float inc1 = 0.002 + 0.008 * (1.0f * rand() / RAND_MAX) ;

		float inc2 = 0.002 + 0.008 * (1.0f * rand() / RAND_MAX) ;

		float inc3 = 0.002 + 0.008 * (1.0f * rand() / RAND_MAX) ;



		Fly r(pyramid_node, inc1, inc2, inc3) ;

		mosche.push_back(r) ;

	}

}



void Fly::update() {

	const Ogre::Vector3& pos = m_pNode->getPosition() ;

	if (pos.x<-2.2 || pos.x>2.2)

		m_incx=-m_incx;

	if (pos.y<-2.2 || pos.y>2.2)

		m_incy=-m_incy;

	if (pos.z<-2.2 || pos.z>2.2)

		m_incz=-m_incz;

	m_pNode->setPosition(pos.x + m_incx, pos.y + m_incy, pos.z + m_incz) ;

}
Mainmosche.cpp

codice:
#include "Ogre.h"



#include "OGREStarter.h"



#include "Fly.h"



#include <iostream>

#include <cstdlib>	// per il rand()

#include <ctime>		// per il time()



using namespace std ;



int main() {




	OGREStarter starter;

	starter.addResourceDir("primitives");

	if(!starter.start()) {

		return 10 ;

	}

	

	//Ogre::SceneManager * scene_manager = starter.getSceneManager() ;

	//Ogre::SceneNode * root = scene_manager->getRootSceneNode() ;



	srand(time(NULL)) ;





	Fly abc(Ogre::SceneNode * node, float inc1, float inc2, float inc3);

	abc.cs();



	cout << "Starting Render Cycle... " << endl ;



	float y = 0 ;



	while(! starter.getWindow()->isClosed() ) {



		//

		// DO EVERYTHING HERE!!!

		//

		// ...

		//

		for(list<Fly>::iterator it = mosche.begin() ; it != mosche.end() ; it++) {

			it->update() ;

		}



		// render

		starter.update() ;

	}





	cout << "Render Cycle finished." << endl ;



	return 0 ;

}