Esempio n. 1
0
int main (int argc, char** argv)
{
	initializeCamera();
	initializeSound();
	initializeGraphics(argc, argv);
	return 0;
}
Esempio n. 2
0
/**
 * @brief CGLArea::resizeGL
 * @param width
 * @param height
 *
 * Evenement lors du resize de la fenetre openGL
 */
void CGLArea::resizeGL(int _width, int _height)
{
    int side = qMin(_width, _height);
    glViewport((_width - side) / 2, (_height - side) / 2, side, side);

    initializeCamera();

}
Esempio n. 3
0
Renderer::Renderer(Conway* conway)
{
	this->space = conway->space;
	this->settings = conway->settings;
	this->conway = conway;

	initializeGlut();
	initializeGraphics();
	initializeCamera();
	initializePixels();
}
Esempio n. 4
0
HeadUpDisplay::HeadUpDisplay(Player *player) : 
    _player(player)
{
    _node = new osg::Geode;
    _node->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
    
    _node->setUserData(this);
    _node->setUpdateCallback(new HeadUpDisplayUpdateCallback);
    
	initializeCamera();
	initializeSpeedBar();
    initializeTimer();
}
Esempio n. 5
0
bool NaoCamera::initialize() {
  std::cout << "==================================================" << std::endl;
  std::cout << "=            NaoCamera::initialize()             =" << std::endl;
  std::cout << "==================================================" << std::endl;

  std::cout << "=            Initializing TOP camera             =" << std::endl;
  if (initializeCamera(topCameraFd, "/dev/video0", &buffersTop, numBuffersTop, currentBufferTop, 0, false)) {
    LOG_ERROR("Error initializing top camera.");
    return true;
  }
  std::cout << "==================================================" << std::endl;

  std::cout << "=           Initializing BOTTOM camera           =" << std::endl;
  if (initializeCamera(bottomCameraFd, "/dev/video1", &buffersBottom, numBuffersBottom, currentBufferBottom, 1, true)) {
    LOG_ERROR("Error initializing bottom camera.");
    return true;
  }
  std::cout << "==================================================" << std::endl;

  std::cout << "= Starting camera threads ...............";
  // Start the threads to read images
  if (pthread_create(&topCameraThread, NULL, startTopThread, this) < 0) {
    std::cout << " FAILED =" << std::endl;
    LOG_ERROR("Error creating top camera thread.");
    return true;
  }
  if (pthread_create(&bottomCameraThread, NULL, startBottomThread, this) < 0) {
    std::cout << " FAILED =" << std::endl;
    LOG_ERROR("Error creating bottom camera thread.");
    return true;
  }
  std::cout << ".. DONE =" << std::endl;
  std::cout << "==================================================" << std::endl;

  return false;
}
Esempio n. 6
0
/**
 * @brief CGLArea::initializeGL
 *
 * Initialise la fenetre openGL
 */
