// Overrides
int 
TestGLApp::Initialize()
{
	GLClearErrors();

	MappedProperties::GetInstance().initialize(".\\data\\test.txt");

	BaseGLApp::Initialize();
	BaseGLApp::SetWindowProperties("OpenGL rendering framework");

	SetupScene();
	GfxStats::Instance().initialize();
	GfxStats::Instance().addStat("objectRender");
	GfxStats::Instance().addStat("frameTime");
	GfxStats::Instance().addStat("textRender");
	GfxStats::Instance().addStat("updateStats");
	GfxStats::Instance().addStat("updateTechnique");

	//UIManager::Instance().init(Core::Window);

	GLErrorCheck("TestGLApp::Initialize");

	// Success
	return 1;
}
Ejemplo n.º 2
0
 bool ReliefApp::Enter(void)
 {
     InfoLog << "Enter ReliefApp" << std::endl;
     mUI.Setup();
     SetupScene();
     return true;
 }
Ejemplo n.º 3
0
bool FaceFeatureRecognitionApp::Enter(void)
{
    InfoLog << "Enter FaceFeatureRecognition" << std::endl;
    mUI.Setup();
    SetupScene();

    return true;
}
Ejemplo n.º 4
0
bool PointShopApp::Enter(void)
{
    InfoLog << "Enter PointShopApp" << std::endl;
    mUI.Setup();
    SetupScene();
    ModelViewer();

    return true;
}
Ejemplo n.º 5
0
bool Engine::CWorld::Reload()
{
	if (!CheckReloadFileExist())
	{
		return false;
	}

	std::ifstream fileBuffer("./data/ReloadFile.reload", std::ifstream::in);
	std::stringstream sData;

	sData << fileBuffer.rdbuf();

	fileBuffer.close();

	if (sData.str().size() == 0)
	{
		return false;
	}

	int zStartOffset = 0;
	int zEndOffset = 0;

	std::vector<std::string> vsReloadFiles;

	while (sData.str().find('\n', zStartOffset) != std::string::npos)
	{
		zEndOffset = sData.str().find('\n', zStartOffset);

		vsReloadFiles.push_back(sData.str().substr(zStartOffset, zEndOffset - zStartOffset));

		zStartOffset = zEndOffset + 1;
	}

	for (size_t zIndex = 0; zIndex < vsReloadFiles.size(); ++zIndex)
	{
		if (vsReloadFiles[zIndex].find(".scene") != std::string::npos)
		{
			GetSceneFiles();

			if (GetSceneFileIndexByPath(vsReloadFiles[zIndex].c_str()) == m_zCurrentScene)
			{
				SetupScene(vsReloadFiles[zIndex].c_str());
			}
		}
	}

	FILE* pFile;

	pFile = fopen("./data/ReloadFile.reload", "w");

	fclose(pFile);

	return true;
}
Ejemplo n.º 6
0
bool Engine::CWorld::SetupScene(const char* i_cpScenePath)
{
	int zScene = GetSceneFileIndexByPath(i_cpScenePath);

	if (zScene == -1)
	{
		return false;
	}

	return SetupScene(zScene);
}
Ejemplo n.º 7
0
 bool DepthVideoApp::Enter(void)
 {
     InfoLog << "Enter DepthVideoApp" << std::endl; 
     if (mpUI == NULL)
     {
         mpUI = new DepthVideoAppUI;
     }
     mpUI->Setup();
     SetupScene();
     return true;
 }
Ejemplo n.º 8
0
 bool Homepage::Enter()
 {
     InfoLog << "Enter Homepage" << std::endl;
     if (mpUI == NULL)
     {
         mpUI = new HomepageUI;
     }
     mpUI->Setup();
     SetupScene();
     UpdateModelRendering();
     return true;
 }
