CGameCamera::CGameCamera() { m_targetObject = NULL; m_objectType = CGameObject::CameraObject; #ifdef GSEDITOR m_cameraMesh = NULL; #endif ISceneManager *smgr = getIView()->getSceneMgr(); // save old camera ICameraSceneNode *oldCam = smgr->getActiveCamera(); // create new camera m_camera = smgr->addCameraSceneNode(); m_camera->setFOV( core::degToRad(60.0f) ); m_camera->setFarValue( 8000.0f ); m_camera->grab(); core::vector3df pos(0,0,0); setPosition( pos ); core::vector3df target(1,0,0); setTarget( target ); #ifdef GSEDITOR CColladaMeshComponent *comp = new CColladaMeshComponent( this ); comp->loadFromFile( getIView()->getPath("data/editor/camera.dae") ); addComponent( comp ); setLighting( false ); m_cameraMesh = m_node; m_cameraMesh->setVisible( true ); ITriangleSelector *selector = smgr->createTriangleSelectorFromBoundingBox( m_cameraMesh ); m_cameraMesh->setTriangleSelector(selector); selector->drop(); #endif // set camera node m_node = m_camera; // restore camera smgr->setActiveCamera( oldCam ); m_animator = NULL; #ifndef GSGAMEPLAY setEditorCamera(); #else setFreeCamera(); #endif }
void editLevelScreen() { int currentType = TILE_RED; showType(currentType); Tile *tiles[TOTAL_TILES]; if(loadTiles(tiles) == false) { cleanUp(); exit(0); } while(true) { fps.start(); while(SDL_PollEvent(&event)) { //When the user clicks if( event.type == SDL_MOUSEBUTTONDOWN ) { //Put the tile putTile( tiles, currentType ); } if (event.type == SDL_KEYDOWN) { switch(event.key.keysym.sym) { case SDLK_1: case SDLK_q: { //Scroll forward through tiles currentType--; if( currentType < TILE_RED ) currentType = TILE_TOPLEFT; //Show the current tile type showType( currentType ); break; } case SDLK_2: case SDLK_w: { //Scroll backward through tiles currentType++; if( currentType > TILE_TOPLEFT ) currentType = TILE_RED; //Show the current tile type showType( currentType ); break; } case SDLK_s: { // save the tiles and display a "saved" message saveTiles(tiles); SDL_Color savedMessageColor = {255, 255, 255}; SDL_Surface* savedMessage = NULL; savedMessage = load_font("eva.ttf", "SAVED", savedMessageColor, 24); apply_surface(1, 1, savedMessage, screen); SDL_Delay(500); SDL_FreeSurface(savedMessage); break; } case SDLK_BACKSPACE: { deleteTiles(tiles); startScreen(); break; } default:; } } myWindow.handle_window(); handleMusic(); if( event.type == SDL_QUIT ) { //Quit the program deleteTiles(tiles); cleanUp(); exit(0); } } if (myWindow.error()) { cleanUp(); exit(0); } setEditorCamera(); for (int t = 0; t < TOTAL_TILES; t++) tiles[t]->show(); if (SDL_Flip(screen) == -1) { cleanUp(); exit(0); } //Cap the frame rate if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND ) { SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() ); } } }