void CGLArea::initializeGL()
{
    glClearColor(0.0, 0.0, 0.0, 1.0);

    glEnable(GL_DEPTH_TEST);
    glShadeModel(GL_SMOOTH);

    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    glDisable(GL_COLOR_MATERIAL);

    glViewport(0, 0, 400, 400);
    initializeCamera();

}
Esempio n. 7
0
void init() {
	//codes for initialization
	initializeCamera();
	canDrawGrid = true;
	
	//initialize the matrix
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	
	//lighting
	enableLighting();

	//give PERSPECTIVE parameters
	gluPerspective(70,	1,	0.1,	10000.0);
	//field of view in the Y (vertically)
	//aspect ratio that determines the field of view in the X direction (horizontally)
	//near distance
	//far distance
	loadCameraData(); 
	initBitmaps();
}
Esempio n. 8
0
LevelMenu::LevelMenu() :
    _currentLevel(NULL),
    _currentItemIndex(0)
{
	_menuPat = new osg::PositionAttitudeTransform();
	_menuPat->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

    _keyboardHandler = new MenuKeyboardHandler(this);
    viewer.addEventHandler(_keyboardHandler);

	initializeCamera();
    initializeHeader();
    initializeBackgroundAnimation();
    initializeSelector();
    loadLevels();
    updateDetails();
            
    viewer.getCamera()->setUpdateCallback(new LevelMenuUpdater(this));

    Sound::getInstance()->playInLoop(MENU_MUSIC_FILE);    
}
Esempio n. 9
0
Sky::Sky() 
{
	_skyPat = new osg::PositionAttitudeTransform();
	_skyPat->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

	initializeCamera();
	
	osg::Geode* geode = new osg::Geode();
    osg::Geometry *geometry = new osg::Geometry();
    geode->addDrawable(geometry);
    
    osg::Vec3Array *vertices = new osg::Vec3Array;

    int screenWidth = viewer.getCamera()->getViewport()->width();
    int screenHeight = viewer.getCamera()->getViewport()->height();
    
    vertices->push_back( osg::Vec3(0, 0, 0) );
    vertices->push_back( osg::Vec3(0, screenHeight, 0) );
    vertices->push_back( osg::Vec3(screenWidth, screenHeight, 0) ); 
    vertices->push_back( osg::Vec3(screenWidth, 0, 0) );
    
    geometry->setVertexArray(vertices);
    
    osg::DrawElementsUInt *rectangle = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
    
    rectangle->push_back(0);
    rectangle->push_back(1);
    rectangle->push_back(2);
    rectangle->push_back(3);
    
    geometry->addPrimitiveSet(rectangle);    
    
    osg::Vec2Array* texcoords = new osg::Vec2Array(4);

    (*texcoords)[0].set(0.0f, 0.0f);
    (*texcoords)[1].set(0.0f, 1.0f);
    (*texcoords)[2].set(1.0f, 1.0f);
    (*texcoords)[3].set(1.0f, 0.0f); 
    
    geometry->setTexCoordArray(0, texcoords);
    
    osg::Texture2D *texture = new osg::Texture2D;
    texture->setDataVariance(osg::Object::DYNAMIC); 

    osg::Image *image = osgDB::readImageFile(BACKGROUND_IMAGE);

    if (!image)
    {
        std::cout << " couldn't find texture, quiting." << std::endl;
        exit(0);
    }

    // assign image to texture
    texture->setImage(image); 
    
    osg::StateSet* stateOne = new osg::StateSet();

    stateOne->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);

    geode->setStateSet(stateOne);
    _skyPat->addChild(geode);  
}
Esempio n. 10
0
void Game::initialize() {
    
	// check if log file not set, then set default file name
	if (this->logger == nullptr)
		this->logger = new Logger();
	
	// this line needs to be after logger initialization,
	// and before helicopter initialization
	timeHandler = new TimeHandler(this);
	
	// model factory to supply models
	ModelFactory mf(this);
    root = new osg::Group();
	osg::ref_ptr<Helicopter> helicopter = static_cast<Helicopter*>(mf.create(ModelsTypes::HELICOPTER));
	osg::ref_ptr<Model> terrain = mf.create(ModelsTypes::TERRAIN);
	osg::ref_ptr<Model> sky = mf.create(ModelsTypes::SKY);
	osg::ref_ptr<Model> eiffelTour = mf.create(ModelsTypes::EIFFEL_TOUR);
    osg::ref_ptr<Model> building1 = mf.create(ModelsTypes::LARGE_RESIDENTIAL_HIGHRISE);
    osg::ref_ptr<Model> building2 = mf.create(ModelsTypes::LARGE_RESIDENTIAL_HIGHRISE_ORANGE);
	osg::ref_ptr<Model> target = mf.create(ModelsTypes::TARGET);
	
    GameController *helicopterController = new GameController(this, helicopter.get());
	this->nodeTracker = new osgGA::NodeTrackerManipulator;

	
	// add models to models vector
	this->models.push_back(helicopter.get());
	this->models.push_back(terrain.get());
	this->models.push_back(sky.get());
	this->models.push_back(eiffelTour.get());
	this->models.push_back(building1.get());
	this->models.push_back(building2.get());
	this->models.push_back(target.get());
	
    
	// add obeservers
    timeHandler->AddObserver(helicopter.get());
	
	
	// add collidables
	this->collision->addCollidable(static_cast<Obstacle*>(eiffelTour.get()));
	this->collision->addCollidable(static_cast<Obstacle*>(building1.get()));
	this->collision->addCollidable(static_cast<Obstacle*>(building2.get()));
	this->collision->addCollidable(static_cast<Obstacle*>(target.get()));
    
	
	// add loggables
	this->logger->addLoggable(helicopter.get());
	
	
	// initialize popup help screen
	initializePopupHelpScreen();
	
	
	// set node tracker
	initializeCamera();
	

	// add children nodes to root
	root->addChild(helicopter.get());
	root->addChild(terrain.get());
	root->addChild(sky.get());
    root->addChild(eiffelTour.get());
	root->addChild(building1.get());
	root->addChild(building2.get());
	root->addChild(target.get());
	
	
	// setup viewer
	viewer.addEventHandler(helicopterController);
	viewer.addEventHandler(timeHandler);
	viewer.setSceneData(root.get());
    viewer.setCameraManipulator(nodeTracker.get());
	
}
Esempio n. 11
0
bool Visualization::initialize()
{
    m_initialized = true;
    m_mousePosition[0] = m_mousePosition[1] = 1;
    m_crowdAvailableDt = 0.f;
    m_stopRequested = false;
	m_rotating = false;
	    
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
	{
		printf("Could not initialize SDL.\n");
		m_initialized = false;
	}
    else
    {
        // Center window
        char env[] = "SDL_VIDEO_CENTERED=1";
#ifdef _MSC_VER
        _putenv(env);
#else
        putenv(env);
#endif
        
        // Init OpenGL
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
        SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
        //#ifndef WIN32
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
        //#endif
        
        const SDL_VideoInfo* vi = SDL_GetVideoInfo();
        
        SDL_Surface* screen = 0;
        
        if (m_fullscreen)
        {
            m_winWidth = vi->current_w;
            m_winHeight = vi->current_h;
            screen = SDL_SetVideoMode(m_winWidth, m_winHeight, 0, SDL_OPENGL|SDL_FULLSCREEN);
        }
        else
        {	
            m_winWidth = vi->current_w - 20;
            m_winHeight = vi->current_h - 80;
            screen = SDL_SetVideoMode(m_winWidth, m_winHeight, 0, SDL_OPENGL);
        }
        
        if (!screen)
        {
            printf("Could not initialise SDL opengl.\n");
            m_initialized = false;
        }
        else
        {
            glEnable(GL_MULTISAMPLE);
            
            SDL_WM_SetCaption("Detour Crowd Demo", 0);
            
            if (!imguiRenderGLInit("DroidSans.ttf"))
            {
                printf("Could not init GUI renderer.\n");
                m_initialized = false;
            }
            else if (!initializeCamera())
            {
                printf("Unable to initialize the camera.\n");
                m_initialized = false;
            }
            else if (m_debugInfo == 0 || !m_debugInfo->initialize())
            {
                printf("Unable to initialize the crowd debug info.\n");
                m_initialized = false;
            }
            else
            {
                m_initialized = true;
                
                glEnable(GL_CULL_FACE);
                
                float fogCol[4] = { 0.32f, 0.31f, 0.30f, 1.0f };
                glEnable(GL_FOG);
                glFogi(GL_FOG_MODE, GL_LINEAR);
                glFogf(GL_FOG_START, m_zFar*0.1f);
                glFogf(GL_FOG_END, m_zFar*1.25f);
                glFogfv(GL_FOG_COLOR, fogCol);
                
                glDepthFunc(GL_LEQUAL);
                
                m_lastTickCount = SDL_GetTicks();
                
                
                // Extract OpenGL view properties
                glGetDoublev(GL_PROJECTION_MATRIX, m_projection);
                glGetDoublev(GL_MODELVIEW_MATRIX, m_modelView);
                glGetIntegerv(GL_VIEWPORT, m_viewport);
            }
        }
    }
    
    if (!m_initialized)
    {
        SDL_Quit();
    }

    return m_initialized;
}