Ejemplo n.º 9
0
int main (int argc, char * argv[]){
  backBuffer = new ColorFloat[640*480];
  // allocate the ray direction lookup table
  Vector *directionTable = GenerateRayDirectionTable();

  const int numPrimitives = 1;
  Primitive *primitives = new Primitive[numPrimitives];
  
  const int numLightSources = 1;
  LightSource *lightSources = new LightSource[numLightSources];

  const int numVertices = 4;

  Vector *vertices = new Vector[numVertices];
  Scene(primitives, numPrimitives, vertices, numVertices, lightSources, numLightSources);
  
  SetupScene(primitives, numPrimitives, vertices, numVertices, lightSources, numLightSources);

  TraceScene(primitives, numPrimitives, lightSources, numLightSources, backBuffer, directionTable);

  /*alboroto para opengl*/
  glutInit(&argc, argv);  
  glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);  
  glutInitWindowSize(width, height);  
  glutInitWindowPosition(initx, inity);  
  window = glutCreateWindow("final");
  glutDisplayFunc(&DrawGLScene);  
  glutIdleFunc(&DrawGLScene);
  glutKeyboardFunc(&keyPressed);
  InitGL(width, height);

  /*  float * a = new float[3];
      glGetFloatv(GL_CURRENT_RASTER_POSITION,a);
      printf("x=%f y=%f z=%f\n",a[0],a[1],a[2]);*/
  glutMainLoop();
  /*fin alboroto de opengl*/

  // clean up
  for(int i=0; i<numPrimitives; i++) ClearPrimitiveType(primitives[i]);    
  delete[] lightSources;
  delete[] vertices;
  delete[] directionTable;
  delete[] backBuffer;
  return 0;
}
Ejemplo n.º 10
0
void CTestGame::Initialize(Engine::IMainLoop *pMainLoop)
{
	// Base
	CApplication::Initialize(pMainLoop);

	// Cache the back buffer pointer
	back_buffer = gEnv->Renderer->GetRenderTarget(0);

	// Create render textures for G-Buffer
	SSurfaceDesc sdesc = *back_buffer->GetSurfaceParams();;
	sdesc.Type = SFC_RENDERTARGET;

	sdesc.Format = FMT_R32F;
	gEnv->SurfaceManager->CreateNewTexture(sdesc, gbuf_depth.wrapped());
	gbuf_depth->AddUser();

	sdesc.Format = FMT_A2R10G10B10;
	gEnv->SurfaceManager->CreateNewTexture(sdesc, gbuf_normal.wrapped());
	gbuf_normal->AddUser();

	// Create light accumulation buffer
	sdesc.Format = FMT_A16B16G16R16F;
	gEnv->SurfaceManager->CreateNewTexture(sdesc, acc_lighting.wrapped());
	acc_lighting->AddUser();


	// Create material for light accumulation
	IEffect* pEffect; SMaterialBindings* bindings;
	gEnv->EffectManager->FindOrLoadEffect(Utils::URL("acc_uberlight.fxd"), &pEffect);
	gEnv->MaterialManager->CreateMaterial(mat_accumulation.wrapped());
	bindings = mat_accumulation->GetBindings();
	bindings->addTextureBinding(FXP_TEXTURE_DEPTH, gbuf_depth);
	bindings->addTextureBinding(FXP_TEXTURE_NORMAL, gbuf_normal);
	mat_accumulation->SetEffect(0, pEffect);
	pEffect->Release();
	pEffect = 0;

	mat_accumulation->AddUser();

	SetupScene();
}
Ejemplo n.º 11
0
void Simulation::Initialize() {

	if(settings_.sys_error_on_)
	{//random systematic errors
		settings_.robParameter_.kDistanceLeftWheel += 	locaUtil::randomGaussian()*settings_.robParameter_.kLeftWheelWidth*0.1;
		//std::cout<<"leftWidth: "<<settings_.robParameter_.kDistanceLeftWheel-0.35<<std::endl;
		settings_.robParameter_.kDistanceRightWheel+= 	locaUtil::randomGaussian()*settings_.robParameter_.kRightWheelWidth*0.1;
		//std::cout<<"RightWidth: "<<settings_.robParameter_.kDistanceRightWheel-0.35<<std::endl;
		settings_.robParameter_.kRadiusWheelLeft += settings_.robParameter_.kRadiusWheelLeft*0.001*locaUtil::randomGaussian();
		settings_.robParameter_.kRadiusWheelRight += settings_.robParameter_.kRadiusWheelRight*0.001*locaUtil::randomGaussian();
	}

	{//apply settings_
		data_to_file_writer_.path_ 			= settings_.picture_path_;
		data_to_file_writer_.datafile_path_ = settings_.datafile_name_;
		data_to_file_writer_.plotfile_path_ = settings_.plotfile_;
		data_to_file_writer_.Header();
		takepicture_intervall_				= (1000*settings_.takepicture_intervall_)/settings_.loop_target_time_;
		loop_target_time_					= settings_.loop_target_time_;
		croud_size_							= settings_.crowd_size_;
		particle_visibility_ratio_			= settings_.particle_visibility_ratio_;
		camera_picture_width_				= settings_.camera_picture_width_;
		camera_picture_height_				= settings_.camera_picture_height_;
		field_of_view_horizontal_			= settings_.field_of_view_horizontal_;
		blind_mode_on_						= settings_.blind_mode_on_;
	}

	osgGA::TrackballManipulator* cam_on_rob_mani = new osgGA::TrackballManipulator;
	root_ = SetupScene();
	robot_ = SetupRobot(cam_on_rob_mani, settings_.robParameter_);
	root_->addChild(robot_);
	root_->addChild(hud_.getGroup());
	screen_shot_callback_ = new ScreenShotCallback();
	root_->addUpdateCallback(new Particles::ParticleNodeCallback());
	osgViewer::View* view_robot = new osgViewer::View;
	osgViewer::View* view_map = new osgViewer::View;
	osgViewer::View* view_camera_on_robot = new osgViewer::View;
	//std::cout<<"ThreadingModelbefore: "<<viewer_.getThreadingModel()<<std::endl;
	viewer_.setThreadingModel((osgViewer::ViewerBase::ThreadingModel) 0);
	//std::cout<<"ThreadingModelafter: "<<viewer_.getThreadingModel()<<std::endl;
	viewer_.setUpThreading();

	viewer_.addView(view_camera_on_robot);
	if(!blind_mode_on_){
		viewer_.addView(view_robot);
		viewer_.addView(view_map);
	}


	{//light
		mylightsource = new osg::LightSource();
		osg::Light *mylight = new osg::Light();
		mylight->setLightNum(0);
		mylightsource->setLight(mylight);
		root_->addChild(mylightsource);
		mylightsource->setStateSetModes(*root_->getOrCreateStateSet(), osg::StateAttribute::ON);
		mylight->setAmbient(osg::Vec4d(0.0, 0.0, 0.0, 1.0));
		mylight->setDiffuse(osg::Vec4d(1.0, 1.0, 1.0, 1.0));
		mylight->setPosition(osg::Vec4d(0.0, 0.0, 10.0, 1.0));
	}

	//Seed human doubles into the simulation.
	AddCrowd(root_, croud_size_);


	if(particles_on_){
		particle_view_ = new Particles();
		particle_view_->Populate(localisation_->param.nrOfParticles/particle_visibility_ratio_);
		localisation_->createSamples(localisation_->param.nrOfParticles);

		std::vector<int> landmark_IDs;
		switch (observe_mode_){
		case Landmarks:
			// Setup visualisation of landmarks.
			landmark_IDs = landmarks_.getIDVector();
			for(std::vector<int>::iterator it = landmark_IDs.begin();it != landmark_IDs.end();it++){
				osg::PositionAttitudeTransform* landmark_view = new osg::PositionAttitudeTransform();
				landmark_view->addChild(locaUtil::pyramid());
				landmark_view->setScale(osg::Vec3d(0.1,0.1,0.1));
				landmark_view->setPosition( osg::Vec3d(landmarks_.getXofID(*it),landmarks_.getYofID(*it),0.0) );
				root_->addChild(landmark_view);
			}
			break;

		case OneParticle:
			particle_view_->Populate(1);
			localisation_->createOneParticle();
			break;
		default:
			break;
		}
		particle_view_->Update(localisation_->getParticles(), particle_visibility_ratio_);
		particle_view_->AddToThis(root_);

	}

	if(pad_control_on_)
		sixaxes_ = new cJoystick();

	if(!blind_mode_on_){
		if( (!pad_control_on_) || (!sixaxes_->isActiv()) ){
			KeyboardEventHandler* robotControlHandler;
			robotControlHandler = new KeyboardEventHandler((RobotData*)robot_->getUserData());
			view_robot->addEventHandler(robotControlHandler);
			pad_control_on_ = false;
		}


		{//Setup view from behind the robot
			view_robot->setSceneData(root_);
			view_robot->setUpViewInWindow(10,10,800,600);
			osg::ref_ptr<osgGA::NodeTrackerManipulator> robot_camera_manipulator = new osgGA::NodeTrackerManipulator;
			robot_camera_manipulator->setHomePosition(osg::Vec3(0, -3, 0), osg::Vec3(0,0,0), osg::Vec3(0,-1.0,0));
			robot_camera_manipulator->setTrackNode(robot_->getChild(0));
			robot_camera_manipulator->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER_AND_ROTATION);
			view_robot->setCameraManipulator(robot_camera_manipulator);
			//view_robot->getCamera()->setFinalDrawCallback(screen_shot_callback_);
		}

		{//Setup view strait down on the robot.
			view_map->setSceneData(root_);
			view_map->setUpViewInWindow(820,10,320,320);
			osg::ref_ptr<osgGA::NodeTrackerManipulator> map_camera_manipulator = new osgGA::NodeTrackerManipulator;
			//osg::ref_ptr<osgGA::TrackballManipulator> trackball_mani = new osgGA::TrackballManipulator;
			map_camera_manipulator->setHomePosition(osg::Vec3(0, 0, 23), osg::Vec3(0,0,0), osg::Vec3(0,0,0));
			map_camera_manipulator->setTrackNode(robot_->getChild(0));
			map_camera_manipulator->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER);
			//view_fix->getCameraManipulator()->setHomePosition(osg::Vec3(0, -3, 0), osg::Vec3(0,0,0), osg::Vec3(0,0,0));
			view_map->setCameraManipulator( map_camera_manipulator );
		}
	}

    {//Setup view for the camera on the robot.
    	view_camera_on_robot->setSceneData(root_);
    	osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
    	traits->x = 0;
    	traits->y = 0;
    	traits->width = camera_picture_width_;
    	traits->height = camera_picture_height_;
    	traits->red = 8;
    	traits->green = 8;
    	traits->blue = 8;
    	traits->alpha = 0;
    	traits->depth = 16;
    	traits->windowDecoration = false;
    	traits->pbuffer = true;
    	traits->doubleBuffer = true;
    	traits->sharedContext = 0;
    	osg::ref_ptr<osg::GraphicsContext> pbuffer = osg::GraphicsContext::createGraphicsContext(traits.get());
    	osg::ref_ptr<osg::Camera> camera = view_camera_on_robot->getCamera();
    	camera->setGraphicsContext(pbuffer.get());
    	camera->setViewport(new osg::Viewport(0,0,camera_picture_width_,camera_picture_height_));
    	camera->setClearColor(osg::Vec4(0.0f,0.0f,0.0f,0.0f));
    	camera->setDrawBuffer(GL_BACK);
    	camera->setReadBuffer(GL_BACK);
    	camera->setFinalDrawCallback(screen_shot_callback_);
    	viewer_.getView(0)->getCamera()->setProjectionMatrixAsPerspective(	field_of_view_horizontal_*camera_picture_height_/camera_picture_width_,
    																			(double)camera_picture_width_/(double)camera_picture_height_,
    																			1,
    																			10000);
    	view_camera_on_robot->setCameraManipulator(cam_on_rob_mani);
    }
