Esempio n. 1
0
void EngineStage::setPause(bool value, bool targetAllSounds)
{
    if (value)
    {
        if (targetAllSounds)
            OgreFramework::getSingletonPtr()->m_pSoundMgr->pauseAllSounds();
        player->pause();
        
        // Display current level index
        LevelSet* levels = player->getLevels();
        std::string msg = "Level: ";
        msg += Util::toStringInt(player->getLevelRequestRow() + 1);
        msg += "-";
        msg += (char)('A' + player->getLevelRequestCol());
        globals.setMessage(msg, MESSAGE_NORMAL);
        
        Ogre::ControllerManager::getSingleton().setTimeFactor(0);
    }
    else
    {
        player->unpause();
        if (targetAllSounds)
            OgreFramework::getSingletonPtr()->m_pSoundMgr->resumeAllPausedSounds();
        globals.clearMessage();
        Ogre::ControllerManager::getSingleton().setTimeFactor(1);
    }
}
Esempio n. 2
0
void EngineStage::activateReleased(float x, float y, float dx, float dy)
{
    if (stageState == STAGE_STATE_PAUSE && !player->hasTriggeredStartup())
    {
        HudSlider* speedSlider = NULL;
        if (hud) speedSlider = hud->getSpeedSlider();
        if (speedSlider && speedSlider->selected)
        {
            speedSlider->selected = false;
            Vector2 np;
#if !defined(OGRE_IS_IOS)
            if (speedSlider->orientation)
                np = speedSlider->p2 + globals.convertToPercentScreen(Vector2(0.0, dy));
            else
                np = speedSlider->p2 + globals.convertToPercentScreen(Vector2(dx, 0.0));
#else
            if (speedSlider->orientation)
                np = speedSlider->p2cache + globals.convertToPercentScreen(Vector2(0.0, dy));
            else
                np = speedSlider->p2cache + globals.convertToPercentScreen(Vector2(dx, 0.0));
#endif
            speedSlider->setBallPosition(np);
            //std::cout << "release\n";
        }
    }
}
Esempio n. 3
0
void OgreApp::setupDemoScene()
{
    globals.initPaths();
#if defined(OGRE_IS_IOS) && defined(NETWORKING)
    syncConfig();
#endif
    
    seed = time(0);
    srand(seed);
    
    // The code snippet below is used to output text
    // create a font resource
    ResourcePtr resourceText = OgreFramework::getSingletonPtr()->m_pFontMgr->create("Arial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    resourceText->setParameter("type", "truetype");
    //resourceText->setParameter("source", "C64_User_Mono_v1.0-STYLE.ttf");
    resourceText->setParameter("source", "NEUROPOL.ttf");
    resourceText->setParameter("size", "16");
    resourceText->setParameter("resolution", "96");
    resourceText->load();
    
    Util::createSphere(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "sphereMesh", 1.0, 8, 8);
    Util::createCylinder(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "cylinderMesh", 1.0, 1.0, 8);
    Util::createDiamond(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "diamondMesh", 1.0, 1.0);
    Util::createBox(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "boxMesh", 1.0, 1.0, 1.0);
    Util::createPlane(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "planeMesh", 1.0, 1.0);
    Util::createDefaultSegments(OgreFramework::getSingletonPtr()->m_pSceneMgrMain);
    
    globals.initPaths();
    //if (!configStageType(globals.configPath, globals.configBackup, "globalConfig"))
    //    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
    
	OgreFramework::getSingletonPtr()->m_pCameraMain->setPosition(Vector3::ZERO);
	OgreFramework::getSingletonPtr()->m_pCameraMain->lookAt(Vector3::ZERO);
	player = new Player(
                        globals.playerName,
                        OgreFramework::getSingletonPtr()->m_pCameraMain->getPosition(),
                        OgreFramework::getSingletonPtr()->m_pCameraMain->getOrientation(),
                        globals.initCamSpeed,
                        globals.vineTOffset,
                        seed,
                        "vinezors" + Util::toStringInt(seed) + ".csv");
    player->setSounds(true);
    if (!player->loadProgress(globals.savePath))
        std::cout << "WARNING: Save File could not be loaded correctly" << std::endl;
    
    globals.initLogs(player->getSkillLevel().sessionID);
    
    engineStateMgr = new EngineStateManager();
    engineStateMgr->requestPushEngine(ENGINE_MAIN_MENU, player);
    
#if defined(OGRE_IS_IOS) && (NETWORKING)
    syncLogs();
#endif
}
Esempio n. 4
0
void OgreApp::setupDemoScene()
{
        globals.initPaths();
    globals.VendorID = getVendorID();
    globals.initGlobalSettingsPath();
    globals.saveGlobalSettings(globals.globalPath);
#if defined(OGRE_IS_IOS) && defined(NETWORKING)
    //syncConfig();
#endif
    
    seed = time(0);
    srand(seed);
    std::cout << "SEED: " << seed << std::endl;
    
    // create font resources
    ResourcePtr resourceText1 = OgreFramework::getSingletonPtr()->m_pFontMgr->create("MainSmall", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    resourceText1->setParameter("type", "truetype");
    //resourceText1->setParameter("source", "C64_User_Mono_v1.0-STYLE.ttf");
    resourceText1->setParameter("source", "NEUROPOLX.ttf");
    resourceText1->setParameter("size", "16");
    resourceText1->setParameter("resolution", "96");
    resourceText1->load();
    
    ResourcePtr resourceText2 = OgreFramework::getSingletonPtr()->m_pFontMgr->create("MainBig", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    resourceText2->setParameter("type", "truetype");
    resourceText2->setParameter("source", "Philosopher-Bold.ttf");
    resourceText2->setParameter("size", "16");
    resourceText2->setParameter("resolution", "256");
    resourceText2->load();
    
    Util::createDefaultSegments(OgreFramework::getSingletonPtr()->m_pSceneMgrMain);
    
	OgreFramework::getSingletonPtr()->m_pCameraMain->setPosition(Vector3::ZERO);
	OgreFramework::getSingletonPtr()->m_pCameraMain->lookAt(Vector3::ZERO);
	player = new Player(
                        globals.playerName,
                        OgreFramework::getSingletonPtr()->m_pCameraMain->getPosition(),
                        OgreFramework::getSingletonPtr()->m_pCameraMain->getOrientation(),
                        globals.initCamSpeed,
                        globals.vineTOffset,
                        seed,
                        "vinezors" + Util::toStringInt(seed) + ".csv");
    player->setSounds();
    if (!player->loadProgress(globals.savePath))
        std::cout << "WARNING: Save File could not be loaded correctly" << std::endl;
    player->feedLevelRequestFromSchedule();
    
    engineStateMgr = new EngineStateManager();
    engineStateMgr->requestPushEngine(ENGINE_MAIN_MENU, player);
    
#if defined(OGRE_IS_IOS) && defined(NETWORKING)
    if (globals.syncDataToServer) syncLogs();
#endif
}
Esempio n. 5
0
void OgreApp::endLevel(Evaluation forced)
{
    globals.clearMessage();
    
    if (tunnel)
    {
        tunnel->setCleaning(true);
        if (levelMgr->levelFinished(tunnel, forced))
        {
            gameState = STATE_PROMPT;
            globals.setMessage("Play Again?\n\n\n(Yes / No)\n\n\n<--- Swipe --->", MESSAGE_NORMAL);
        }
        else
            gameState = STATE_PLAY;
    }
}
Esempio n. 6
0
void OgreFramework::requestResize()
{
    m_pRenderWnd->windowMovedOrResized();
	m_pCameraMain->setAspectRatio(Real(m_pViewportMain->getActualWidth()) / Real(m_pViewportMain->getActualHeight()));
    globals.screenWidth = m_pRenderWnd->getWidth();
    globals.screenHeight = m_pRenderWnd->getHeight();
    globals.set();
}
Esempio n. 7
0
std::string TutorialManager::queryButtons(Vector2 target) const
{
    Vector2 comp = globals.convertToPercentScreen(target);
    for (int i = 0; i < buttons.size(); ++i)
    {
        if ((buttons[i].overlay && buttons[i].overlay->isVisible()) && buttons[i].isInside(comp) && buttons[i].active)
        {
            return buttons[i].name;
        }
    }
    return "";
}
Esempio n. 8
0
void OgreApp::setPause(bool value)
{
    if (value)
    {
        pause = value;
        player->pause();
        OgreFramework::getSingletonPtr()->m_pSoundMgr->pauseAllSounds();
        if (predictSessionOver())
        {
            if (player->getName() == "subject999")
                globals.setMessage("Training is complete!\nPlease check in.\n\nDouble tap to exit.", MESSAGE_FINAL);
            else
                globals.setMessage("That's it for Today!\nPlease check in before you leave.\n\nYou completed: " + Util::toStringInt(player->getNumStagesWon()) + " stages!\n\nDouble tap to exit.", MESSAGE_FINAL);
            endGame();
        }
        else
        {
            globals.appendMessage("\n\nSwipe to Continue", MESSAGE_NORMAL);
#ifdef DEBUG_MODE
            globals.appendMessage("\n\n" + player->getSkillLevel().getCurrentStats(), MESSAGE_NORMAL);
            globals.appendMessage("\n\n" + Util::toStringInt(globals.sessionTime - getTotalElapsed()), MESSAGE_NORMAL);
#endif
        }
        Ogre::ControllerManager::getSingleton().setTimeFactor(0);
    }
    else if (!sessionOver)
    {
        pause = value;
        player->unpause();
        OgreFramework::getSingletonPtr()->m_pSoundMgr->resumeAllPausedSounds();
        
        globals.clearMessage();
        Ogre::ControllerManager::getSingleton().setTimeFactor(1);
    }
}
Esempio n. 9
0
void EngineStage::activatePressed(float x, float y)
{
    if (stageState == STAGE_STATE_PAUSE && !player->hasTriggeredStartup())
    {
        HudSlider* speedSlider = NULL;
        if (hud) speedSlider = hud->getSpeedSlider();
        if (speedSlider)
        {
            Vector2 pos = globals.convertToPercentScreen(Vector2(x, y));
        
            // Case for tapping into the slider which makes ball jump to position
            if (speedSlider->isInsideRange(pos))
            {
                // Project position to range
                if (speedSlider->orientation)
                {
                    float ny = pos.y - speedSlider->p1.y - speedSlider->dim2.y / 2;
                    speedSlider->setBallPosition(Vector2(speedSlider->p2.x, ny));
                }
                else
                {
                    float nx = pos.x - speedSlider->p1.x - speedSlider->dim2.x / 2;
                    speedSlider->setBallPosition(Vector2(nx, speedSlider->p2.y));
                }
            }
        
            // Initialize p2cache first time we touch ball
            // p2cache is better since iOS tracking uses total dx which is more accurate
            // then passing in a dx everytime
            if (speedSlider->isInsideBall(pos))
            {
                speedSlider->selected = true;
                speedSlider->p2cache = speedSlider->p2;
            }
            //std::cout << "press\n";
        }
    }
}
Esempio n. 10
0
// The following deal with injecting coordinates to simulate a slider
//
void EngineTabSettings::activateMoved(float x, float y, float dx, float dy)
{
    Ogre::Vector2 temp = globals.convertToPercentScreen(Vector2(0.0,dy));

    std::cout << "Temp: "<<"(" << temp.x <<", " << temp.y << ")" << std::endl;

    //Testing Dragging!
   /*
    if(touchedBox)
    {
        Ogre::Vector2 temp2 = globals.convertToPercentScreen(Vector2(x,y));
        
    
        //Move everything depending on the dy!
        Ogre::Vector2 temp = globals.convertToPercentScreen(Vector2(0.0,dy));
        
        
        //float newy = initTextPosition
        float constant = 1;
        temp.y /= constant;
        hud->enableUnlimitedFuelBackground->setPosition(.32, hud->initTextPosition.y+temp.y);
    }
    */
}
Esempio n. 11
0
void EngineStage::setup()
{
    globals.clearMessage();
    
    // Dealloc data
    dealloc();
    
    // Retrieve player skill and gen new tunnel
    PlayerLevel skillLevel = player->getSkillLevel();
    
    // Setup player and tunnel params
    Vector3 origin = Vector3::ZERO;
    Vector3 forward = globals.tunnelReferenceForward;
    Quaternion rot = Quaternion(1, 0, 0, 0);
    
    //if (!configStageType(globals.configPath, globals.configBackup, "globalConfig"))
    //    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
    
    globals.maxCamSpeed = skillLevel.maxSpeed;
    
    globals.stageTotalTargets1 = globals.stageTotalSignals * (globals.podNBackChance / 100.0);
    globals.stageTotalTargets2 = globals.stageTotalSignals * (globals.podNBackChance / 100.0);
    globals.stageTotalTargets3 = globals.stageTotalSignals * (globals.podNBackChance / 100.0);
    
    StageMode nmode = STAGE_MODE_PROFICIENCY;
    StageRequest level = player->getLevels()->retrieveLevel(player->getLevelRequestRow(), player->getLevelRequestCol());
    int nlevel = level.nback;
    switch (level.phase)
    {
        case 'A':
        {
            nmode = STAGE_MODE_COLLECTION;
            globals.signalTypes = std::vector<std::vector<PodInfo> >(4);
            globals.signalTypes[POD_SIGNAL_1].push_back(PodInfo(POD_SIGNAL_1, POD_FUEL, POD_COLOR_BLUE, POD_SHAPE_UNKNOWN, POD_SOUND_1));
            globals.signalTypes[POD_SIGNAL_2].push_back(PodInfo(POD_SIGNAL_2, POD_FUEL, POD_COLOR_GREEN, POD_SHAPE_UNKNOWN, POD_SOUND_2));
            globals.signalTypes[POD_SIGNAL_3].push_back(PodInfo(POD_SIGNAL_3, POD_FUEL, POD_COLOR_PINK, POD_SHAPE_UNKNOWN, POD_SOUND_3));
            globals.signalTypes[POD_SIGNAL_4].push_back(PodInfo(POD_SIGNAL_4, POD_FUEL, POD_COLOR_YELLOW, POD_SHAPE_UNKNOWN, POD_SOUND_4));
            
            //globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
            globals.appendMessage("\nObtain matches by Color!", MESSAGE_NORMAL);
            break;
        }
        case 'B':
        {
            nmode = STAGE_MODE_COLLECTION;
            globals.signalTypes = std::vector<std::vector<PodInfo> >(4);
            globals.signalTypes[POD_SIGNAL_1].push_back(PodInfo(POD_SIGNAL_1, POD_FUEL, POD_COLOR_UNKNOWN, POD_SHAPE_DIAMOND, POD_SOUND_1));
            globals.signalTypes[POD_SIGNAL_2].push_back(PodInfo(POD_SIGNAL_2, POD_FUEL, POD_COLOR_UNKNOWN, POD_SHAPE_SPHERE, POD_SOUND_2));
            globals.signalTypes[POD_SIGNAL_3].push_back(PodInfo(POD_SIGNAL_3, POD_FUEL, POD_COLOR_UNKNOWN, POD_SHAPE_CONE, POD_SOUND_3));
            globals.signalTypes[POD_SIGNAL_4].push_back(PodInfo(POD_SIGNAL_4, POD_FUEL, POD_COLOR_UNKNOWN, POD_SHAPE_TRIANGLE, POD_SOUND_4));
            
            //globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
            globals.appendMessage("Obtain matches by Shape!", MESSAGE_NORMAL);
            break;
        }
        case 'C':
        {
            nmode = STAGE_MODE_COLLECTION;
            globals.signalTypes = std::vector<std::vector<PodInfo> >(4);
            globals.signalTypes[POD_SIGNAL_1].push_back(PodInfo(POD_SIGNAL_1, POD_FUEL, POD_COLOR_HOLDOUT, POD_SHAPE_UNKNOWN, POD_SOUND_1));
            globals.signalTypes[POD_SIGNAL_2].push_back(PodInfo(POD_SIGNAL_2, POD_FUEL, POD_COLOR_HOLDOUT, POD_SHAPE_UNKNOWN, POD_SOUND_2));
            globals.signalTypes[POD_SIGNAL_3].push_back(PodInfo(POD_SIGNAL_3, POD_FUEL, POD_COLOR_HOLDOUT, POD_SHAPE_UNKNOWN, POD_SOUND_3));
            globals.signalTypes[POD_SIGNAL_4].push_back(PodInfo(POD_SIGNAL_4, POD_FUEL, POD_COLOR_HOLDOUT, POD_SHAPE_UNKNOWN, POD_SOUND_4));

            //globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
            globals.setMessage("Obtain matches by only sound!", MESSAGE_NORMAL);
            break;
        }
        case 'D':
            nmode = STAGE_MODE_COLLECTION;
            globals.signalTypes = std::vector<std::vector<PodInfo> >(4);
            globals.signalTypes[POD_SIGNAL_1].push_back(PodInfo(POD_SIGNAL_1, POD_FUEL, POD_COLOR_BLUE, POD_SHAPE_DIAMOND, POD_SOUND_1));
            globals.signalTypes[POD_SIGNAL_2].push_back(PodInfo(POD_SIGNAL_2, POD_FUEL, POD_COLOR_GREEN, POD_SHAPE_SPHERE, POD_SOUND_2));
            globals.signalTypes[POD_SIGNAL_3].push_back(PodInfo(POD_SIGNAL_3, POD_FUEL, POD_COLOR_PINK, POD_SHAPE_CONE, POD_SOUND_3));
            globals.signalTypes[POD_SIGNAL_4].push_back(PodInfo(POD_SIGNAL_4, POD_FUEL, POD_COLOR_YELLOW, POD_SHAPE_TRIANGLE, POD_SOUND_4));
            
            //globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
            globals.setMessage("Obtain matching signals!", MESSAGE_NORMAL);
            break;
        case 'E':
            nmode = STAGE_MODE_RECESS;
            globals.signalTypes.clear();
            
            if (level.initCamSpeed <= 15) // For starting slower stages, be nicer
                globals.stageTotalCollections = (level.minCamSpeed + level.maxCamSpeed) / 3.0 * level.stageTime / Util::getModdedLengthByNumSegments(globals, globals.tunnelSegmentsPerPod);
            else
                globals.stageTotalCollections = (level.minCamSpeed + level.maxCamSpeed) / 2.5 * level.stageTime / Util::getModdedLengthByNumSegments(globals, globals.tunnelSegmentsPerPod);
            //globals.setBigMessage("Recess!");
            globals.setMessage("Reach the end! Grab Fuel Cells!", MESSAGE_NORMAL);
            break;
        case 'F':
            nmode = STAGE_MODE_TEACHING;
            globals.signalTypes.clear();
            //globals.setBigMessage("Training!");
            globals.setMessage("Grab Fuel Cells!", MESSAGE_NORMAL);
            break;
    }
    globals.initCamSpeed = level.initCamSpeed;
    globals.minCamSpeed = level.minCamSpeed;
    globals.maxCamSpeed = level.maxCamSpeed;
    
    tunnel = new Tunnel(
                        OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getRootSceneNode(),
                        origin + forward * (globals.tunnelSegmentWidth / 2),
                        rot,
                        globals.tunnelSegmentWidth,
                        globals.tunnelSegmentDepth,
                        globals.tunnelMinAngleTurn,
                        globals.tunnelMaxAngleTurn,
                        1, // replace or remove...
                        nmode,
                        level.phase, // replace or remove...
                        nlevel,
                        level.stageTime,
                        SOUTH,
                        globals.tunnelSegmentsPerSection,
                        globals.tunnelSegmentsPerPod,
                        globals.tunnelSegmentsPerDistractors,
                        globals.tunnelSegmentsPerPowerup,
                        globals.signalTypes,
                        level.powerups);
    tunnel->link(player);
    player->link(tunnel);
    
    tunnel->setHoldout(level.hasHoldout,level.holdoutFrequency);
    if (tunnel->getMode() == STAGE_MODE_RECESS)
    {
        // Assign nav levels in an incremental order specified by Liam's formula if the mode is recess
        // Therefore, the level parameter provided looks at the nav level provided as the starting index
        tunnel->setNavigationLevels(level.navLevels[0].level, globals.navMap.size() - 1, level.tunnelSectionsPerNavLevel);
    }
    else
    {
        // Otherwise, nav levels provided by the parameters
        tunnel->setNavigationLevels(level.navLevels, level.tunnelSectionsPerNavLevel);
    }
    tunnel->setCollectionCriteria(level.collectionCriteria);
    tunnel->constructTunnel(level.nameTunnelTile, globals.tunnelSections);
    player->newTunnel(level.nameMusic);
    player->setSpeedParameters(globals.initCamSpeed, globals.minCamSpeed, globals.maxCamSpeed);
    
    Util::setSkyboxAndFog(level.nameSkybox);
    
    /*
     if (skillLevel.set1Notify)
     globals.setBigMessage("Congratulations! You earned " + Util::toStringInt(nlevel) + "-Back!");
     else
     {
     if (skillLevel.set1Rep >= 2)
     globals.setBigMessage(Util::toStringInt(nlevel) + "-Back. Challenge Round!");
     else
     globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
     }
     globals.setMessage("Match by Color!", MESSAGE_NORMAL);
     */
    
    hud = new HudStage(player, tunnel);
    
    Quaternion camRot = player->getCombinedRotAndRoll();
    
    // Set lighting
    lightMain = OgreFramework::getSingletonPtr()->m_pSceneMgrMain->createLight("StageLight");
    lightMain->setDiffuseColour(1.0, 1.0, 1.0);
    lightMain->setSpecularColour(1.0, 1.0, 1.0);
    //lightMain->setAttenuation(10, 1.0, 0.0001, 0.0);
    lightNode = OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getRootSceneNode()->createChildSceneNode("lightNode");
    lightNode->attachObject(lightMain);
    
    // Set initial transformations for camera, light, skynode
    OgreFramework::getSingletonPtr()->m_pCameraMain->setPosition(player->getCamPos());
    OgreFramework::getSingletonPtr()->m_pCameraMain->setOrientation(camRot);
    if (OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode())
        OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode()->setOrientation(player->getCombinedRotAndRoll());
    if (lightNode)
        lightNode->setPosition(OgreFramework::getSingletonPtr()->m_pCameraMain->getPosition());
    
    // Set tutorial slides for certain thingies
    if (tunnel->getMode() == STAGE_MODE_RECESS || tunnel->getMode() == STAGE_MODE_TEACHING || tunnel->getHighestCriteria() <= 0)
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_ZERO_BACK);
    if (tunnel->getHighestCriteria() == 1)
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_ONE_BACK);
    if (tunnel->getHighestCriteria() == 2)
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_TWO_BACK);
    if (tunnel->getPhase() == 'A')
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_COLOR_SOUND);
    if (tunnel->getPhase() == 'B')
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_SHAPE_SOUND);
    if (tunnel->getPhase() == 'C')
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_SOUND_ONLY);
    if (tunnel->getPhase() == 'D')
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_HOLDOUT);

    spinVelocity = 0.0f;
    spinVelocityTarget = 0.0f;
    damping = 0.0f;
    freeMotion = false;
}
Esempio n. 12
0
void OgreApp::setLevel(Evaluation forced, bool forward)
{
    globals.clearMessage();
    
    std::vector<NavigationLevel> navLevels;
    if (tunnel)
    {
        levelMgr->updatePlayerSkill(tunnel, forced);
        if (forward)
            levelMgr->incrementSchedIndex();
        else
            levelMgr->decrementSchedIndex();
        navLevels = tunnel->getNavLevels();
        player->unlink();
        tunnel->unlink();
        hud->unlink();
    }
    
    // Don't gen a new tunnel if our schedule is over
    if (!predictSessionOver())
    {
        tunnel = levelMgr->getNextLevel(tunnel);
        if (navLevels.size() <= 0) // First stage
        {
            globals.appendMessage("\n\nSession No: " + Util::toStringInt(player->getSkillLevel().sessionID), MESSAGE_NORMAL);
        }
    }
    // Link/Relink Pointers
    tunnel->link(player, hud);
    player->link(tunnel, hud);
    hud->init(tunnel, player);
    
    if (!predictSessionOver())
    {
        // If repeated, repeat the same navigation level
        if (levelMgr->isRepeatingPhase())
            tunnel->setNavigationLevels(navLevels);
        else
            tunnel->setNavigationLevels();
        tunnel->constructTunnel(globals.tunnelSections);
        // If nback is same then panels are changing, keep speed same
        player->setCamPos(tunnel->getStart() + tunnel->getCurrent()->getForward() * globals.tunnelSegmentDepth);
        player->setCamRot(tunnel->getCurrent()->getQuaternion());
        player->setDesireRot(player->getCamRot());
        player->newTunnel(musicMode == MUSIC_ENABLED);
        
        Plane plane;
        switch (globals.setSkyBox)
        {
            case 0:
                plane.d = 3000;
                plane.normal = Ogre::Vector3(0, 0, 1);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setSkyPlane(true, plane, "General/SpaceSkyPlane", 80, 4, true);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setFog(Ogre::FOG_LINEAR, Ogre::ColourValue::ZERO, 0.0, 300.0, 600.0);
                OgreFramework::getSingletonPtr()->m_pViewportMain->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode()->resetToInitialState();
                break;
            case 1:
                plane.d = 160;
                plane.normal = Ogre::Vector3(0, 0, 1);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setSkyPlane(true, plane, "General/TestSkyPlane0", 1.9, 1, true);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setFog(Ogre::FOG_LINEAR, Ogre::ColourValue(1.0, 0.95, 0.3, 0.0), 0.0, 500.0,  800.0);
                OgreFramework::getSingletonPtr()->m_pViewportMain->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode()->resetToInitialState();
                break;
            default:
                plane.d = 3000;
                plane.normal = Ogre::Vector3(0, 0, 1);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setSkyPlane(true, plane, "General/SpaceSkyPlane", 80, 4, true);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setFog(Ogre::FOG_LINEAR, Ogre::ColourValue::ZERO, 0.0, 300.0, 600.0);
                OgreFramework::getSingletonPtr()->m_pViewportMain->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode()->resetToInitialState();
                break;
        }
    }
    
    // Stop the game
    setPause(true);
}
Esempio n. 13
0
float LevelManager::extractTime(char c) const
{
    PlayerLevel skillLevel = player->getSkillLevel();
    switch (c)
    {
        case 'A':
        {
            if (skillLevel.set1Rep <= 0)
            {
                if (!configStageType(globals.configPath, globals.configBackup, "Arep1"))
                    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            }
            else if (skillLevel.set1Rep <= 1)
            {
                if (!configStageType(globals.configPath, globals.configBackup, "Arep2"))
                    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            }
            else
            {
                if (!configStageType(globals.configPath, globals.configBackup, "Arep3"))
                    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            }
            break;
        }
        case 'B':
        {
            if (skillLevel.set2Rep <= 0)
            {
                if (!configStageType(globals.configPath, globals.configBackup, "Brep1"))
                    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            }
            else if (skillLevel.set2Rep <= 1)
            {
                if (!configStageType(globals.configPath, globals.configBackup, "Brep2"))
                    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            }
            else
            {
                if (!configStageType(globals.configPath, globals.configBackup, "Brep3"))
                    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            }
            break;
        }
        case 'C':
        {
            if (skillLevel.set3Rep <= 0)
            {
                if (!configStageType(globals.configPath, globals.configBackup, "Crep1"))
                    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            }
            else if (skillLevel.set3Rep <= 1)
            {
                if (!configStageType(globals.configPath, globals.configBackup, "Crep2"))
                    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            }
            else
            {
                if (!configStageType(globals.configPath, globals.configBackup, "Crep3"))
                    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            }
            break;
        }
        case 'D':
        {
            if (!configStageType(globals.configPath, globals.configBackup, "D"))
                globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            break;
        }
        case 'E':
        {
            // Ignore Speed Trial...
            return 0.0;
        }
        case 'F':
        {
            if (!configStageType(globals.configPath, globals.configBackup, "F"))
                globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            break;
        }
        case 'G':
        {
            if (!configStageType(globals.configPath, globals.configBackup, "G"))
                globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            break;
        }
        case 'H':
        {
            if (!configStageType(globals.configPath, globals.configBackup, "H"))
                globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
            break;
        }
    }
    return globals.stageTime;
}
Esempio n. 14
0
void OgreApp::setupDemoScene()
{
    bool isSynced = false;
    globals.initPaths();
#if defined(NETWORKING)
#if defined(OGRE_IS_IOS)
    isSynced = syncConfig();
#endif
#endif
    
    seed = time(0);
    
    srand(seed);
    sessionOver = false;
    
    Util::generateMaterials();
    
    Util::createSphere(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "sphereMesh", 1.0, 8, 8);
    Util::createCylinder(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "cylinderMesh", 1.0, 1.0, 8);
    Util::createDiamond(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "diamondMesh", 1.0, 1.0);
    Util::createBox(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "boxMesh", 1.0, 1.0, 1.0);
    Util::createPlane(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "planeMesh", 1.0, 1.0);
    Util::createDefaultSegments(OgreFramework::getSingletonPtr()->m_pSceneMgrMain);
    
	origin = Vector3(0, 0, 0);
    
	OgreFramework::getSingletonPtr()->m_pCameraMain->setPosition(Vector3(origin.x, origin.y, origin.z + globals.tunnelSegmentDepth / 2));
	OgreFramework::getSingletonPtr()->m_pCameraMain->lookAt(origin);
    
    globals.initPaths();
    if (!configStageType(globals.configPath, globals.configBackup, "globalConfig"))
        globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
    
	player = new Player(
                        globals.playerName,
                        OgreFramework::getSingletonPtr()->m_pCameraMain->getPosition(),
                        OgreFramework::getSingletonPtr()->m_pCameraMain->getOrientation(),
                        globals.initCamSpeed,
                        globals.vineTOffset,
                        SPEED_CONTROL_AUTO,
                        seed,
                        "vinezors" + Util::toStringInt(seed) + ".csv");
	player->addVine(new Vine(OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getRootSceneNode(), player->getCamPos(), globals.vineRadius));
    player->setSounds(true);
    player->setRunningSpeed(globals.set1StartingSpeed, globals.set2StartingSpeed, globals.set3StartingSpeed, globals.trialStartingSpeed, globals.startingNav);
    if (!player->loadProgress(globals.savePath))
        std::cout << "WARNING: Save File could not be loaded correctly" << std::endl;
    globals.initLogs(player->getSkillLevel().sessionID);
    
    tunnel = NULL;
    hud = new Hud();
    
    // Determine length of time
    globals.sessionTime = globals.sessionTimeMin;
    if (player->getSkillLevel().sessionID >= 1)
        globals.sessionTime += ((globals.sessionTimeMax - globals.sessionTimeMin) / globals.expectedNumSessions) * (player->getSkillLevel().sessionID - 1);
    std::cout << "Session Length: " << globals.sessionTime << std::endl;
    
    levelMgr = new LevelManager(player, globals.scheduleMain, globals.scheduleRepeat, globals.scheduleRepeatRandomPool);
    
    setLevel(EVEN);
    
    Light* lightMain = OgreFramework::getSingletonPtr()->m_pSceneMgrMain->createLight("Light");
    lightMain->setDiffuseColour(1.0, 1.0, 1.0);
    lightMain->setSpecularColour(1.0, 1.0, 1.0);
    //lightMain->setAttenuation(3250, 1.0, 0.0014, 0.000007);
    lightNodeMain = OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getRootSceneNode()->createChildSceneNode("lightNode");
    lightNodeMain->attachObject(lightMain);
    lightNodeMain->setPosition(OgreFramework::getSingletonPtr()->m_pCameraMain->getPosition());
    
    if (!isSynced) {
        globals.setMessage("ERROR: Could not connect for updates.\nPlease contact the RA", MESSAGE_ERROR);
    }
    
#if defined(NETWORKING)
#if defined(OGRE_IS_IOS)
    syncLogs();
#endif
#endif
}
Esempio n. 15
0
void EngineStage::keyPressed(const OIS::KeyEvent &keyEventRef)
{
    switch (keyEventRef.key)
    {
        case OIS::KC_W:
        {
            player->setKeyUp(true);
            break;
        }
        case OIS::KC_A:
        {
            player->setKeyLeft(true);
            break;
        }
        case OIS::KC_S:
        {
            player->setKeyDown(true);
            break;
        }
        case OIS::KC_D:
        {
            player->setKeyRight(true);
            break;
        }
        case OIS::KC_SPACE:
        {
            player->setKeySpace(true);
            break;
        }
        case OIS::KC_LEFT:
        {
            activatePerformLeftMove();
            break;
        }
        case OIS::KC_RIGHT:
        {
            activatePerformRightMove();
            break;
        }
        case OIS::KC_UP:
        {
            activatePerformSwipeUp();
            break;
        }
        case OIS::KC_DOWN:
        {
            activatePerformSwipeDown();
            break;
        }
        case OIS::KC_1:
        {
            if (tunnel && tunnel->isMultiCollectionTask())
            {
                player->setToggleBack(3);
                tunnel->respondToToggleCheat();
            }
            break;
        }
        case OIS::KC_2:
        {
            if (tunnel && tunnel->isMultiCollectionTask())
            {
                player->setToggleBack(2);
                tunnel->respondToToggleCheat();
            }
            break;
        }
        case OIS::KC_3:
        {
            if (tunnel && tunnel->isMultiCollectionTask())
            {
                player->setToggleBack(1);
                tunnel->respondToToggleCheat();
            }
            break;
        }
        case OIS::KC_4:
        {
            if (tunnel && tunnel->isMultiCollectionTask())
            {
                // Bad hack but
                // Don't show 3-Back for multi-collection tasks of 1 or less.
                if (player->getLevelRequestRow() > 0)
                    player->setToggleBack(0);
                tunnel->respondToToggleCheat();
            }
            break;
        }
        case OIS::KC_P:
        {
            if (stageState == STAGE_STATE_RUNNING)
            {
                setPause(true);
                globals.appendMessage("\n\nPaused", MESSAGE_NORMAL);
                stageState = STAGE_STATE_PAUSE;
            }
            else
            {
                setPause(false);
                stageState = STAGE_STATE_RUNNING;
            }
            break;
        }
        case OIS::KC_Z:
        {
            activatePerformBeginLongPress();
            break;
        }
        case OIS::KC_X:
        {
            if (stageState == STAGE_STATE_RUNNING) player->performPowerUp("TractorBeam");
            break;
        }
        case OIS::KC_C:
        {
            player->setPowerUp("TimeWarp", true);
            if (stageState == STAGE_STATE_RUNNING) player->performPowerUp("TimeWarp");
            break;
        }
        case OIS::KC_V:
        {
            if (stageState == STAGE_STATE_RUNNING) player->performPowerUp("Shields");
            break;
        }
#ifdef DEBUG_MODE
        case OIS::KC_K:
        {
            if (stageState == STAGE_STATE_RUNNING) tunnel->setDone(FAIL);
            break;
        }
        case OIS::KC_L:
        {
            if (stageState == STAGE_STATE_RUNNING) tunnel->setDone(PASS);
            break;
        }
        case OIS::KC_G:
        {
            player->setGodMode(!player->getGodMode());
            std::cout << "God Mode: " << player->getGodMode() << std::endl;
            break;
        }
#endif
        default:
            break;
    }
}
Esempio n. 16
0
// This version follows a schedule specified when LevelManager was initialized
//
// Very big function...
// Hardcoded settings for five different area. Until the json files are implemented, this will
// be more modular. For now, it'll do.
Tunnel* LevelManager::getNextLevel(Tunnel* previousTunnel)
{
    // Extract previous information as the previous tunnel still exists
    Vector3 newOrigin = Vector3(0, 0, 0) + globals.tunnelReferenceForward * (globals.tunnelSegmentWidth / 2);
    Quaternion newRot = Quaternion(1, 0, 0, 0);
    Vector3 newForward = globals.tunnelReferenceForward;
    int oldNBack = previousTunnel ? previousTunnel->getNBack() : 0;
    GameMode oldGameMode = previousTunnel ? previousTunnel->getMode() : GAME_TIMED;
    if (previousTunnel)
    {
        delete previousTunnel;
    }
    
    GameMode nmode = GAME_PROFICIENCY;
    int nlevel = 0;
    int ncontrol = 1;
    
    if (!configStageType(globals.configPath, globals.configBackup, "globalConfig"))
        globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
    
    PlayerLevel skillLevel = player->getSkillLevel(); // Updated in previous tunnel and referenced for new tunnel

    nlevel = skillLevel.set1;
    ncontrol = 1;
    nmode = GAME_PROFICIENCY;
            
    globals.initCamSpeed = skillLevel.runSpeed1;
    globals.maxCamSpeed = skillLevel.maxSpeed;
            
    if (skillLevel.set1Rep <= 0)
    {
        if (!configStageType(globals.configPath, globals.configBackup, "Arep1"))
            globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
    }
    else if (skillLevel.set1Rep <= 1)
    {
        if (!configStageType(globals.configPath, globals.configBackup, "Arep2"))
            globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
    }
    else
    {
        if (!configStageType(globals.configPath, globals.configBackup, "Arep3"))
            globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
    }
            
    globals.stageTotalTargets1 = globals.stageTotalSignals * (globals.podNBackChance / 100.0);
    globals.stageTotalTargets2 = globals.stageTotalSignals * (globals.podNBackChance / 100.0);
    globals.stageTotalTargets3 = globals.stageTotalSignals * (globals.podNBackChance / 100.0);
            
    globals.signalTypes = std::vector<std::vector<PodInfo> >(4);
    globals.signalTypes[POD_SIGNAL_1].push_back(PodInfo(POD_SIGNAL_1, POD_BASIC, POD_COLOR_BLUE, POD_SHAPE_SPHERE, POD_SOUND_1));
    globals.signalTypes[POD_SIGNAL_2].push_back(PodInfo(POD_SIGNAL_2, POD_BASIC, POD_COLOR_GREEN, POD_SHAPE_SPHERE, POD_SOUND_2));
    globals.signalTypes[POD_SIGNAL_3].push_back(PodInfo(POD_SIGNAL_3, POD_BASIC, POD_COLOR_PINK, POD_SHAPE_SPHERE, POD_SOUND_3));
    globals.signalTypes[POD_SIGNAL_4].push_back(PodInfo(POD_SIGNAL_4, POD_BASIC, POD_COLOR_YELLOW, POD_SHAPE_SPHERE, POD_SOUND_4));
            
    if (skillLevel.set1Notify)
        globals.setBigMessage("Congratulations! You earned " + Util::toStringInt(nlevel) + "-Back!");
    else
    {
        if (skillLevel.set1Rep >= 2)
            globals.setBigMessage(Util::toStringInt(nlevel) + "-Back. Challenge Round!");
        else
            globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
    }
    globals.setMessage("Match by Color!", MESSAGE_NORMAL);

    Tunnel* ret = new Tunnel(
                             OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getRootSceneNode(),
                             newOrigin + newForward * (globals.tunnelSegmentWidth / 2),
                             newRot,
                             globals.tunnelSegmentWidth,
                             globals.tunnelSegmentDepth,
                             globals.tunnelMinAngleTurn,
                             globals.tunnelMaxAngleTurn,
                             getSchedNo(),
                             nmode,
                             getScheduleValue(),
                             nlevel,
                             ncontrol,
                             SOUTH,
                             globals.tunnelSegmentsPerSection,
                             globals.tunnelSegmentsPerPod,
                             globals.tunnelSegmentsPerDistractors,
                             globals.signalTypes);
    
    return ret;
}
Esempio n. 17
0
void EngineStage::update(float elapsed)
{
    switch (stageState)
    {
        case STAGE_STATE_INIT:
        {
            setup();
            setPause(true);
            if (tunnel->getMode() != STAGE_MODE_RECESS || tunnel->getMode() != STAGE_MODE_TEACHING)
                globals.appendMessage("\n\nSet Your Speed", MESSAGE_NORMAL);
            stageState = STAGE_STATE_PAUSE;
            
            hud->update(elapsed);
            hud->setOverlay(0, true);
            hud->setOverlay(1, false);
            hud->setOverlay(2, false);
            hud->setOverlay(3, false);
            hud->notifyGoButton(false);
            
            OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
            break;
        }
        case STAGE_STATE_RUNNING:
        {
            OgreFramework::getSingletonPtr()->m_pSoundMgr->update(elapsed);
            
#if defined(OGRE_IS_IOS)
            // Update the game state
            updateSpin(elapsed);
#endif
            tunnel->update(elapsed);
            
            if (tunnel->needsCleaning())
            {
                completeStage(EVEN);
                stageState = STAGE_STATE_PROMPT;
                setPause(true);
                
                std::string finalScoreMessage = Util::toStringInt(player->getScore());
                globals.appendMessage("\nScore " + finalScoreMessage + "\n\nPlay Again?", MESSAGE_NORMAL);
            }

            hud->update(elapsed);
            hud->setOverlay(0, true);
            hud->setOverlay(1, false);
            hud->notifyGoButton(false);
            
            // Graphical view changes from camera, light, and skybox
            Quaternion camRot = player->getCombinedRotAndRoll();
            OgreFramework::getSingletonPtr()->m_pCameraMain->setPosition(player->getCamPos());
            OgreFramework::getSingletonPtr()->m_pCameraMain->setOrientation(camRot);
            if (OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode())
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode()->setOrientation(player->getCombinedRotAndRoll());
            if (lightNode)
                lightNode->setPosition(OgreFramework::getSingletonPtr()->m_pCameraMain->getPosition());
            
            OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
            
            // See by the end of this frame if we have a tutorial popup, if so pause the game, keep the music running
            if (player->getTutorialMgr()->isVisible())
            {
                setPause(true, false);
                globals.appendMessage("\n\nPaused", MESSAGE_NORMAL);
                stageState = STAGE_STATE_PAUSE;
            }
            break;
        }
        case STAGE_STATE_PAUSE:
        {
            // Navigation Debug Keys
            if (player->getKeyUp())
                player->move(Vector3(player->getCamForward() * globals.initCamSpeed * elapsed));
            if (player->getKeyDown())
                player->move(Vector3(player->getCamForward() * -globals.initCamSpeed * elapsed));
            if (player->getKeyLeft())
                player->move(Vector3(player->getCamRight() * -globals.initCamSpeed * elapsed));
            if (player->getKeyRight())
                player->move(Vector3(player->getCamRight() * globals.initCamSpeed * elapsed));
            
            OgreFramework::getSingletonPtr()->m_pCameraMain->setPosition(player->getCamPos());
            OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
            
            if (!player->hasTriggeredStartup())
            {
                int sliderSpeed = hud->getSpeedSlider()->getIndex();
                globals.initCamSpeed = Util::clamp(sliderSpeed, globals.minCamSpeed, globals.maxCamSpeed);
                player->setSpeedParameters(globals.initCamSpeed, globals.minCamSpeed, globals.maxCamSpeed);
            }
            
            hud->update(elapsed);
            hud->setOverlay(0, true);
            hud->setOverlay(1, false);
            hud->notifyGoButton(true);
            break;
        }
        case STAGE_STATE_PROMPT:
        {
            hud->update(elapsed);
            hud->setOverlay(0, true);
            hud->setOverlay(1, true);
            hud->notifyGoButton(false);
            
            OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setAmbientLight(Ogre::ColourValue(0.1, 0.1, 0.1));
            break;
        }
        case STAGE_STATE_DONE:
        {
            // Unpause Settings but without the sound deactivating
            engineStateMgr->requestPopEngine();
            break;
        }
    }
}
Esempio n. 18
0
void OgreApp::setupDemoScene()
{
    seed = time(0);
    srand(seed);
    sessionOver = false;
    
    Util::generateMaterials();
    
    Util::createSphere(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "sphereMesh", 1.0, 256, 4);
    Util::createCylinder(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "cylinderMesh", 1.0, 1.0, 8);
    Util::createDiamond(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "diamondMesh", 1.0, 1.0);
    Util::createBox(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "boxMesh", 1.0, 1.0, 1.0);
    Util::createPlane(OgreFramework::getSingletonPtr()->m_pSceneMgrMain, "planeMesh", 1.0, 1.0);
    Util::createDefaultSegments(OgreFramework::getSingletonPtr()->m_pSceneMgrMain);
    
	origin = Vector3(0, 0, 0);
    
	OgreFramework::getSingletonPtr()->m_pCameraMain->setPosition(Vector3(origin.x, origin.y, origin.z + globals.tunnelSegmentDepth / 2));
	OgreFramework::getSingletonPtr()->m_pCameraMain->lookAt(origin);
    
    globals.initPaths();
    if (!configStageType(globals.configPath, globals.configBackup, "globalConfig"))
        globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
    
	player = new Player(
                        globals.playerName,
                        OgreFramework::getSingletonPtr()->m_pCameraMain->getPosition(),
                        OgreFramework::getSingletonPtr()->m_pCameraMain->getOrientation(),
                        globals.initCamSpeed,
                        globals.vineTOffset,
                        SPEED_CONTROL_AUTO,
                        seed,
                        "vinezors" + Util::toStringInt(seed) + ".csv");
	player->addVine(new Vine(OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getRootSceneNode(), player->getCamPos(), globals.vineRadius));
    player->setSounds(true);
    player->setRunningSpeed(globals.set1StartingSpeed, globals.set2StartingSpeed, globals.set3StartingSpeed, globals.trialStartingSpeed, globals.startingNav);
    if (player->getName() != "subject999")
    {
        if (!player->loadProgress(globals.savePath))
            std::cout << "WARNING: Save File could not be loaded correctly" << std::endl;
    }
    else
    {
        // Special training session for space game
        PlayerLevel skill = player->getSkillLevel();
        skill.sessionID = 0;
        skill.set1 = 1;
        skill.set2 = 1;
        skill.set3 = 1;
        skill.set1Rep = 0;
        skill.set2Rep = 1;
        skill.set3Rep = 2;
        player->setSkillLevel(skill);
    }
    globals.initLogs(player->getSkillLevel().sessionID);
    
    tunnel = NULL;
    hud = new Hud();
    
    // Determine length of time
    globals.sessionTime = (globals.sessionTimeMin + ((globals.sessionTimeMax - globals.sessionTimeMin) / globals.expectedNumSessions) * player->getSkillLevel().sessionID);
    
    std::cout << "Session Length: " << globals.sessionTime << std::endl;
    
    levelMgr = new LevelManager(player, globals.scheduleMain, globals.scheduleRepeat, globals.scheduleRepeatRandomPool);
    
    setLevel(EVEN);
    
//    OgreFramework::getSingletonPtr()->m_pCameraMain
    backSphere = OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getRootSceneNode()->createChildSceneNode("backSphereNode");
    Entity* backContentEntity = backSphere->getCreator()->createEntity("backSphereEntity", "sphereMesh");
    backContentEntity->setMaterialName("General/PodUnknown");
    backSphere->attachObject(backContentEntity);
    backSphere->scale(globals.podHeadRadius * 4, globals.podHeadRadius * 4, globals.podHeadRadius);
    backSphere->translate(Vector3(0, 0, -globals.tunnelSegmentDepth * 20));
    
}
Esempio n. 19
0
bool OgreFramework::initOgre(OIS::KeyListener *pKeyListener, OIS::MouseListener *pMouseListener, Ogre::RenderTargetListener *pRenderTargetListener)
#endif
{
    new Ogre::LogManager();
    
	m_pLog = Ogre::LogManager::getSingleton().createLog("OgreLogfile.log", true, true, false);
	m_pLog->setDebugOutputEnabled(true);
    
    String pluginsPath;
    // only use plugins.cfg if not static
#ifndef OGRE_STATIC_LIB
    pluginsPath = m_ResourcePath + "plugins.cfg";
#endif
    m_pRoot = new Ogre::Root(pluginsPath, Ogre::macBundlePath() + "/ogre.cfg");
    
#ifdef OGRE_STATIC_LIB
    m_StaticPluginLoader.load();
#endif
    if(m_pRoot->restoreConfig() || m_pRoot->showConfigDialog())
        m_pRenderWnd = m_pRoot->initialise(true, "");
    else
        return false;
    m_pRenderWnd->resize(600, 800);
    m_pRenderWnd->windowMovedOrResized();
    //m_pRenderWnd->setFullscreen(true, 800, 600);
    globals.screenWidth = m_pRenderWnd->getWidth();
    globals.screenHeight = m_pRenderWnd->getHeight();
    globals.set();
    
    /*
     Ogre::NameValuePairList paramsWnd;
     paramsWnd["border"] = "fixed";
     m_pRenderWnd = m_pRoot->createRenderWindow(wndTitle, Util::SCREEN_WIDTH, Util::SCREEN_HEIGHT, false, &paramsWnd);
     */
	m_pSceneMgrMain = m_pRoot->createSceneManager(ST_GENERIC, "SceneManagerMain");
	//m_pSceneMgrSide = m_pRoot->createSceneManager(ST_GENERIC, "SceneManagerSide");
	m_pSceneMgrMain->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
	//m_pSceneMgrSide->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
    
	m_pCameraMain = m_pSceneMgrMain->createCamera("CameraMain");
	m_pCameraMain->setPosition(Vector3(0, 0, 50));
	m_pCameraMain->lookAt(Vector3(0, 0, 0));
	m_pCameraMain->setNearClipDistance(0.1);
//    m_pCameraMain->setFOVy(Degree(45));
    //m_pCameraMain->setFarClipDistance(500.0);
	m_pViewportMain = m_pRenderWnd->addViewport(m_pCameraMain, 1,
                                                0.0,
                                                0.0,
                                                float(globals.viewportMainWidth_modeNone) / globals.screenWidth,
                                                float(globals.viewportMainHeight_modeNone) / globals.screenHeight);
	m_pCameraMain->setAspectRatio(Real(m_pViewportMain->getActualWidth()) / Real(m_pViewportMain->getActualHeight()));
	m_pViewportMain->setCamera(m_pCameraMain);
    m_pViewportMain->getTarget()->addListener(pRenderTargetListener);
    /*
     m_pCameraSide = m_pSceneMgrSide->createCamera("CameraSide");
     m_pCameraSide->setPosition(Vector3(0, 0, 30));
     m_pCameraSide->lookAt(Vector3(0, 0, 0));
     m_pCameraSide->setNearClipDistance(1);
     m_pCameraSide->setOrthoWindow(10.0, 25.0);
     m_pCameraSide->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
     m_pViewportSide = m_pRenderWnd->addViewport(m_pCameraSide, 0,
     float(globals.viewportMainWidth_modeNone) / globals.screenWidth,
     0.0,
     float(globals.viewportSideWidth_modeNone) / globals.screenWidth,
     float(globals.viewportSideHeight_modeNone) / globals.screenHeight);
     m_pViewportSide->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
     m_pCameraSide->setAspectRatio(Real(m_pViewportSide->getActualWidth()) / Real(m_pViewportSide->getActualHeight()));
     m_pViewportSide->setCamera(m_pCameraSide);
     m_pViewportSide->getTarget()->addListener(pRenderTargetListener);
     */
	unsigned long hWnd = 0;
    OIS::ParamList paramList;
    m_pRenderWnd->getCustomAttribute("WINDOW", &hWnd);
    
	paramList.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(hWnd)));
    
	m_pInputMgr = OIS::InputManager::createInputSystem(paramList);
    
