void BouwplaatsGameClient::init()
{
	dataMan = new DataManager();
	//fire up the networklayer and ask for the groups
	net = new Network(dataMan);
	net->start();


	// fire up an Ogre rendering window. Clearing the first two (of three) params will let us 
	// specify plugins and resources in code instead of via text file
	ogre = new Ogre::Root("", "");

	Ogre::Log* log = Ogre::LogManager::getSingleton().getDefaultLog();

#if defined(_DEBUG)
	//ogre->loadPlugin("RenderSystem_Direct3D9_d");
	ogre->loadPlugin("RenderSystem_GL_d");
#else
	ogre->loadPlugin("RenderSystem_GL");
#endif

	renderSystems = NULL;

	renderSystems = ogre->getAvailableRenderers();
	r_it = renderSystems->begin();
	ogre->setRenderSystem(*r_it);
	ogre->initialise(false);

	// load common plugins
#if defined(_DEBUG)
	//ogre->loadPlugin("Plugin_CgProgramManager_d");		
	ogre->loadPlugin("Plugin_OctreeSceneManager_d");
#else
	//ogre->loadPlugin("Plugin_CgProgramManager");		
	ogre->loadPlugin("Plugin_OctreeSceneManager");
#endif
	// load the basic resource location(s)
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource", "FileSystem", "General");
	//Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource/gui.zip", "Zip", "GUI");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource/GUI", "FileSystem", "GUI");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("meshes", "FileSystem", "Meshes");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource/audio", "FileSystem", "Audio");
#if defined(WIN32)
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("c:\\windows\\fonts", "FileSystem", "GUI");
#endif

	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("GUI");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Meshes");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Audio");

	loadLogin();
}
Example #2
0
login::login(QWidget * parent) : QWidget(parent) {
	ui.setupUi(this);
    loadLogin();
}
void BouwplaatsGameClient::run()
{
	DWORD tFrameStart = 0x0; //in miliseconds
	signed long tFrameX = 0x0;
	float tDelta = 0.0f; //in seconds
	float m_fps = 60.0f;
	tFrameStart = GetTickCount();
	bool b = true;
	bool worldLoaded = false;
	while ((cState = sim->getCurrentState()) != SHUTDOWN) 
	{
		tFrameX = GetTickCount() - tFrameStart;
		tDelta = (float)tFrameX / 1000.0f;
		if (tDelta > 3600) // tDelta > 1 hour
			tDelta = 1.0f / m_fps; //< System tick count has highly likely overflowed, so get approximation
		tFrameStart = GetTickCount();
		m_fps = (int)(1.0f / tDelta);

		handler->capture();
		handler->update(tDelta);
		entityController->update(tDelta);
		gui->update();
		update(tDelta);

		// run the message pump (Eihort)
		Ogre::WindowEventUtilities::messagePump();
		ogre->renderOneFrame();
		
		if (cState == SIMULATION_GOTOTOPDOWNVIEW) 
		{
			handler->changeCameraView(tDelta);			
		}
		else if(cState == SIMULATION_GOFROMTOPDOWNVIEW)
		{
			handler->restoreCameraView(tDelta);
		}
		if(sim->getCurrentState() != cState)
		{
			handler->StateSwitched(cState, sim->getCurrentState());
			switch (sim->getCurrentState()) 
			{
				case STARTUP:
					loadLogin();
					break;
				case LOADING:
					if(!worldLoaded)
					{
						LoadWorld();
						worldLoaded = true;
					}
					sim->requestStateChange(SIMULATION);
					break;
				case SIMULATION_TOPDOWNVIEW:
					//handler->setObject(2, mainSceneMgr->getSceneNode("dixieNode1"));
					//sim->requestStateChange(SIMULATION);
					break;
			}
		}
		else
		{
			switch(cState)
			{
				case SIMULATION_GOTOTOPDOWNVIEW:
					
					break;				
			}
		}

		if(net->isConnected() && b)
		{
			net->Send(GETGROUPS, "", "", NULL);
			b = false;
		}
	}
	net->stop();
	Sleep(200);
}