Exemple #1
0
 //Apply world geometry to the mobile: force it to stay inside the world bounds
void World::applyBounds( Mobile & mob )
{
    //For now, only force mobile to stay within the rectangular area of the World.
    //In future, add some obstacles?
    const vec2 & pos = mob.getLocation();
    if ( bounds.contains( pos ) ){
	//Bot is within the world rectangle
	return;
    }else{
	//Bot is outside the world rectangle
	//force it back
	vec2 pos1 = pos;
	vec2 speed1 = mob.getSpeed();

	if ( pos.x < bounds.left() ){
	    pos1.x  = bounds.left();
	    speed1.x = 0;
	}else if ( pos.x > bounds.right() ) {
	    pos1.x = bounds.right();
	    speed1.x = 0;
	}
	if ( pos.y < bounds.top() ){
	    pos1.y  = bounds.top();
	    speed1.y = 0;
	}else if ( pos.y > bounds.bottom() ) {
	    pos1.y = bounds.bottom();
	    speed1.y = 0;
	}
	//update the speed and position
	mob.setLocation( pos1 );
	mob.setSpeed( speed1 );
    }
}
void
HeroController::update(EntityManager &em, Entity &entity,
                       const InputState &input, int now) {
    float dx = 0;
    float dy = 0;
    if (input.isKeyDown(InputState::Up)) {
        dy -= 2;
    }
    if (input.isKeyDown(InputState::Down)) {
        dy += 2;
    }
    if (input.isKeyDown(InputState::Left)) {
        dx -= 2;
    }
    if (input.isKeyDown(InputState::Right)) {
        dx += 2;
    }

    Mobile *m = NULL;
    if (!entity.hasComponent(Mobile::TYPE)) {
        m = new Mobile();
        entity.addComponent(m);
    } else {
        m = entity.getComponent<Mobile>();
    }
    m->setSpeed(dx, dy);
}
Exemple #3
0
void Engine::tick() {
    map->tick();
    player->tick();

    vector<Positionable*> mobs = map->get_all_mobiles();
    for (unsigned i = 0; i < mobs.size(); i++) {
        Mobile* current = (Mobile*) mobs.at(i);
        current->tick();
    }
}
Exemple #4
0
void Engine::do_ai() {
    vector<Positionable*> mobs = map->get_all_mobiles_by_dist_to_player();
    for (unsigned i = 0; i < mobs.size(); i++) {
        Mobile* current = (Mobile*) mobs.at(i);
        if (current->is_turn()) {
            current->take_turn();
        }

    }
}
Exemple #5
0
void Engine::render() {
	SDL_FillRect(screen, NULL, 0x000000);
	display->render(screen);
	player->render(WIDTH/2, HEIGHT/2, screen);
	player->renderAttrib(screen, display);
	int xR = (WIDTH/2) + (rando->getX() - player->getX());
	int yR = (HEIGHT/2) + (rando->getY() - player->getY());
	rando->render(xR, yR, screen);
	//textWriter->write(display->getCurrentTile(), 50, 50, screen);
	//textWriter->write(display->getOffsets(), 50, 50, screen);
	//display->getOffsets();
	SDL_Flip(screen);
}
//called to draw one item
void GlutGuiViewport::drawMobile( Mobile& item)
{
    //drawing a triangle
    const vec2 &pos = item.getPos();
    

    glMatrixMode(GL_MODELVIEW);

    glPushMatrix();
	
    glTranslatef(pos.x, pos.y, 0);
    glRotatef( item.getAngle()*(180/M_PI), 0,0,1);
    drawIcon( item );
	
    glPopMatrix();
}
Exemple #7
0
bool Engine::detect_player_and_mob_turns() {
    //check players turn, set state and break
    if (player->is_turn()) {
        state = PLAYER_TURN;
        return true;
    }

    //check ai turn, set state and break
    vector<Positionable*> mobs = map->get_all_mobiles_by_dist_to_player();
    for (unsigned i = 0; i < mobs.size(); i++) {
        Mobile* current = (Mobile*) mobs.at(i);
        if (current->is_turn()) {
            state = MOB_TURN;
            return true;
        }
    }

    return false;
}
GameObject* BulletFactory::GetNewObject()
{
	int nextID = IDFactory::GetNextID();

	// TODO:  this sucks, fix it
		Mobile* m = new Mobile();
		GameObject* bullet = new Bullet();
		Collider* c = new Collider();

	m->SetValue(PhysicsComponent::GeneralVelocity, 12);
	
	c->SetRadius(1);
	
	
	bullet->SetID(nextID);
	m->SetCollider(c);
	bullet->SetMobile(m);
	return bullet;
}
GameObject* BulletFactory::GetBullet(float x, float y, float rotation, GameObject* owner, Controller* owningController)
{
	GameObject* bullet = new Bullet();
	Collider* c = new Collider();
	Mobile* m = new Mobile();
	bullet->SetID(IDFactory::GetNextID());
	m->SetCollider(c);
	bullet->SetMobile(m);
	
	c->SetRadius(collisionRadius);

	m->SetValue(PhysicsComponent::PositionX, x);
	m->SetValue(PhysicsComponent::PositionY, y);
	m->SetValue(PhysicsComponent::Rotation, rotation);
	
	bullet->SetParent(owner);	
	bullet->SetController(owningController);
	bullet->SetDamage(damage);
	bullet->SetRenderable(bulletRenderable);
	return bullet;

}
Exemple #10
0
void Engine::render_map() {
    werase(map_window);

    ViewportCalculator vpc(map_win_width - 2, map_win_height - 2, player->get_pos(), map);
    vector<Position> to_render = vpc.contained_positions();

    int x_offset = vpc.get_x_offset();
    int y_offset = vpc.get_y_offset();

    for (unsigned i = 0; i < to_render.size(); i++) {
        Position p = to_render.at(i);
        int xpos = p.get_x() - x_offset + 1;
        int ypos = p.get_y() - y_offset + 1;

        Tile* t = map->tile_for(to_render.at(i));
        if (t->is_visible()) {
            mvwprintw(map_window, ypos, xpos , t->to_char().c_str());
        }

        Item* item = map->item_for(to_render.at(i));
        if (item && map->positions_have_los(item->get_pos(), player->get_pos())) {
            mvwprintw(map_window, ypos, xpos , item->to_char().c_str());
        }

        Mobile* mob = (Mobile*) map->mobile_for(to_render.at(i));
        if (mob && mob->is_visible_from(player->get_pos())) {
            mvwprintw(map_window, ypos, xpos , mob->to_char().c_str());
        }

    }

    int ypos = player->get_pos().get_y() - y_offset + 1;
    int xpos = player->get_pos().get_x() - x_offset + 1;
    mvwprintw(map_window, ypos, xpos, player->to_char().c_str());
    box(map_window, 0, 0);
    wnoutrefresh(map_window);
}
Exemple #11
0
void ModelManager::CreateBlueprintFromMobile(const Mobile& mobile, ModelBlueprint& blueprint)
{
   const MobileDisplayInfo& info = mobile.DisplayInfo();

   // info.BaseFigure(): we only have this one yet
   blueprint.m_cszAnimatedModelName = _T("CS_muscle_animated");
   blueprint.m_vecAnimatedMaterialTextures.resize(5);

   // material 0, name [feet_texture] texture [.\base.feet.human.jpg]
   // material 1, name [pants_texture] texture [.\base.pants.human.jpg]
   // material 2, name [body_texture] texture [.\base.body.human.jpg]
   // material 3, name [hands_texture] texture [.\base.hands.human.jpg]
   // material 4, name [head_texture] texture [.\base.head.human.jpg]

   // all textures come with looks from 001-024; some have a prefix
   // _D or _L appended, for light and dark skin textures.
   blueprint.m_vecAnimatedMaterialTextures[0] = _T("001.feet.human.jpg");
   blueprint.m_vecAnimatedMaterialTextures[1] = _T("001.pants.human.jpg");
   blueprint.m_vecAnimatedMaterialTextures[2] = _T("001.body.human.jpg");
   blueprint.m_vecAnimatedMaterialTextures[3] = _T("001_D.hands.human.jpg");

   // face style: 01..08 (7 face styles); skin color: 0..2 (normal, light, dark)
   blueprint.m_vecAnimatedMaterialTextures[4].Format(
      _T("%02u_%01u.head.human.jpg"), info.FaceStyle()+1, info.SkinColor()+1);

   CString cszPilosity;
   cszPilosity.Format(_T("pilosity%02u_%01u"),
      info.PilosityBrowStyle()+1, // range 01-12
      info.PilosityHairStyle()+1); // range 1-5

   CString cszHairColor;
   cszHairColor.Format(_T("%u."), info.HairColor()+1); // range 1-5

   blueprint.m_vecStaticBlueprints.push_back(ModelBlueprint::StaticModelBlueprint(cszPilosity, _T("mount1"), cszHairColor));

   // TODO process inventory/paperdoll
   // all mount points:
   // mount0: head, hat, helmet
   // mount1: face, pilosity
   // mount2: N/A
   // mount3: right hand, sword, crossbow
   // mount4: left hand, bow, shield
   // mount5: right shoulder, shoulder pad R
   // mount6: left shoulder, shoulder pad L
   // mount7: back, quiver
   blueprint.m_vecStaticBlueprints.push_back(ModelBlueprint::StaticModelBlueprint(_T("axe01"), _T("mount3")));
   //blueprint.m_vecStaticBlueprints.push_back(ModelBlueprint::StaticModelBlueprint(_T("hat01"), _T("mount0")));
}
Exemple #12
0
void Engine::update() {

	player->update(display);
	rando->update(display);

	int xp = player->getX();
	int yp = player->getY();

	display->setOffsets(xp - WIDTH / 2, yp - HEIGHT / 2);

	if(player->isSailing()) {
		audio->switchTo(BOATMUSIC);
	} 
	else if(!(player->isSailing())) {
		audio->switchTo(LANDMUSIC);
	}

}
void GlutGuiViewport::drawIcon(Mobile& mob)
{
    ftype iconSize = 1.0;

    glBegin(GL_POLYGON);
    glColor3f( 1, 1, 1);
    
    glVertex2f( 0, -iconSize);
    glVertex2f( 0.7*iconSize, -0.7*iconSize);
    glVertex2f( iconSize, 0);
    glVertex2f( 0.7*iconSize, 0.7*iconSize);
    glVertex2f( 0, iconSize);
    glVertex2f( -0.7*iconSize, 0.7*iconSize);
    glVertex2f( -iconSize, 0);
    glVertex2f( -0.7*iconSize, -0.7*iconSize);

    glEnd();

    glBegin( GL_LINES );
    glColor3f( 1, 0, 0);
    glVertex2f( 0,0);
    glVertex2f( 0, iconSize*2);
    glEnd();

    //draw motors
    glBegin( GL_LINES );
    
    for( int i = 0; i < Mobile::NUM_MOTORS; ++i){
	const Motor& m = mob.getMotor( i );
	const vec2& pos = m.getPos();
	vec2 posEnd = pos + m.getForce();
	glColor3f( 1, 1, 1);
	glVertex2f( pos.x, pos.y);
	glColor3f( 0, 1, 0);
	glVertex2f( posEnd.x, posEnd.y );
    }
    glEnd();
}
Exemple #14
0
int main()
{
  
  //initialiser tråde og objekter til testcases
  
  ManualController objManualController;
  AutomaticController objAutomaticController;
  UIController objUIController;
  Settings objSettings;
  SettingsController objSettingsController(&objSettings);
  MeasurementsController objMeasurementsController;
  Cradle objCradle;
  Mobile objMobile;
  ZigBeeIF_out objZigBeeIF_out;
  ZigBeeIF_in objZigBeeIF_in;
  
  objUIController.setMqs( objManualController.getMsgQueue(), objAutomaticController.getMsgQueue(),  objSettingsController.getMsgQueue() );
  
  objManualController.setMqs( objCradle.getMsgQueue(), objMobile.getMsgQueue(), objUIController.getMsgQueue() );
  
  objAutomaticController.setMqs( objCradle.getMsgQueue(), objMobile.getMsgQueue(), objUIController.getMsgQueue(), objMeasurementsController.getMsgQueue()  );
  
  objSettingsController.setMqs( objUIController.getMsgQueue(), objCradle.getMsgQueue(), objMobile.getMsgQueue(), objMeasurementsController.getMsgQueue() );
  
  objMeasurementsController.setMqs( objUIController.getMsgQueue(), objAutomaticController.getMsgQueue() );
  
  objCradle.setMqs( objManualController.getMsgQueue(), objAutomaticController.getMsgQueue(), objZigBeeIF_out.getMsgQueue() );
  
  objMobile.setMqs( objManualController.getMsgQueue(), objAutomaticController.getMsgQueue(), objZigBeeIF_out.getMsgQueue() );
  
  objZigBeeIF_in.setMqs( objMeasurementsController.getMsgQueue() );
  
  osapi::Thread thrUIController(&objUIController);
  osapi::Thread thrManualController(&objManualController);
  osapi::Thread thrAutomaticController(&objAutomaticController);
  osapi::Thread thrSettingsController(&objSettingsController);
  osapi::Thread thrMeasurementsController(&objMeasurementsController);
  osapi::Thread thrCradle(&objCradle);
  osapi::Thread thrMobile(&objMobile);
  osapi::Thread thrZigBeeIF_out(&objZigBeeIF_out);
  osapi::Thread thrZigBeeIF_in(&objZigBeeIF_in);
  
  thrUIController.start();
  thrManualController.start();
  thrAutomaticController.start();
  thrSettingsController.start();
  thrMeasurementsController.start();
  thrCradle.start();
  thrMobile.start();
  thrZigBeeIF_out.start();
  thrZigBeeIF_in.start();
  
  
  objSettingsController.init();
  
  
  //indstil settings, således at disse indstillers værdier kan forventes i den resterende test.
  
  std::cout << std::endl << "Test-kommentar: Indstil indstillinger" << std::endl << std::endl;
  
  //setCurrentSettings(unsigned int _cradleTime, unsigned int _cradleSpeed, unsigned int _mobileTime, unsigned int _mobileSpeed, unsigned int _minTemperature, unsigned int _maxTemperature, unsigned int _maxSound)
  objUIController.setSaveSettings(10, 255, 15, 255, 15, 35, 60 ); 
  
  sleep(5);
  
  std::cout << std::endl << "Start ZigBee_out" << std::endl << std::endl;
  
  objZigBeeIF_out.startSend();
  
  sleep(5);
  
  //Start cradle, som når at udløbe
  std::cout << std::endl << "Test-kommentar: Start cradle i tiden cradleTime." << std::endl << std::endl;
  
  objUIController.cradleOnManUIbutton_ = true;
  objUIController.startCradle();
  
  std::cout << std::endl << "Test-kommentar: Vent 15 sek i mainprogrammet." << std::endl << std::endl;
  sleep(15);
  
  std::cout << std::endl << "Test-kommentar: Cradle burde være stoppet nu." << std::endl << std::endl;
  
  sleep(5);
  
  //Start cradle, med stop før tid
  std::cout << std::endl << "Test-kommentar: Start cradle i tiden cradleTime - men stoppes før tid." << std::endl << std::endl;
  
  objUIController.cradleOnManUIbutton_ = true;
  objUIController.startCradle();
  
  std::cout << std::endl << std::endl << "Test-kommentar: Vent 5 sek i mainprogrammet." << std::endl << std::endl;
  sleep(5);
  
  std::cout << std::endl << "Test-kommentar: Cradle stoppes før tid." << std::endl << std::endl;
  objUIController.stopCradle();
  
  sleep(5);
  
  
  //Start mobile, som når at udløbe
  std::cout << std::endl << "Test-kommentar: Start mobile i tiden mobileTime." << std::endl << std::endl;
  
  objUIController.mobileOnManUIbutton_ = true;
  objUIController.startMobile();
  
  std::cout << std::endl << "Test-kommentar: Vent 20 sek i mainprogrammet." << std::endl << std::endl;
  sleep(20);
  
  std::cout << std::endl << "Test-kommentar: Mobile burde være stoppet nu." << std::endl << std::endl;
  
  sleep(5);
  
  
  //Start mobile med stop før tid
  std::cout << std::endl << "Test-kommentar: Start mobile i tiden mobileTime - men stoppes før tid." << std::endl << std::endl;
  
  objUIController.mobileOnManUIbutton_ = true;
  objUIController.startMobile();
  
  std::cout << std::endl << "Test-kommentar: Vent 5 sek i mainprogrammet." << std::endl << std::endl;
  sleep(5);
  
  std::cout << std::endl << "Test-kommentar: Mobile stoppes før tid." << std::endl << std::endl;
  objUIController.stopMobile();
  
  sleep(5);
  
  
  //Start cradle og mobile så de overlapper hinanden
  std::cout << std::endl << "Test-kommentar: Start cradle i tiden cradleTime." << std::endl << std::endl;
  objUIController.cradleOnManUIbutton_ = true;
  objUIController.startCradle();
  
  std::cout << std::endl << "Test-kommentar: Vent 5 sek i mainprogrammet." << std::endl << std::endl;
  sleep(5);
  
  std::cout << std::endl << "Test-kommentar: Start mobile i tiden mobileTime." << std::endl << std::endl;
  objUIController.mobileOnManUIbutton_ = true;
  objUIController.startMobile();
  
  std::cout << std::endl << "Test-kommentar: Både Cradle og Mobile burde være stoppet nu." << std::endl << std::endl;
  
  sleep(20);
  
  std::cout << std::endl << "Test-kommentar: Testen er s**t nu." << std::endl << std::endl;
  
  
 
  //Evt. oprydning (eksekveres aldrig)
  
  thrUIController.join();
  thrManualController.join();
  thrAutomaticController.join();
  thrSettingsController.join();
  thrMeasurementsController.join();
  thrCradle.join();
  thrMobile.join();
  thrZigBeeIF_out.join();
  thrZigBeeIF_in.join();

  return 0;
}
Exemple #15
0
int main()
{
  
  //initialiser tråde og objekter til testcases
  
  ManualController objManualController;
  AutomaticController objAutomaticController;
  UIController objUIController;
  Settings objSettings;
  SettingsController objSettingsController(&objSettings);
  MeasurementsController objMeasurementsController;
  Cradle objCradle;
  Mobile objMobile;
  ZigBeeIF_out objZigBeeIF_out;
  ZigBeeIF_in objZigBeeIF_in;
  
  objUIController.setMqs( objManualController.getMsgQueue(), objAutomaticController.getMsgQueue(),  objSettingsController.getMsgQueue() );
  
  objManualController.setMqs( objCradle.getMsgQueue(), objMobile.getMsgQueue(), objUIController.getMsgQueue() );
  
  objAutomaticController.setMqs( objCradle.getMsgQueue(), objMobile.getMsgQueue(), objUIController.getMsgQueue(), objMeasurementsController.getMsgQueue()  );
  
  objSettingsController.setMqs( objUIController.getMsgQueue(), objCradle.getMsgQueue(), objMobile.getMsgQueue(), objMeasurementsController.getMsgQueue() );
  
  objMeasurementsController.setMqs( objUIController.getMsgQueue(), objAutomaticController.getMsgQueue() );
  
  objCradle.setMqs( objManualController.getMsgQueue(), objAutomaticController.getMsgQueue(), objZigBeeIF_out.getMsgQueue() );
  
  objMobile.setMqs( objManualController.getMsgQueue(), objAutomaticController.getMsgQueue(), objZigBeeIF_out.getMsgQueue() );
  
  objZigBeeIF_in.setMqs( objMeasurementsController.getMsgQueue() );
  
  osapi::Thread thrUIController(&objUIController);
  osapi::Thread thrManualController(&objManualController);
  osapi::Thread thrAutomaticController(&objAutomaticController);
  osapi::Thread thrSettingsController(&objSettingsController);
  osapi::Thread thrMeasurementsController(&objMeasurementsController);
  osapi::Thread thrCradle(&objCradle);
  osapi::Thread thrMobile(&objMobile);
  osapi::Thread thrZigBeeIF_out(&objZigBeeIF_out);
  osapi::Thread thrZigBeeIF_in(&objZigBeeIF_in);
  
  thrUIController.start();
  thrManualController.start();
  thrAutomaticController.start();
  thrSettingsController.start();
  thrMeasurementsController.start();
  thrCradle.start();
  thrMobile.start();
  thrZigBeeIF_out.start();
  thrZigBeeIF_in.start();
  
  
  objSettingsController.init();
  
  
  //indstil settings, således at disse indstillers værdier kan forventes i den resterende test.
  
  std::cout << std::endl << "Test-kommentar: Indstil indstillinger. MinTemp = 15, MaxTemp = 35, MaxSound = 60" << std::endl << std::endl;
  
  //setCurrentSettings(unsigned int _cradleTime, unsigned int _cradleSpeed, unsigned int _mobileTime, unsigned int _mobileSpeed, unsigned int _minTemperature, unsigned int _maxTemperature, unsigned int _maxSound)
  objUIController.setSaveSettings(4, 255, 4, 255, 15, 35, 60 ); 
  
  sleep(5);
  
  std::cout << std::endl << std::endl << "Test-kommentar: (simuleret) Der modtages datapakke med temperatur = 25 og lyd = 10. " << std::endl << std::endl;
  objZigBeeIF_in.setTest(10, 25);
  objZigBeeIF_in.receiveData();

  sleep(1);
  
  std::cout << std::endl << std::endl << "Test-kommentar: (simuleret) Der modtages datapakke med temperatur = 37 og lyd = 31. " << std::endl << std::endl;
  objZigBeeIF_in.setTest(31, 37);
  objZigBeeIF_in.receiveData();

  sleep(1);
  
  std::cout << std::endl << std::endl << "Test-kommentar: (simuleret) Der modtages datapakke med temperatur = 37 og lyd = 68. " << std::endl << std::endl;
  objZigBeeIF_in.setTest(68, 37);
  objZigBeeIF_in.receiveData();

  sleep(1);
  
  std::cout << std::endl << std::endl << "Test-kommentar: (simuleret) Der modtages datapakke med temperatur = 12 og lyd = 68. " << std::endl << std::endl;
  objZigBeeIF_in.setTest(68, 12);
  objZigBeeIF_in.receiveData();
  
  sleep(1);
  
  std::cout << std::endl << "Test-kommentar: Indstil indstillinger. MinTemp = 20, MaxTemp = 30, MaxSound = 41" << std::endl << std::endl;
  objUIController.setSaveSettings(4, 255, 4, 255, 20, 30, 41 ); 
  
  sleep(1);
  
  std::cout << std::endl << std::endl << "Test-kommentar: (simuleret) Der modtages datapakke med temperatur = 12 og lyd = 42. " << std::endl << std::endl;
  objZigBeeIF_in.setTest(42, 12);
  objZigBeeIF_in.receiveData();
  
  sleep(1);
  
  std::cout << std::endl << std::endl << "Test-kommentar: (simuleret) Der modtages datapakke med temperatur = 29 og lyd = 40. " << std::endl << std::endl;
  objZigBeeIF_in.setTest(40, 29);
  objZigBeeIF_in.receiveData();
 
  sleep(1);

  std::cout << std::endl << std::endl << "Testen er s**t nu." << std::endl << std::endl;
  
 
  //Evt. oprydning (eksekveres aldrig)
  
  thrUIController.join();
  thrManualController.join();
  thrAutomaticController.join();
  thrSettingsController.join();
  thrMeasurementsController.join();
  thrCradle.join();
  thrMobile.join();
  thrZigBeeIF_out.join();
  thrZigBeeIF_in.join();

  return 0;
}
    /*!
      Generate a torque.
    */
    Ogre::Vector3 Stabilizer::NewtonMeter() const
    {
      PhysicalObject* physical_object = getObject()->getParent<PhysicalObject>() ;
      Oriented* oriented = physical_object->getObject()->getTrait<Oriented>() ;
      Kernel::Object* physical_world = physical_object->getPhysicalWorld() ;
      
      if (physical_world && physical_object && oriented)
      {
        
        Mobile* mobile = physical_object->getObject()->getTrait<Mobile>() ;
        
        /// get the rotation against 
        const AngularSpeed& speed = mobile->getAngularSpeed() ;
        
        InternalMessage("Model","Model::Stabilizer::NewtonMeter angular speed="
                        + Kernel::toString(speed.RadianPerSecond()[0]) + ","
                        + Kernel::toString(speed.RadianPerSecond()[1]) + ","
                        + Kernel::toString(speed.RadianPerSecond()[2])) ;
        
        if (speed.RadianPerSecond().length() > 100)
          ErrorMessage("Model::Stabilizer::NewtonMeter high speed encountered") ;

        
        Ogre::Quaternion object_orientation = 
          oriented->getOrientation(physical_world).getQuaternion() ;
        
        
        InternalMessage("Model","Model::Stabilizer::NewtonMeter object orientation="
                        + Kernel::toString(object_orientation.w) + ","
                        + Kernel::toString(object_orientation.x) + ","
                        + Kernel::toString(object_orientation.y) + ","
                        + Kernel::toString(object_orientation.z)) ;
        
        /// calculate 
        Ogre::Vector3 global_axis = object_orientation*m_axis ;

        InternalMessage("Model","Model::Stabilizer::NewtonMeter global_axis="
                        + Kernel::toString(global_axis[0]) + ","
                        + Kernel::toString(global_axis[1]) + ","
                        + Kernel::toString(global_axis[2])) ;

        
        // projection of speed onto the axis. 
        float force = global_axis.dotProduct(speed.TurnPerSecond()) ;

        /// sign of force is : positive when axis and speed are oriented same way
        float sign ;
        if (force < 0)
        {
          sign = -1 ;    
        }
        else
        {
          sign = +1 ;    
        }
          

        InternalMessage("Model","Model::Stabilizer::NewtonMeter force="
                        + Kernel::toString((float)force)) ;
        
        global_axis.normalise() ;
        
        global_axis *= -sign*std::min((float)100,std::max(std::max(force,-force),(force*force))) ;

        InternalMessage("Model","Model::Stabilizer::NewtonMeter result="
                        + Kernel::toString(global_axis[0]) + ","
                        + Kernel::toString(global_axis[1]) + ","
                        + Kernel::toString(global_axis[2])) ;
        
        return global_axis ;
      }
      
      /// return value for not applicable.
      return Ogre::Vector3(0,0,0) ;
    }
      void DetectorObjectView::check()
      {
        InternalMessage("Model","Model::DetectorObjectView::check entering") ;
        
        Detector* detector = getViewPoint()->getObserver() ;
        if (!detector)
          return ;
        bool in_range = detector ? detector->canDetect(getObject()) : false ;
        
        if (!detector->getComputer())
          return ;        
        
        Computer* computer = detector->getComputer()->getTrait<Computer>() ;
        if (! computer)
          return ;
                  
        if (!in_range && m_detection_information)
        {
          // destroy object
          computer->getMemoryModel()->destroyObject(m_detection_information) ;
          m_detection_information = NULL ;
        }
        else if (in_range)
        {
          InternalMessage(
            "Model",
            "Model::DetectorObjectView::check in range updating detection data") ;
          
          bool mobile = false ;
          
          if (! m_detection_information)
          {
            Solid* solid = getObject()->getTrait<Solid>() ;
            
            // create object 
            m_detection_information = computer->getMemoryModel()->createObject() ;
            m_detection_information->addTrait(new DetectionData(detector->getComputer())) ;
            m_detection_information->addTrait(new Positionned()) ;
            m_detection_information->addTrait(new Solid(solid->getMesh())) ;

            m_detection_information->getTrait<DetectionData>()->m_detected = getObject() ;
          }
          // update object position
          Position position = getRelativePosition(getObject(),
                                                  computer->getObject()) ;
          
          m_detection_information->getTrait<Positionned>()->setPosition(position) ;
          
          // update speed if exists
          Mobile* mobileTrait = getObject()->getTrait<Mobile>() ;
          
          if (mobileTrait)
          {
            Mobile* data = m_detection_information->getTrait<Mobile>() ;
            if (! data)
            {
              data = new Mobile() ;
              m_detection_information->addTrait(data) ;
            }
            data->setSpeed(mobileTrait->getSpeed()) ;
            data->setAngularSpeed(mobileTrait->getAngularSpeed()) ;
          }

          // update identification
          Transponder* identified = 
              getObject()->getTrait<Transponder>() ; 
          
          Transponder* identifedData = 
              m_detection_information->getTrait<Transponder>() ; 
          
          if (identified)
          {
            if (! identifedData)
            {
              // gained identification
              m_detection_information->addTrait(new Transponder(*identified)) ;
            }
            else if (identifedData->getCode() != identified->getCode())
            {
              // changed identification
              identifedData->setCode(identified) ;
            }
          }
          else if (identifedData)
          {
            // lost identification
            m_detection_information->destroyTrait(identifedData) ;
          }

          // update Targetting
          std::set<TargetingSystem*> systems = getObject()->getChildren<TargetingSystem>() ;
          TargetingSystem* system_data = 
              m_detection_information->getTrait<TargetingSystem>() ;
          
          if (systems.size() == 1)
          {
            TargetingSystem* system = *(systems.begin()) ;
            
            if (! system_data)
            {
              // gained identification
              m_detection_information->addTrait(new TargetingSystem()) ;
              
              m_detection_information->getTrait<TargetingSystem>()->m_target =
                system->getTarget() ;
              m_detection_information->getTrait<TargetingSystem>()->notify() ;
            }
            else if (system_data->getTarget() != system->getTarget())
            {
              // changed selection
              system_data->m_target = system->getTarget() ;
              system_data->notify() ;
            }
          }
          else if (system_data)
          {
            // lost targeting system
            m_detection_information->destroyTrait(system_data) ;
          }
          
        }
        
        
        InternalMessage("Model","Model::DetectorObjectView::check leaving") ;
      }