#if !defined(OGRE_IS_IOS)
    m_pKeyboard = static_cast<OIS::Keyboard*>(m_pInputMgr->createInputObject(OIS::OISKeyboard, true));
	m_pMouse = static_cast<OIS::Mouse*>(m_pInputMgr->createInputObject(OIS::OISMouse, true));
    
	m_pMouse->getMouseState().height = m_pRenderWnd->getHeight();
	m_pMouse->getMouseState().width	 = m_pRenderWnd->getWidth();
    
	if(pKeyListener == 0)
		m_pKeyboard->setEventCallback(this);
	else
		m_pKeyboard->setEventCallback(pKeyListener);
    
	if(pMouseListener == 0)
		m_pMouse->setEventCallback(this);
	else
		m_pMouse->setEventCallback(pMouseListener);
#else
    //	m_pMouse = static_cast<OIS::MultiTouch*>(m_pInputMgr->createInputObject(OIS::OISMultiTouch, true));
	//if(pMouseListener == 0)
	//	m_pMouse->setEventCallback(this);
	//else
	//	m_pMouse->setEventCallback(pMouseListener);
#endif
    
    
	Ogre::String secName, typeName, archName;
	Ogre::ConfigFile cf;
    
    cf.load(m_ResourcePath + "resources.cfg");
    
    m_pResourceGroupMgr = Ogre::ResourceGroupManager::getSingletonPtr();
    m_pOverlayMgr = Ogre::OverlayManager::getSingletonPtr();
    m_pFontMgr = Ogre::FontManager::getSingletonPtr();
    m_pMeshMgr = Ogre::MeshManager::getSingletonPtr();
    m_pMaterialMgr = Ogre::MaterialManager::getSingletonPtr();
    m_pTextureMgr = Ogre::TextureManager::getSingletonPtr();
    m_pCompositeMgr = CompositorManager::getSingletonPtr();
    
	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;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || defined(OGRE_IS_IOS)
            // OS X does not set the working directory relative to the app,
            // In order to make things portable on OS X we need to provide
            // the loading with it's own bundle path location
            if (!Ogre::StringUtil::startsWith(archName, "/", false)) // only adjust relative dirs
                archName = Ogre::String(m_ResourcePath + archName);
