示例#1
0
/**
   Remove a call list
  */
bool ShadowableScene::removeModel(string modelName)
{
   /// \todo loop through all the display lists and try to find the modelName
   if (removeModelFromList(modelName, shadowCasterList))
      return true;
   else if (removeModelFromList(modelName, shadowReceiverList))
      return true;
   else if (removeModelFromList(modelName, normalList))
      return true;

   return false;
}
示例#2
0
//------------------------------------------------------------------------------
// mapPlayers2ElevTable() - Map the player list to the model table
//------------------------------------------------------------------------------
void Otw::mapPlayers2ElevTable()
{
   // Set all entries as unciecked
   for (unsigned int i = 0; i < getElevationTableSize(); i++) {
      hotTbl[i]->setCheckedFlag(false);
   }

   // When we have a player list ...
   if (playerList != 0) {

      // ---
      // Find players that are alive and require terrain elevation from the visual system ...
      // ---
      Basic::List::Item* item = playerList->getFirstItem();
      while (item != 0) {

         // Get a pointer to the player, 'p'
         Basic::Pair* pair = dynamic_cast<Basic::Pair*>(item->getValue());
         Player* p = (Player*) pair->object();

         // Check if this player is alive and within range.
         if ( p->isActive() && p->isTerrainElevationRequired() ) {

            // Check if in-range
            bool inRange = computeRangeToPlayer(p) <= maxRange;
            
            if (inRange) {
            
               // Find the player's model entry (if any)
               OtwModel* model = findModel(p, HOT_TABLE);

               if (model != 0) {
                  // The player has a valid entry.
                  model->incReqCount();
               }
               else {
                  // Player doesn't have an entry, so create one.
                  model = newElevEntry(p);
               }
               if (model != 0) model->setCheckedFlag(true);
            }

         }

         //completed  = p->isNetworkedPlayer();
         item = item->getNext(); // Next player
      }
   }

   // ---
   // Remove unmatched model entries; their players are inactive or no longer
   // require terrain elevation
   // ---
   for (int i = getElevationTableSize(); i > 0; --i) {
      if ( hotTbl[i-1]->isNotChecked() ) {
         // Deleting this entry
         removeModelFromList( (i-1), HOT_TABLE);
      }
   }
}
示例#3
0
//------------------------------------------------------------------------------
// resetTables() -- Resets all of the working tables 
//------------------------------------------------------------------------------
void Otw::resetTables()
{
    // Clear the model table
    // (in reverse order just in case another thread is traversing the 
    //  table from bottom up)
    while (nModels > 0) {
        removeModelFromList(nModels-1, MODEL_TABLE);
    }

    // Clear the elevation table
    // (in reverse order just in case another thread is traversing the 
    //  table from bottom up)
    while (nHots > 0) {
        removeModelFromList(nHots-1, HOT_TABLE);
    }
}
示例#4
0
//------------------------------------------------------------------------------
// mapPlayerList2ModelTable() - Map the player list to the model table
//  
//  model states are:
//     INACTIVE     -- unused model entry
//     ACTIVE       -- player is alive and in-range
//     DEAD         -- player is dead or destoryed
//     OUT_OF_RANGE -- player is alive but out of range
//
//  Note: this routines will set model entries to DEAD and OUT_OF_RANGE, but the
//  derived class should handle the visual system unique termination sequences and
//  clear the model entry.
//------------------------------------------------------------------------------
void Otw::mapPlayerList2ModelTable()
{
   // ---
   // Check for reset
   // ---
   if (isResetInProgress()) {
      // Set all active models as Out-Of-Range so that sendOwnshipAndModels() can remove them
      for (unsigned int i = 0; i < getModelTableSize(); i++) {
         modelTbl[i]->setState( OtwModel::OUT_OF_RANGE );
      }
      return;
   }

   // ---
   // Remove all inactive, dead or out-of-range models
   //   -- These states were issued last pass, so the OTW system
   //       specific software should have handled them by now.
   //   -- As models are removed, the table above the model is shifted down.  
   //   -- We're also clearing the model's 'checked' flag
   // ---
   for (int i = getModelTableSize(); i > 0; --i) {
      if ( modelTbl[i-1]->isState(OtwModel::CLEARED) ) {
         // Deleting this model
         //std::cout << "Otw::mapPlayerList2ModelTable() cleanup: model = " << modelTbl[i] << std::endl;
         removeModelFromList( (i-1), MODEL_TABLE);
      }
   }
   for (unsigned int i = 0; i < getModelTableSize(); i++) {
      modelTbl[i]->setCheckedFlag(false);
   }
    
   if (playerList != 0) {
      // We must have a player list ...

      // ---
      // Find players that are alive and within range of the visual system ...
      // ---
      Basic::List::Item* item = playerList->getFirstItem();
      while (item != 0) {
    
         // Get a pointer to the player, 'p'
         Basic::Pair* pair = dynamic_cast<Basic::Pair*>(item->getValue());
         Player* p = (Player*) pair->object();

         bool dummy = false;
         const Weapon* wpn = dynamic_cast<const Weapon*>( p );
         if (wpn != 0) dummy = wpn->isDummy();

         if ( p != getOwnship() && !dummy ) {

            // Find the player's model entry (if any)
            OtwModel* model = findModel(p, MODEL_TABLE);

            // Check if in-range
            bool inRange = computeRangeToPlayer(p) <= maxRange;
         
            // Check if this player is alive and within range.
            if (p->isActive() && inRange) {
               // When alive and in range ...
               if (model != 0) {
                  // a) and it already has a model entry: make sure it's active ...
                  model->setState( OtwModel::ACTIVE );
               }
               else {
                  // b) and it doesn't have a model entry (new, in-range player) ...
                  model = newModelEntry(p);
               }
            }
            else if (p->isDead() && inRange) {
               // When player isn't alive and it had a model entry
               if (model != 0) {
                  // set state to dead
                  model->setState( OtwModel::DEAD );
               }
            }
            else {
               // When player is out-of-range and it had a model entry
               if (model != 0) {
                  // set state to out-of-range
                  model->setState( OtwModel::OUT_OF_RANGE );
               }
            }
            if (model != 0) model->setCheckedFlag(true);

         }

         item = item->getNext(); // Next player
      }

   }

   // ---
   // Any models not checked needs to be removed
   // ---
   for (unsigned int i = 0; i < getModelTableSize(); i++) {
      if ( modelTbl[i]->isNotChecked() ) {
         // Request removel; 
         // (note: the OTW system specific code now has one frame to cleanup it's own code
         //  before the model is dropped from the output list next frame -- see above)
         modelTbl[i]->setState( OtwModel::OUT_OF_RANGE );
      }
   }

}