当前位置: 首页>>代码示例>>C++>>正文


C++ Object::addTrait方法代码示例

本文整理汇总了C++中kernel::Object::addTrait方法的典型用法代码示例。如果您正苦于以下问题:C++ Object::addTrait方法的具体用法?C++ Object::addTrait怎么用?C++ Object::addTrait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kernel::Object的用法示例。


在下文中一共展示了Object::addTrait方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: detectOneObject

      void TestDetector::detectOneObject()
      {
        InternalMessage("Model","Model::TestDetector::detectOneObject entering") ;
        /*!
          We create a ship with a detector and a second object to detect.
        */
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestDetector::detectOneObject")) ;
        model->init() ;

        Kernel::Object* system = model->createObject() ;

        Kernel::Object* ship = system->createObject() ;
        ship->addTrait(new Positioned()) ;
        ship->addTrait(new Oriented()) ;
        ship->addTrait(new Mobile()) ;
        ship->addTrait(new Solid(Mesh("test_ship.mesh"))) ;
        ship->addTrait(new Massive(Mass::Kilogram(1000))) ;
        ship->addTrait(new Computer()) ;
        ship->addTrait(new Detector()) ;
        Detector::connect(ship,ship) ;

        Kernel::Object* ship2 = system->createObject() ;
        ship2->addTrait(new Positioned(Position::Meter(0,0,500))) ;
        ship2->addTrait(new Massive(Mass::Kilogram(1000))) ;
        ship2->addTrait(new Oriented()) ;
        ship2->addTrait(new Mobile()) ;
        ship2->addTrait(new Solid(Mesh("test_ship.mesh"))) ;

        std::set<Kernel::Object*> detected(ship->getTrait<Computer>()->getDetectedObjects()) ;

        CPPUNIT_ASSERT(!detected.empty()) ;
        CPPUNIT_ASSERT(detected.find(ship2) != detected.end()) ;

        InternalMessage("Model","Model::TestDetector::detectOneObject leaving") ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:35,代码来源:test_detector.cpp

示例2: mouseCursor

      void TestMenu::mouseCursor()
      {
        InternalMessage("Input","Input::TestMenu::mouseCursor entering") ;

        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestMenu::mouseCursor")) ;
        model->init() ;
        
        Kernel::Object* menu = model->createObject() ;
        menu->addTrait(new Model::Menu("Demo7Windows.layout")) ;
        Kernel::Object* observer = model->createObject() ;
        observer->addTrait(new Model::Observer()) ;
        observer->addTrait(new Model::Player()) ;
        observer->addTrait(new Model::Positionned()) ;
        
        Kernel::Timer timer ;
        Kernel::Timer global_timer ;
        
        while (global_timer.getSecond() < 20)
        {
          float seconds = timer.getSecond() ;
          if (seconds != 0)
          {
            timer.reset() ;
          }
          model->update(seconds) ;
        }        
        
        InternalMessage("Input","Input::TestMenu::mouseCursor leaving") ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:29,代码来源:test_menu.cpp

示例3: beamEnergy

      void TestLaser::beamEnergy()
      {
        InternalMessage("Model","Model::TestLaser::beamEnergy entering") ;
        // we construct a complete system
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestLaser::testFire")) ;
        model->init() ;

        // should be a PhysicalWorld
        Kernel::Object* system = model->createObject() ;
        CPPUNIT_ASSERT(system->getTrait<PhysicalWorld>()) ;

        Kernel::Object* ship = system->createObject() ;
        ship->addTrait(new Positionned()) ;
        ship->addTrait(new Oriented()) ;
        ship->addTrait(new Mobile()) ;
        ship->addTrait(new Massive(Mass::Kilogram(1000))) ;
        ship->addTrait(new Laser(Position(),Orientation(),Energy::Joule(10))) ;
        CPPUNIT_ASSERT(ship->getTrait<PhysicalObject>()) ;
        CPPUNIT_ASSERT(ship->getTrait<PhysicalWorld>()) ;

        CPPUNIT_ASSERT(system->getChildren().size()==1) ;

        InternalMessage("Model","built ship") ;

        ship->call("fire") ;

        InternalMessage("Model","fire") ;
        CPPUNIT_ASSERT(system->getDescendants<LaserBeam>().size()==1) ;
        CPPUNIT_ASSERT(system->getDescendants<Shot>().size()==1) ;

        std::set<LaserBeam*> beams = system->getDescendants<LaserBeam>() ;
        LaserBeam* beam = *(beams.begin()) ;
        
        CPPUNIT_ASSERT(beam->getEnergy().Joule()==10) ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:35,代码来源:test_laser.cpp

示例4: steeringFullBackShouldTurn

      void TestAgent::steeringFullBackShouldTurn()
      {
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestAgent::steeringFullBackShouldTurn")) ;
        model->init() ;

        Kernel::Object* system = model->createObject() ;
        system->addTrait(new Model::StellarSystem()) ;
        system->addTrait(new Model::Positioned()) ;

        Kernel::Object* ship = Model::createShip(system) ;
        Kernel::Object* agent = Model::createAI(ship) ;

        Implementation::Agent* agent_controler = getAgentController(agent) ;

        /*
          should perform a full turn :
          <--       -->
          ship      steering

          => x or y command should be not null.
        */
        //
        agent_controler->m_steering = Ogre::Vector3::UNIT_Z ;

        Ogre::Vector3 command(agent_controler->calculateSteeringCommands(0.1)) ;

        CPPUNIT_ASSERT_MESSAGE("ship should turn",command.x != 0 || command.y != 0) ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:28,代码来源:test_agent.cpp

示例5: testComputerDestruction

      void TestDetector::testComputerDestruction()
      {
        InternalMessage("Model","Model::TestDetector::testComputerDestruction entering") ;

        /*!
          We create a ship with a detector and a second object to detect.
        */
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestDetector::testComputerDestruction")) ;
        model->init() ;

        Kernel::Object* system = model->createObject() ;

        Kernel::Object* ship = system->createObject() ;
        ship->addTrait(new Positioned()) ;
        ship->addTrait(new Oriented()) ;
        ship->addTrait(new Mobile()) ;
        ship->addTrait(new Solid(Mesh("test_ship.mesh"))) ;
        ship->addTrait(new Massive(Mass::Kilogram(1000))) ;
        ship->addTrait(new Computer()) ;
        ship->addTrait(new Detector()) ;
        Detector::connect(ship,ship) ;

        Kernel::Object* ship2 = system->createObject() ;
        ship2->addTrait(new Positioned(Position::Meter(0,0,500))) ;
        ship2->addTrait(new Massive(Mass::Kilogram(1000))) ;
        ship2->addTrait(new Oriented()) ;
        ship2->addTrait(new Mobile()) ;
        ship2->addTrait(new Solid(Mesh("test_ship.mesh"))) ;

        InternalMessage("Model","Model::TestDetector::testComputerDestruction destroying computer") ;
        ship->destroyTrait(ship->getTrait<Computer>()) ;
        model->update(0.1) ;

        InternalMessage("Model","Model::TestDetector::testComputerDestruction leaving") ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:35,代码来源:test_detector.cpp

示例6: isTargetedByTarget

      void TestAgent::isTargetedByTarget()
      {
        std::auto_ptr<Kernel::Model> model(new Kernel::Model()) ;
        model->init() ;

        Kernel::Object* system = model->createObject() ;
        system->addTrait(new Model::StellarSystem()) ;
        system->addTrait(new Model::Positioned()) ;

        Kernel::Object* ship1 = Model::createShip(system) ;
        Kernel::Object* agent = Model::createAI(ship1) ;
        Model::TargetingSystem* targeting_system1 = ship1->getChild<Model::TargetingSystem>() ;

        Kernel::Object* ship2 = Model::createShip(system) ;
        Model::TargetingSystem* targeting_system2 = ship2->getChild<Model::TargetingSystem>() ;

        Implementation::Agent* agent_controller = getAgentController(agent) ;

        targeting_system1->selectTarget(ship2) ;

        CPPUNIT_ASSERT(!agent_controller->isTargetedByTarget()) ;

        targeting_system2->selectTarget(ship1) ;

        CPPUNIT_ASSERT(agent_controller->isTargetedByTarget()) ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:26,代码来源:test_agent.cpp

示例7: basicTest

      void TestGuidanceControl::basicTest()
      {
        InternalMessage("Model","Model::TestGuidanceControl::basicTest entering") ;
        /// we construct a complete system on a ship
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestGuidanceControl::basicTest")) ;

        /// should be a PhysicalWorld
        Kernel::Object* system = model->createObject() ;
        CPPUNIT_ASSERT(system->getTrait<PhysicalWorld>()) ;

        Kernel::Object* ship = system->createObject() ;
        ship->addTrait(new Positionned()) ;
        ship->addTrait(new Oriented()) ;
        ship->addTrait(new Mobile()) ;
        ship->addTrait(new Massive(Mass::Kilogram(1000))) ;
        CPPUNIT_ASSERT(ship->getTrait<PhysicalObject>()) ;

        Kernel::Object* stick = ship->createObject() ;
        stick->addTrait(new Oriented()) ;

        Kernel::Object* guidance_system = ship->createObject() ;
        guidance_system->addTrait(new GuidanceSystem(1)) ;

        Kernel::Object* guidance_control = ship->createObject() ;
        guidance_control->addTrait(new GuidanceControler()) ;

        connectStickControler(stick,guidance_control) ;
        connectControlerGuidanceSystem(guidance_control,guidance_system) ;

        /// now we can test the control...
        {
          /// variables redefines to have direct access to interesting traits

          GuidanceSystem* guidance_system_trait = guidance_system->getTrait<GuidanceSystem>() ;
          CPPUNIT_ASSERT(guidance_system_trait) ;
          GuidanceControler* guidance_control_trait = guidance_control->getTrait<GuidanceControler>() ;
          CPPUNIT_ASSERT(guidance_control_trait) ;
          Oriented* stick_trait = stick->getTrait<Oriented>() ;
          CPPUNIT_ASSERT(stick_trait) ;

          /// basic init check
          CPPUNIT_ASSERT(guidance_system_trait->NewtonMeter() == Ogre::Vector3(0,0,0)) ;

          Ogre::Quaternion orientation(0,1,0,0) ;
          stick_trait->setOrientation(orientation) ;

          CPPUNIT_ASSERT(equal(guidance_system_trait->NewtonMeter().x,pi) &&
                         equal(guidance_system_trait->NewtonMeter().y,pi) &&
                         equal(guidance_system_trait->NewtonMeter().z,0)) ;

          /// reorient ship...
          ship->getTrait<Oriented>()->setOrientation(
            Ogre::Quaternion(sqrt(0.5),0,sqrt(0.5),0)) ;

          CPPUNIT_ASSERT(equal(guidance_system_trait->NewtonMeter().x,0) &&
                         equal(guidance_system_trait->NewtonMeter().y,pi) &&
                         equal(guidance_system_trait->NewtonMeter().z,-pi)) ;
        }
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:59,代码来源:test_guidance_control.cpp

示例8: moveParentSource

      void TestMovingObject::moveParentSource()
      {
        std::cerr << "TestMovingObject::moveParentSource" << std::endl ;
        std::cerr.flush() ;

        // we construct a complete system
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestMovingObject::basicTest")) ;
        model->init() ;
        
        Kernel::Object* system = model->createObject() ;
        system->addTrait(new Model::Positionned()) ;
        system->addTrait(new Model::Oriented()) ;

        Kernel::Object* listener = system->createObject() ;
        listener->addTrait(new Model::Listener()) ;
        Model::Positionned* listenerPos = new Model::Positionned();
        listener->addTrait(listenerPos) ;
        listener->addTrait(new Model::Oriented()) ;
        listener->addTrait(new Model::Mobile());
        
        Kernel::Object* ship = system->createObject() ;
        Model::Positionned* ship_positionned = new Model::Positionned(Model::Position::Meter(0,0,-50));
        ship->addTrait(ship_positionned);
        ship->addTrait(new Model::Oriented()) ;
        ship->addTrait(new Model::Mobile());
        
        Kernel::Object* engine = ship->createObject() ;
        engine->addTrait(new Model::Engine(Model::Force::Newton(10,10,10))) ;
        
        Kernel::ViewPoint* viewpoint = model->getViewPoint<Implementation::OpenAL::RealWorldViewPoint>() ;
        CPPUNIT_ASSERT(engine->getTrait<Implementation::Engine>()
                             ->getView<Implementation::OpenAL::Engine>(viewpoint)) ;
        
        ALuint engine_source = 
          engine->getTrait<Implementation::Engine>()
                ->getView<Implementation::OpenAL::Engine>(viewpoint)->m_source ;
        
        Kernel::Timer global_timer ;
        Kernel::Timer timer ;
        
        float expected_position_x = 0 ;
        float expected_position_y = 0 ;
        float expected_position_z = -50 ;

        checkSourcePosition(engine_source,
                            expected_position_x,
                            expected_position_y,
                            expected_position_z) ;

        ship_positionned->setPosition(ship_positionned->getPosition()+Model::Position::Meter(0,0,-0.01));
        
        expected_position_z -= 0.01 ;

        checkSourcePosition(engine_source,
                            expected_position_x,
                            expected_position_y,
                            expected_position_z) ;
        
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:59,代码来源:test_moving_object.cpp

示例9: moveParentAndListenerHasPosition

      void TestMovingObject::moveParentAndListenerHasPosition()
      {
        std::cerr << "TestMovingObject::moveParentAndListenerHasPosition" << std::endl ;
        std::cerr.flush() ;

        // we construct a complete system
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestMovingObject::moveParentAndListenerHasPosition")) ;
        model->init() ;
        
        Kernel::Object* system = model->createObject() ;
        system->addTrait(new Model::Positionned()) ;
        system->addTrait(new Model::Oriented()) ;

        Kernel::Object* listener_ship = system->createObject() ;
        Model::Positionned* listener_ship_positionned = new Model::Positionned();
        listener_ship->addTrait(listener_ship_positionned) ;
        
        Kernel::Object* listener = listener_ship->createObject() ;
        listener->addTrait(new Model::Positionned()) ;
        listener->addTrait(new Model::Listener()) ;
        listener->addTrait(new Model::Oriented()) ;
        listener->addTrait(new Model::Mobile());
        
        Kernel::Object* ship = system->createObject() ;
        Model::Positionned* ship_positionned = new Model::Positionned(Model::Position::Meter(0,0,-50));
        ship->addTrait(ship_positionned);
        ship->addTrait(new Model::Oriented()) ;
        ship->addTrait(new Model::Mobile());
        
        Kernel::Object* engine = ship->createObject() ;
        engine->addTrait(new Model::Engine(Model::Force::Newton(10,10,10))) ;
        engine->addTrait(new Model::Positionned()) ;
        
        Kernel::Timer global_timer ;
        Kernel::Timer timer ;
        
        float listener_position_x ;
        float listener_position_y ;
        float listener_position_z ;

        float expected_listener_position_x = 0 ;
        float expected_listener_position_y = 0 ;
        float expected_listener_position_z = 0 ;

        alGetListener3f(AL_POSITION,&listener_position_x,&listener_position_y,&listener_position_z) ;
        CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_listener_position_x,listener_position_x,delta) ;
        CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_listener_position_y,listener_position_y,delta) ;
        CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_listener_position_z,listener_position_z,delta) ;

        listener_ship_positionned->setPosition(listener_ship_positionned->getPosition()+Model::Position::Meter(0,0,-1));
        
        expected_listener_position_z -= 1 ;

        alGetListener3f(AL_POSITION,&listener_position_x,&listener_position_y,&listener_position_z) ;
        CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_listener_position_x,listener_position_x,delta) ;
        CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_listener_position_y,listener_position_y,delta) ;
        CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_listener_position_z,listener_position_z,delta) ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:58,代码来源:test_moving_object.cpp

示例10: onInit

        void Collision::onInit()
        {
          InternalMessage("Model","Collision::onInit entering") ;
          m_beam = NULL ;
          m_destroyable = NULL ;
          /*
            if one object is a laser beam
            - destroy it 
            and if the other is destroyable
            - manage damage 
          */
          LaserBeam* beam1 = getTrait()->getObject1()->getTrait<LaserBeam>() ;
          LaserBeam* beam2 = getTrait()->getObject2()->getTrait<LaserBeam>() ;
          
          Destroyable* destroyable1 = getTrait()->getObject1()->getTrait<Destroyable>() ;
          Destroyable* destroyable2 = getTrait()->getObject2()->getTrait<Destroyable>() ;
          
          if (beam1)
          {
            m_beam = beam1 ;
            getTrait()->getObject1()->destroyObject() ;
          }

          if (beam2)
          {
            m_beam = beam2 ;
            getTrait()->getObject2()->destroyObject() ;
          }
          
          if (destroyable1)
          {
            m_destroyable = destroyable1 ;
          }

          if (destroyable2)
          {
            m_destroyable = destroyable2 ;
          }
          
          // handle beam/destroyable collision
          if (m_beam && m_destroyable)
          {
            InternalMessage("Model","Collision::onInit damaging " + Kernel::toString(m_beam->getEnergy().Joule())) ;
            m_destroyable->damage(m_beam->getEnergy()) ;
            Kernel::Object* hit = m_destroyable->getObject()->createObject() ;
            hit->addTrait(new Hit()) ;
            Position position(getRelativePosition(getObject(),m_destroyable->getObject())) ;

            InternalMessage("Model","Collision::onInit creating hit at " + ::Ogre::StringConverter::toString(position.Meter())) ;

            hit->addTrait(new Positioned(position)) ;
            hit->addTrait(new WithLifetime(Duration::Second(0))) ;
            hit->addTrait(new Sized(Distance(Distance::_Meter,60))) ;
            hit->addTrait(new Oriented(Orientation(position))) ;
          }          
          
          InternalMessage("Model","Collision::onInit leaving") ;
        }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:58,代码来源:collision.cpp

示例11: oneShip

      void TestDemonstration::oneShip()
      {
        InternalMessage("Sound","entering TestDemonstration::oneShip") ;
        std::cerr << "TestDemonstration::oneShip" << std::endl ;
        std::cerr.flush() ;

        std::auto_ptr<Kernel::Model> model(new Kernel::Model()) ;
        model->init() ;

        Kernel::Object* root = model->createObject() ;

        Kernel::Object* universe = root->createObject() ;
        universe->addTrait(new Model::Universe()) ;
        universe->addTrait(new Model::Positioned()) ;
        universe->setName("universe") ;

        Kernel::Object* system = universe->createObject() ;
        system->addTrait(new Model::StellarSystem()) ;
        system->addTrait(new Model::Positioned()) ;
        system->setName("system") ;

//        Kernel::Object* ship = Model::loadShip("test_ship",system) ;

        Kernel::Object* pilot = system->createObject() ;
        pilot->addTrait(new Model::Listener()) ;
        pilot->addTrait(new Model::Positioned()) ;
        pilot->addTrait(new Model::Oriented()) ;
        pilot->addTrait(new Model::Player()) ;
        pilot->addTrait(new Model::Observer()) ;
        pilot->addTrait(new Model::Active()) ;
        pilot->addTrait(new Model::Mobile()) ;

        Kernel::Object* ship2 = Model::loadShip("test_ship",system) ;

        Model::Positioned* ship2_positioned = ship2->getTrait<Model::Positioned>() ;
        ship2_positioned->setPosition(Model::Position::Meter(0,0,200)) ;
        ship2->getTrait<Model::Mobile>()->setSpeed(Model::Speed::MeterPerSecond(0,0,-50)) ;
        Kernel::Timer global_timer ;
        Kernel::Timer timer ;

        std::set<Model::Throttle*> throttles = ship2->getChildren<Model::Throttle>() ;

        (*throttles.begin())->set(100) ;

        while (global_timer.getSecond() <= 4)
        {
          float seconds = timer.getSecond() ;
          if (seconds > 0)
          {
            timer.reset() ;
            ship2_positioned->setPosition(ship2_positioned->getPosition()+Model::Position::Meter(0,0,-50*seconds)) ;
            model->update(seconds) ;
          }
        }
        InternalMessage("Sound","leaving TestDemonstration::oneShip") ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:56,代码来源:test_demonstration.cpp

示例12: basicTest

      void TestBackgroundSound::basicTest()
      {
        /*!
          - build a background sound object wih a ogg
          - build an event colision with a wav (default sound.wav in OpenAL::colision.cpp code) 
          - build a listener
          - destroy the event  before the end of the sound
          - update the module for streaming during 10secondes
          -destroy all and clean sound module
        */

        // we construct a complete system
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestBackgroundSound::basicTest")) ;
        model->init() ;
        
        Kernel::Object* system = model->createObject() ;
        system->addTrait(new Model::Positionned()) ;
        system->addTrait(new Model::Oriented()) ;

        Kernel::Object* listener = system->createObject() ;
        listener->addTrait(new Model::Listener()) ;
        listener->addTrait(new Model::Positionned()) ;
        listener->addTrait(new Model::Oriented()) ;
        listener->addTrait(new Model::Mobile());

        Kernel::Object* emmiter = system->createObject() ;
        emmiter->addTrait(new Model::BackgroundSound("pu_comm_essai_1.ogg")) ;
        emmiter->addTrait(new Model::Positionned()) ;
        emmiter->addTrait(new Model::Oriented()) ;
        
        
        Kernel::Object* elm1 = system->createObject() ;
        Kernel::Object* elm2 = system->createObject() ;
        Kernel::Object* collision = system->createObject() ;
        const Model::Position& posRef = Model::Position();
        collision->addTrait(new Model::Collision(elm1, elm2, posRef)) ;
        InternalMessage("Sound","fin definition world") ;
        
        model->destroyObject(collision) ;
        
        InternalMessage("Sound","after destroy colision") ;
        
        Kernel::Timer global_timer ;
        Kernel::Timer timer ;
        int i = 0 ;
        while(global_timer.getSecond() <= 10.0)
        {
          ++i ;
          float seconds = timer.getSecond() ;
          timer.reset() ;
          model->update(seconds) ;
        }          
        
        InternalMessage("Sound","i=" + Kernel::toString(i)) ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:55,代码来源:test_background_sound.cpp

示例13: customMission

      void TestMenu::customMission()
      {
        InternalMessage("GUI","GUI::TestMenu::customMission entering") ;
        try
        {
          std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestMenu::customMission")) ;
          model->init() ;

          Kernel::Object* mission = model->createObject() ;
          mission->addTrait(new Model::CustomMission("test",NULL,NULL)) ;
          mission->addTrait(new Model::Edited()) ;

          Kernel::Object* team1 = mission->createObject() ;
          team1->addTrait(new Model::Team("team 1")) ;

          Kernel::Object* team2 = mission->createObject() ;
          team2->addTrait(new Model::Team("team 2")) ;

          Kernel::Object* team3 = mission->createObject() ;
          team3->addTrait(new Model::Team("team 3")) ;

          Kernel::Timer timer ;
          Kernel::Timer global_timer ;

          float test_duration = 0 ;

          try
          {
            test_duration = Kernel::Parameters::getValue<float>("GUI","Test.PlayerConfiguration.Duration") ;
          }
          catch(...)
          {
            test_duration = 5 ;
          }

          while (global_timer.getSecond() < test_duration)
          {
            float seconds = timer.getSecond() ;
            if (seconds != 0)
            {
              timer.reset() ;
            }
            model->update(seconds) ;
          }
        }
        catch( ::CEGUI::Exception& exception)
        {
          std::cout << exception.getMessage() << std::endl ;
          throw ;
        }

        InternalMessage("GUI","GUI::TestMenu::customMission leaving") ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:53,代码来源:test_menu.cpp

示例14: createUniverseAndSystem

Kernel::Object* DisplayTestFixture::createUniverseAndSystem(Kernel::Model* model) const
{
    Kernel::Object* universe = model->createObject() ;
    universe->addTrait(new Model::Universe()) ;
    universe->addTrait(new Model::Positioned()) ;

    Kernel::Object* system = universe->createObject() ;
    system->addTrait(new Model::StellarSystem()) ;
    system->addTrait(new Model::Positioned()) ;

    return system ;
}
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:12,代码来源:display_test_fixture.cpp

示例15: createObserver

Kernel::Object* DisplayTestFixture::createObserver(Kernel::Object* parent) const
{
    Kernel::Object* observer = parent->createObject() ;
    observer->addTrait(new Model::Observer()) ;
    observer->getTrait<Model::Observer>()->setFieldOfView(::Ogre::Degree(70)) ;
    observer->addTrait(new Model::Player()) ;
    observer->addTrait(new Model::Active()) ;
    observer->addTrait(new Model::Positioned()) ;
    observer->addTrait(new Model::Oriented()) ;

    return observer ;
}
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:12,代码来源:display_test_fixture.cpp


注:本文中的kernel::Object::addTrait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。