//	osg::Matrix windowMatrix = viewer_.getView(0)->getCamera()->getViewport()->computeWindowMatrix();
//	osg::Matrix projectionMatrix = viewer_.getView(0)->getCamera()->getProjectionMatrix();
//	osg::Matrix mat = projectionMatrix*windowMatrix;
//	std::cout<<"Intrinsic camera parameter:"<<std::endl;
//	std::cout<<"fx: "<<mat(0,0)<<" fy: "<<mat(1,1)<<" cx:"<<-mat(2,0)<<" cy:"<<-mat(2,1)<<std::endl;
//	std::cout<<std::endl;
	robotdata_ = dynamic_cast<RobotData*> (robot_->getUserData());
}
Ejemplo n.º 12
0
bool Engine::CWorld::Update()
{
	m_pcTimer->Stop();

	float fDeltaTime = m_pcTimer->GetElapsedMilliseconds();

	//Handle Input
	GetInput();

	if (m_pcJustPressedInputBuffer->GetBit(VK_F11))
	{
		int zNewScene = m_zCurrentScene + 1 > m_zScenes - 1 ? 0 : m_zCurrentScene + 1;
		SetupScene(zNewScene);
		return true;
	}

	if (m_pcJustPressedInputBuffer->GetBit(VK_F12))
	{
		Reload();
		return true;
	}

	float fVolumeDelta = 1.0f;

	if (m_pcJustPressedInputBuffer->GetBit(VK_F5))
	{
		eae6320::UserSettings::SetSoundVolumeLevel(eae6320::UserSettings::GetSoundVolumeLevel() - fVolumeDelta);
		m_pcSoundEngine->SetVolume(eae6320::UserSettings::GetSoundVolumeLevel(), m_pcAmbientChannel);
	}

	if (m_pcJustPressedInputBuffer->GetBit(VK_F6))
	{
		eae6320::UserSettings::SetSoundVolumeLevel(eae6320::UserSettings::GetSoundVolumeLevel() + fVolumeDelta);
		m_pcSoundEngine->SetVolume(eae6320::UserSettings::GetSoundVolumeLevel(), m_pcAmbientChannel);
	}

	if (m_pcJustPressedInputBuffer->GetBit(VK_F7))
	{
		m_pcSoundEngine->SetVolume(m_pcSoundEngine->GetVolume(m_pcMusicChannel) - fVolumeDelta, m_pcMusicChannel);
	}

	if (m_pcJustPressedInputBuffer->GetBit(VK_F8))
	{
		m_pcSoundEngine->SetVolume(m_pcSoundEngine->GetVolume(m_pcMusicChannel) + fVolumeDelta, m_pcMusicChannel);
	}

	//Tilde - Change game state - Find better solution
#ifdef _DEBUG
	if (!m_bConnected && m_pcJustPressedInputBuffer->GetBit(VK_OEM_3))
	{
		if (m_cpGameState != nullptr)
		{
			if (strcmp(m_cpGameState, "Game") == 0)
			{
				delete[] m_cpGameState;
				m_cpGameState = nullptr;

				int zLength = strlen("DebugMenu");

				m_cpGameState = CNEW char[zLength + 1];

				strncpy(m_cpGameState, "DebugMenu", zLength);

				m_cpGameState[zLength] = '\0';
			}
			else
			{
				delete[] m_cpGameState;
				m_cpGameState = nullptr;

				int zLength = strlen("Game");

				m_cpGameState = CNEW char[zLength + 1];

				strncpy(m_cpGameState, "Game", zLength);

				m_cpGameState[zLength] = '\0';
			}
		}
Ejemplo n.º 13
0
void StereoRender::Init()
{
    SetupScene();
}
Ejemplo n.º 14
0
int CsGame::Run()
{
	Init();

	
	SetupScene("spawntest");
	
	//mRoot->renderOneFrame();
	// create threads
	
	mLogicThread  = new boost::thread(&CsGame::Logic, this);
	//mInputThread = new boost::thread(&CsGame::InputControl, this);
	mControlThread  = new boost::thread(&CsGame::ThreadControl, this);

	mBulletManager->GetDynamicsWorld()->stepSimulation(0.0);

	mGameLevel->Update();
	mGameLevel->Synchronize();
	mGameLevel->UpdateSceneNodes();


	//terminate the control thread 
	boost::thread::id notAny;
	while (1)  {
		Ogre::WindowEventUtilities::messagePump();

		// if logic thread quits then wait for the reaper
		if ( mLogicThread->get_id() == notAny)  {
				//mControlThread->interrupt();
				mControlThread->join();
				break;
		}

		mInputManager->CaptureInput();
		Render();
		
		// dispatch accumulated messages to the Logic part
		{
			boost::mutex::scoped_lock lock(mLogicQueue.mMutex);
			while (!mLogicTempQueue.empty()) {
				mLogicQueue.push(mLogicTempQueue.front());
				mLogicTempQueue.pop();
			}
		}

	}


	// TODO: termination of threads, exception handling etc
	// TODO: disableInterruption objects in thread functions
	// destroy threads

	delete mControlThread;
	delete mLogicThread;
	//delete mInputThread;

	DestroyScene();

	// ----------------------------------------------------------------------------------------------

	
	//------------------------------------------------------------------------------------------------

	Cleanup();
    return 17;
}