#endif
            m_pResourceGroupMgr->addResourceLocation(archName, typeName, secName);
        }
    }
    
    Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
    
	m_pTrayMgr = new OgreBites::SdkTrayManager("TrayMgr", m_pRenderWnd, m_pMouse, this);
    //m_pTrayMgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
    //m_pTrayMgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
    m_pTrayMgr->hideCursor();
    m_pTrayMgr->setListener(this);
    m_pTrayMgr->setTrayPadding(10.0);
    
    Ogre::FontManager::getSingleton().getByName("SdkTrays/Caption")->load();
    //  m_quitButton = OgreFramework::getSingletonPtr()->m_pTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT, "sdkQuitButton", "QUIT", 250);
    
    m_pSoundMgr = OgreOggSound::OgreOggSoundManager::getSingletonPtr();
    m_pSoundMgr->init();
    m_pSoundMgr->createSound("Music1", "pianomusic2.ogg", false, true, true);
    m_pSoundMgr->createSound("Music4", "pianomusic5.ogg", false, true, true);
    m_pSoundMgr->createSound("Music5", "pianomusic.ogg", false, true, true);
    //m_pSoundMgr->createSound("SoundGreatFeedback", "GoodFeedback.wav", false, false, true);
    m_pSoundMgr->createSound("SoundGreatFeedback", "ding3up3.wav", false, false, true);
    m_pSoundMgr->createSound("SoundGoodFeedback", "energyup.wav", false, false, true);
    m_pSoundMgr->createSound("SoundBadFeedback", "BadFeedback.wav", false, false, true);
    m_pSoundMgr->createSound("SoundCollision", "wrong_answer_feedback.wav", false, false, true);
    m_pSoundMgr->createSound("SoundPod1", "pod4.wav", false, false, true);           // Rose
    m_pSoundMgr->createSound("SoundPod2", "pod3.wav", false, false, true);            // Iris
    m_pSoundMgr->createSound("SoundPod3", "bubbleSound.wav", false, false, true);    // Bubble Flower
    m_pSoundMgr->createSound("SoundPod4", "pod2.wav", false, false, true);            // Daisy
    m_pSoundMgr->createSound("SoundStartup", "beeTakeoff.wav", false, false, true);
    
	Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    
	Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    
	m_pTimer = OGRE_NEW Ogre::Timer();
	m_pTimer->reset();
    
	m_pRenderWnd->setActive(true);
    
	return true;
}
Esempio n. 20
0
bool OgreFramework::initOgre(OIS::KeyListener *pKeyListener, OIS::MouseListener *pMouseListener)
#endif
{
    new Ogre::LogManager();
    
	m_pLog = Ogre::LogManager::getSingleton().createLog("OgreLogfile.log", true, true, false);
	m_pLog->setDebugOutputEnabled(true);
    
    String pluginsPath;
    // only use plugins.cfg if not static
#ifndef OGRE_STATIC_LIB
    pluginsPath = m_ResourcePath + "plugins.cfg";
#endif
    m_pRoot = new Ogre::Root(pluginsPath, Ogre::macBundlePath() + "/ogre.cfg");
    
    // OgreOggSound is still a dynamic library (dylib)
    // OgreOggSound::OgreOggSoundPlugin* mOgreOggSoundPlugin = OGRE_NEW OgreOggSound::OgreOggSoundPlugin();
    // m_pRoot->installPlugin(mOgreOggSoundPlugin);
#ifdef OGRE_STATIC_LIB
    m_StaticPluginLoader.load();
#endif

    if(m_pRoot->restoreConfig() || m_pRoot->showConfigDialog())
        m_pRenderWnd = m_pRoot->initialise(true, "");
    else
        return false;
    //m_pRenderWnd->resize(800, 600);
    //m_pRenderWnd->setFullscreen(true, 1024, 800);
    globals.screenWidth = m_pRenderWnd->getWidth();
    globals.screenHeight = m_pRenderWnd->getHeight();
    globals.set();
    
	m_pSceneMgrMain = m_pRoot->createSceneManager(ST_GENERIC, "SceneManagerMain");
    m_pSceneMgrMain->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
    
	m_pCameraMain = m_pSceneMgrMain->createCamera("CameraMain");
	m_pCameraMain->setPosition(Vector3(0, 0, 50));
	m_pCameraMain->lookAt(Vector3(0, 0, 0));
	m_pCameraMain->setNearClipDistance(0.1);
	m_pViewportMain = m_pRenderWnd->addViewport(m_pCameraMain);
	m_pViewportMain->setCamera(m_pCameraMain);
    
    Ogre::OverlaySystem* m_pOverlaySystem = new Ogre::OverlaySystem();
    m_pSceneMgrMain->addRenderQueueListener(m_pOverlaySystem);
    
	unsigned long hWnd = 0;
    OIS::ParamList paramList;
    m_pRenderWnd->getCustomAttribute("WINDOW", &hWnd);
    
	paramList.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(hWnd)));
    
	m_pInputMgr = OIS::InputManager::createInputSystem(paramList);
    
