App() : mTimer(0), mTimer2(0), mNextUpdate(0) { _makeOgre(); _makeOIS(); // Create Silverback and load in dejavu mSilverback = new Gorilla::Silverback(); mSilverback->loadAtlas("dejavu"); mScreen = mSilverback->createScreen(mViewport, "dejavu"); mScreen->setOrientation(Ogre::OR_DEGREE_270); Ogre::Real vpW = mScreen->getWidth(), vpH = mScreen->getHeight(); // Create our drawing layer mLayer = mScreen->createLayer(0); rect = mLayer->createRectangle(0,0, vpW, vpH); rect->background_gradient(Gorilla::Gradient_Diagonal, Gorilla::rgb(98,0,63), Gorilla::rgb(255,180,174)); markup = mLayer->createMarkupText(9,5,5, "%@24%A Haiku\n%@14%Written by Betajaen%@9%\nSo many to choose from\nPretty typefaces on Ogre screen\nTime to update Git"); caption = mLayer->createCaption(9, vpW - 55, 5, "9"); caption->width(50); caption->align(Gorilla::TextAlign_Right); caption = mLayer->createCaption(14, vpW - 55, 18, "14"); caption->width(50); caption->align(Gorilla::TextAlign_Right); caption = mLayer->createCaption(24, vpW - 55, 33, "24"); caption->width(50); caption->align(Gorilla::TextAlign_Right); }
App() : mNextUpdate(0), mTimer(0) { _makeOgre(); _makeOIS(); _makeScene(); // Initialise Gorilla mGorilla = new Gorilla::Silverback(); mGorilla->loadAtlas("dejavu"); mScreen = mGorilla->createScreen(mViewport, "dejavu"); mFPSLayer = mScreen->createLayer(14); mFPS = mFPSLayer->createCaption(14, 10,10, Ogre::StringUtil::BLANK); mConsole = new OgreConsole(); mConsole->init(mScreen); mConsole->addCommand("whoami", whoami); mConsole->addCommand("version", version); mConsole->addCommand("make", make); mConsole->addCommand("quit", quit); }
App() : mCurrentTest(0) { _makeOgre(); _makeOIS(); // Create Silverback and load in dejavu mSilverback = new Gorilla::Silverback(); mSilverback->loadAtlas("dejavu"); registerTests(mTests, mSilverback, mViewport, mSceneMgr); }
App() : mTimer(0), mTimer2(0), mBasePower(150), mNextUpdate(0) { _makeOgre(); _makeOIS(); // Create Silverback and load in dejavu mSilverback = new Gorilla::Silverback(); mSilverback->loadAtlas("dejavu"); createHUD(); createControlPanel(); }
void createHUD() { mHUD = mSilverback->createScreen(mViewport, "dejavu"); mHUDLayer = mHUD->createLayer(); Gorilla::Caption* fakeHealth = mHUDLayer->createCaption(24, 0, 0, "+ 100"); fakeHealth->width(mViewport->getActualWidth()-16); fakeHealth->height(mViewport->getActualHeight()-4); fakeHealth->align(Gorilla::TextAlign_Right); fakeHealth->vertical_align(Gorilla::VerticalAlign_Bottom); Gorilla::Caption* fakeAmmo = mHUDLayer->createCaption(24, 16, 0, ": 60"); fakeAmmo->width(mViewport->getActualWidth()); fakeAmmo->height(mViewport->getActualHeight()-4); fakeAmmo->vertical_align(Gorilla::VerticalAlign_Bottom); mCrosshairLayer = mHUD->createLayer(); mCrosshair = mCrosshairLayer->createRectangle((mViewport->getActualWidth() * 0.5f) - 11, (mViewport->getActualHeight() * 0.5f) - 11, 22, 22); mCrosshair->background_image("crosshair"); }
void GameState::createScene() { // CREATE 3D SCENE m_bQuit = false; _highScoreEntryDialog = nullptr; _gameTime = 0.0f; _physicsTime = 0.0f; _playerScore = 0.0f; _pauseState = PAUSE_STATE_NONE; _pulsePower = 0.0f; _pulseTime = 0.0f; _gameOverTime = 0.0f; _energyDrainFactor = 1.0f; _vibrationStrength = 0.0f; // BULLET SETUP // Build the broadphase _btBroadphase = new (alignedMalloc<btDbvtBroadphase>()) btDbvtBroadphase(); // Set up the collision configuration and dispatcher _btCollisionConfiguration = new (alignedMalloc<btDefaultCollisionConfiguration>()) btDefaultCollisionConfiguration(); _btDispatcher = new (alignedMalloc<btCollisionDispatcher>()) btCollisionDispatcher(_btCollisionConfiguration); // The actual physics solver _btSolver = new (alignedMalloc<btSequentialImpulseConstraintSolver>()) btSequentialImpulseConstraintSolver; // The world. _btDynamicsWorld = new (alignedMalloc<btDiscreteDynamicsWorld>()) btDiscreteDynamicsWorld(_btDispatcher,_btBroadphase,_btSolver,_btCollisionConfiguration); _btDynamicsWorld->setGravity(btVector3(0,-10,0)); _btGroundShape = new (alignedMalloc<btStaticPlaneShape>()) btStaticPlaneShape(btVector3(0,1,0),1); _btGroundMotionState = new (alignedMalloc<btDefaultMotionState>()) btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,-1,0))); btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI(0,_btGroundMotionState,_btGroundShape,btVector3(0,0,0)); _btGroundRigidBody = new (alignedMalloc<btRigidBody>()) btRigidBody(groundRigidBodyCI); assert((int)_btGroundRigidBody % 16 == 0); _btGroundRigidBody->setRestitution(1.0f); _btGroundRigidBody->setActivationState(DISABLE_DEACTIVATION); _btDynamicsWorld->addRigidBody(_btGroundRigidBody,COL_STATIC,COL_ALL); // CREATE ACTORS _playerBase = new LagomPlayerBase(this); boost::shared_ptr<LagomPlayerBase> playerBase(_playerBase); RegisterActor(playerBase); // Effects stuff _particleManager = new LagomParticleManager(m_pSceneMgr,_btDynamicsWorld,1000,0.5f); _billboardManager = new BillboardManager(m_pSceneMgr,m_pCamera); //need a HUD too! Gorilla::Silverback* silverback = Gorilla::Silverback::getSingletonPtr(); _gScreen[0] = silverback->createScreen(Lagom::getSingleton().m_pViewport, "LargeFont"); _gScreen[1] = silverback->createScreen(Lagom::getSingleton().m_pViewport, "MediumFont"); _gScreen[2] = silverback->createScreen(Lagom::getSingleton().m_pViewport, "SmallFont"); _gTutorialScreen = silverback->createScreen(Lagom::getSingleton().m_pViewport, "dejavu"); _gLayer[0] = _gScreen[0]->createLayer(12); _gLayer[1] = _gScreen[1]->createLayer(13); _gLayer[2] = _gScreen[2]->createLayer(15); _gTutorialLayer = _gTutorialScreen->createLayer(18); int x,y,w,h; Lagom::getSingleton().m_pViewport->getActualDimensions(x,y,w,h); _gDisplays[0]._gText = _gLayer[1]->createCaption(24,w/2,h, ""); _gDisplays[1]._gText = _gLayer[0]->createCaption(48,w/2,h, ""); _gDisplays[2]._gText = _gLayer[1]->createCaption(24,w/2,h, ""); for(auto it = _gDisplays.begin(); it< _gDisplays.end(); ++it) { it->_text = ""; it->_displayPingTime = 0.0f; it->_displayVisibleTime = 0.0f; it->_gText->align(Gorilla::TextAlign_Centre); } _gDisplays[0]._gText->vertical_align(Gorilla::VerticalAlign_Top); _gDisplays[0]._gText->top(0+5); _gDisplays[1]._gText->vertical_align(Gorilla::VerticalAlign_Middle); _gDisplays[1]._gText->top(h/2); _gDisplays[2]._gText->vertical_align(Gorilla::VerticalAlign_Bottom); _gDisplays[2]._gText->top(h-5); _gameTime= 0.0f; _displayTime = 0.0f; _inputTime = 0.0; //set up fader Ogre::ResourcePtr resptr = Ogre::MaterialManager::getSingleton().getByName("fadeToBlackMaterial"); Ogre::Material * mat = dynamic_cast<Ogre::Material*>(resptr.getPointer()); Ogre::Technique *tech = mat->getTechnique(0); // Get the technique Ogre::Pass *pass = tech->getPass(0); // Get the pass _fadeTexUnit = pass->getTextureUnitState(0); // Get the texture_unit state _fadeOverlay = Ogre::OverlayManager::getSingleton().getByName("fadeToBlackOverlay"); //set overlay to black _fadeOverlay->show(); _fadeTexUnit->setAlphaOperation(LBX_MODULATE, LBS_MANUAL, LBS_TEXTURE, 1.0f); calculatePlayArea(); //now load level if any _stageSpawner = new StageSpawnManager(this,playerBase); // set proper state for fade in SetPauseState(PAUSE_STATE_FADING); _fadeFactor = -1.0f; }
bool Lagom::initExtra() { m_pViewport = m_pRenderWnd->addViewport(0); m_pViewport->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f, 1.0f)); //m_pViewport->setClearEveryFrame(false); m_pViewport->setCamera(0); LogMessage("Viewport Initialized"); if(!LagomInput::getSingletonPtr()) new LagomInput(); LagomInput::getSingletonPtr()->Initialize(m_pRenderWnd); LogMessage("Input Initialized"); //initialize Resources LogMessage("Adding resource locations"); #if defined( ANDROID ) Ogre::ResourceGroupManager::getSingleton().addResourceLocation(_dataFile, "Android"); #elif !defined(_DEBUG) Ogre::ResourceGroupManager::getSingleton().addResourceLocation(_dataFile, "Zip"); #else Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/models", "FileSystem"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/materials/scripts", "FileSystem"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/materials/textures", "FileSystem"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/gui", "FileSystem"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/SSAO", "FileSystem"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/music", "FileSystem"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/sound", "FileSystem"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/units", "FileSystem"); #endif LogMessage("Lagom Resources Added"); Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource("LargeFont.gorilla"); if(!stream.getPointer()) LogMessage("Expected Resource does not exist"); else LogMessage("Expected Resource exists"); Ogre::TextureManager::getSingleton().setDefaultNumMipmaps( MIP_UNLIMITED ); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); LogMessage("Resource Groups Initialized complete"); /* #ifndef ANDROID // on android this is done from the JNI Ogre::String secName, typeName, archName; Ogre::ConfigFile cf; cf.load(_dataFile); Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); while (seci.hasMoreElements()) { secName = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); ++i) { typeName = i->first; archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); } } Ogre::TextureManager::getSingleton().setDefaultNumMipmaps( MIP_UNLIMITED ); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); LogMessage("Resources Initialized"); #endif*/ //m_pTrayMgr = new OgreBites::SdkTrayManager("AOFTrayMgr", m_pRenderWnd, m_pMouse, 0); m_pTimer = new Ogre::Timer(); m_pTimer->reset(); LogMessage("Timer Initialized"); //init CEGUI //CEGUI::ImagesetManager::getSingleton().createFromImageFile("LagomLogo","LagomLogo.png","General"); //CEGUI::Imageset &imageset = CEGUI::ImagesetManager::getSingleton().createFromImageFile((CEGUI::utf8 *)"tutorialSet", (CEGUI::utf8 *)"Tutorial.png",(CEGUI::utf8 *)"General"); //imageset.defineImage((CEGUI::utf8 *)"tutorialImage", CEGUI::Rect(0, 0, 800, 600), CEGUI::Vector2(0, 0)); // setup compositors if (CompositorManager::getSingleton().addCompositor(m_pViewport, "SSAO/GBuffer")) CompositorManager::getSingleton().setCompositorEnabled(m_pViewport, "SSAO/GBuffer", false); else LogManager::getSingleton().logMessage("SSAO: Failed to add GBuffer compositor \n"); LogMessage("Compositors Initialized"); /* for (unsigned int i = 0; i < nCompositorNames; i++) { if (CompositorManager::getSingleton().addCompositor(m_pViewport, compositorNames[i])) CompositorManager::getSingleton().setCompositorEnabled(m_pViewport, compositorNames[i], false); else LogManager::getSingleton().logMessage("SSAO: Failed to add compositor: " + compositorNames[i] + "\n"); } for (unsigned int i = 0; i < nPostprocessingNames; i++) { if (CompositorManager::getSingleton().addCompositor(m_pViewport, postprocessingNames[i])) CompositorManager::getSingleton().setCompositorEnabled(m_pViewport, postprocessingNames[i], false); else LogManager::getSingleton().logMessage("SSAO: Failed to add " + postprocessingNames[i] + " compositor \n"); } */ Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0); Ogre::MeshManager::getSingleton().createPlane("terrain", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 150, 150, 100, 100, true, 1, 1, 1, Ogre::Vector3::UNIT_Z); LogMessage("Base Objects Initialized"); setSSAO(); _BufferFlush.start(3); LogMessage("Flush Buffers Initialized"); //setup sound SoundManager* soundManager = new SoundManager; soundManager->Initialize(); LogMessage("Sound Manager Initialized"); //setup Gorilla Gorilla::Silverback* silverback = new Gorilla::Silverback(); silverback->loadAtlas("LargeFont"); silverback->loadAtlas("MediumFont"); silverback->loadAtlas("SmallFont"); silverback->loadAtlas("dejavu"); LogMessage("Gorilla Initialized"); // play music //m_ceguiRenderer = &CEGUI::OgreRenderer::bootstrapSystem(); LogMessage("CEGUI Initialization Begin"); m_ceguiRenderer = &CEGUI::OgreRenderer::create(*m_pRenderWnd); LogMessage("CEGUI Renderer Initialized"); CEGUI::OgreResourceProvider& rp = CEGUI::OgreRenderer::createOgreResourceProvider(); LogMessage("CEGUI Resource Provider Initialized"); CEGUI::OgreImageCodec& ic = CEGUI::OgreRenderer::createOgreImageCodec(); LogMessage("CEGUI Image Coded Initialized"); CEGUI::System::create( *m_ceguiRenderer ,&rp, static_cast<CEGUI::XMLParser*>(0), &ic); LogMessage("CEGUI Base Initialized"); // Load the scheme CEGUI::SchemeManager::getSingleton().create( (std::string(sDefaultGUITheme)+".scheme").c_str() ); LogMessage("GUIScheme Initialized"); // Set the defaults CEGUI::System::getSingleton().setDefaultFont( "SmallFont" ); CEGUI::System::getSingleton().setDefaultMouseCursor( std::string(sDefaultGUISheme).c_str(), sDefaultGUIMouseArrow ); CEGUI::System::getSingleton().setDefaultTooltip( (CEGUI::utf8*)"Sunrise/Tooltip" ); LogMessage("GUI defaults Initialized"); //CEGUI::FontManager::getSingleton().get("LargeFont").setAutoScaled( m_ceguiRenderer->setRenderingEnabled(true); LogMessage("CEGUI Initialized"); PlayRandomMusic(); LogMessage("Lagom Initialization Complete"); return true; }