예제 #1
0
int main(int argc, char** argv)
{
    MyApplication app;

    try{
        app.go();
    }
    catch(Ogre::Exception& e)
    {
        
    }

    return 0;
}
예제 #2
0
파일: main.cpp 프로젝트: sub77/hobbycode
int main(int argc, char* argv[])
{

       
        srand((unsigned int)time(NULL));

        SDL_Init(SDL_INIT_JOYSTICK);
        if(SDL_NumJoysticks() > 0)
        {
                // Setup the joystick.
                std::cout << "========================================" << std::endl;
                std::cout << "Initializing game controller: " << SDL_JoystickName(0)
                        << std::endl;
                gGamePad = SDL_JoystickOpen(0);
                std::cout << SDL_JoystickNumAxes(gGamePad) << " axes" << std::endl;
                std::cout << SDL_JoystickNumBalls(gGamePad) << " trackballs" << std::endl;
                std::cout << SDL_JoystickNumHats(gGamePad) << " hats" << std::endl;
                std::cout << SDL_JoystickNumButtons(gGamePad) << " buttons" << std::endl;
                std::cout << "========================================" << std::endl;
        }
        else
        {
                std::cout << "========================================" << std::endl;
                std::cout << "No game controller detected" << std::endl;
                std::cout << "========================================" << std::endl;
        }

        //Ogre::Overlay* trialOverlay;

        ///// The current amount of elapsed time within a trial.
        //Ogre::Real mCurrentTrialTime;

        ///// The length of each trial in seconds.
        //Ogre::Real mTrialLength;

        ///// The rewards received during a single trial, in rewards per step.
        //verve::real mAvgRewardPerStep;

       
        if (!gEngine.init())
        {
                return 0;
        }
       

        /*
        gEngine.setUpdateMode(SimulationEngine::SIMULATE_REAL_TIME_MULTIPLE, 1);
        */

        //// Set to capture frames at 29.97 fps.
        //engine.setUpdateMode(SIMULATE_CONSTANT_CHUNK, 0.0333667);

        /*
        // Use feet for this simulation.
        gEngine.getSimulator()->setGravity(opal::Vec3r(0, -30, 0));
        gEngine.getSimulator()->setStepSize(gPhysicsStepSize);

        // Make sure we get notified at the end of each step.
        gEngine.getSimulator()->addPostStepEventHandler(&gPostStepEventHandler);

        */
       
       
        // Create the robot.
        opal::Matrix44r robotTransform;
        robotTransform.translate(0, 1, 0);
        gRobot = new Robot(gEngine, 5);
        gRobot->init("../data/blueprints/robot1.xml", "Plastic/LightBlue",
                0.5, robotTransform, 2);
        gRobot->resetBodyAndCreateNewAgent();
        gRobot->resetBodyAndSTM();
        gRobot->randomizeState();
        gRobot->getFLMotor()->setMaxTorque((opal::real)2);
        gRobot->getFRMotor()->setMaxTorque((opal::real)2);
        gRobot->getFLMotor()->setMaxVelocity(1000);
        gRobot->getFRMotor()->setMaxVelocity(1000);


        // Create the car.
        opal::Matrix44r carTransform;
        carTransform.translate(-12, 2, 4);
        gCar = new Car(gEngine);
        gCar->init("../data/blueprints/car1.xml", "Plastic/Blue", 1,
                carTransform, 1);
       

        //DataFile dataFile(mNumTrialsPerRun);
        //updateOverlayData(trial);
        //mAvgRewardPerStep = 0;
        //mCurrentTrialTime = 0;
       
        gAgentDebugger = new AgentVisualDebugger(gEngine.getSceneManager());
        gAgentDebugger->setAgent(gRobot->getAgent());
        gAgentDebugger->setDisplayEnabled(false);
       
       
        /*
        Ogre::OverlayManager::getSingleton().getByName("Verve/Debug")->hide();
        Ogre::OverlayManager::getSingleton().getByName("Core/DebugOverlay")->hide();

        // Setup camera.
        gEngine.getCamera()->setPosition(opal::Point3r(0, 25, 25));
        gEngine.getCamera()->lookAt(opal::Point3r(0, (opal::real)0.1, 0));
        gEngine.setCameraMoveSpeed(15);
        */

        //setupEnvironment();
       
        gEngine.go();

        //mainLoop();

        delete gRobot;
        delete gCar;
        delete gAgentDebugger;
        return 0;
}