#if !defined(OGRE_IS_IOS)
    m_pKeyboard = static_cast<OIS::Keyboard*>(m_pInputMgr->createInputObject(OIS::OISKeyboard, true));
	m_pMouse = static_cast<OIS::Mouse*>(m_pInputMgr->createInputObject(OIS::OISMouse, true));
    
	m_pMouse->getMouseState().height = m_pRenderWnd->getHeight();
	m_pMouse->getMouseState().width	 = m_pRenderWnd->getWidth();
    
	if(pKeyListener == 0)
		m_pKeyboard->setEventCallback(this);
	else
		m_pKeyboard->setEventCallback(pKeyListener);
    
	if(pMouseListener == 0)
		m_pMouse->setEventCallback(this);
	else
		m_pMouse->setEventCallback(pMouseListener);
#endif
    
    
	Ogre::String secName, typeName, archName;
	Ogre::ConfigFile cf;
    
    cf.load(m_ResourcePath + "resources.cfg");
    
    m_pResourceGroupMgr = Ogre::ResourceGroupManager::getSingletonPtr();
    m_pOverlayMgr = Ogre::OverlayManager::getSingletonPtr();
    m_pFontMgr = Ogre::FontManager::getSingletonPtr();
    m_pMeshMgr = Ogre::MeshManager::getSingletonPtr();
    m_pMaterialMgr = Ogre::MaterialManager::getSingletonPtr();
    m_pTextureMgr = Ogre::TextureManager::getSingletonPtr();
    m_pCompositeMgr = CompositorManager::getSingletonPtr();
    
	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;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || defined(OGRE_IS_IOS)
            // OS X does not set the working directory relative to the app,
            // In order to make things portable on OS X we need to provide
            // the loading with it's own bundle path location
            if (!Ogre::StringUtil::startsWith(archName, "/", false)) // only adjust relative dirs
                archName = Ogre::String(m_ResourcePath + archName);
#endif
            m_pResourceGroupMgr->addResourceLocation(archName, typeName, secName);
        }
    }
    
    Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");

    m_pSoundMgr = OgreOggSound::OgreOggSoundManager::getSingletonPtr();
    m_pSoundMgr->init();
    
    m_pSoundMgr->createSound("SoundGreatFeedback", "ding3up3.wav", false, false, true);
    m_pSoundMgr->createSound("SoundGoodFeedback", "energyup.wav", false, false, true);
    m_pSoundMgr->createSound("SoundBadFeedback", "wrongtriangle.wav", false, false, true);
    m_pSoundMgr->createSound("SoundMissFeedback", "misstriangle.wav", false, false, true);
    m_pSoundMgr->createSound("SoundCollision", "laser.wav", false, false, true);
    m_pSoundMgr->createSound("SoundStartup", "shipstartup.wav", false, false, true);
    m_pSoundMgr->createSound("SoundBoost", "ExhaustSound.wav", false, true, true);
    m_pSoundMgr->createSound("SoundButtonPress", "menuButton.wav", false, false, true);
    m_pSoundMgr->createSound("SoundFirework", "distantboom.wav", false, false, true);
    m_pSoundMgr->createSound("SoundDing", "positiveding.wav", false, false, true);
    
    m_pSoundMgr->createSound("GateOpen", "gateopen.wav", false, false, true);
    m_pSoundMgr->createSound("GateClose", "gateclose.wav", false, false, true);
    
    m_pSoundMgr->createSound("LevelFail", "down.wav", false, false, true);
    m_pSoundMgr->createSound("LevelPass", "LevelPass.wav", false, false, true);
    
	Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    
	m_pTimer = OGRE_NEW Ogre::Timer();
	m_pTimer->reset();
    
    OgreBites::InputContext inputContext;
    inputContext.mMouse = m_pMouse;
    inputContext.mKeyboard = m_pKeyboard;
    m_pTrayMgr = new OgreBites::SdkTrayManager("TrayMgr", m_pRenderWnd, inputContext, this);
    //m_pTrayMgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
    //m_pTrayMgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
    //m_pTrayMgr->hideCursor();
    
	m_pRenderWnd->setActive(true);
    
	return true;
}