Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 6, 2017, 3:43:57 PM (7 years ago)
Author:
varxth
Message:

function to change clothes

Location:
code/branches/SOBv2_HS17/src/modules/superorxobros
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc

    r11535 r11538  
    113113
    114114            // now, change the clothes of the Figure to red
    115             std::set<WorldEntity*> attachedObjects = this->getAttachedObjects();
    116             std::set<WorldEntity*>::iterator it;
    117             for (it = attachedObjects.begin(); it != attachedObjects.end(); ++it)
    118             {
    119                 Model* FiguresModel = orxonox_cast<Model*>(*it);
    120                 if (FiguresModel != nullptr)
    121                 {
    122                     std::string name = "orxo_material_gross";
    123 
    124                     FiguresModel->setSubMaterial(name, 4); // 4 is the body
    125 
    126                 }
    127             }   
    128         }
     115            std::string name = "orxo_material_gross";
     116            this->changeClothes(name);
     117           
     118        }
     119       
    129120        //Check if otherObject is a Gumba (that walking enemies)
    130121
     
    146137                   
    147138                   
    148             // now, change the clothes of the Figure to old ones
    149             std::set<WorldEntity*> attachedObjects = this->getAttachedObjects();
    150             std::set<WorldEntity*>::iterator it;
    151             for (it = attachedObjects.begin(); it != attachedObjects.end(); ++it)
    152             {
    153                 Model* FiguresModel = orxonox_cast<Model*>(*it);
    154                 if (FiguresModel != nullptr)
    155                 {
    156                     std::string name = "orxo_material ";
    157                     FiguresModel->setMaterial(name);
    158                 }
    159             } 
     139           // now, change the clothes of the Figure to old ones
     140            std::string name = "orxo_material";
     141            this->changeClothes(name);
    160142                    gumba->destroyLater();
    161143                    gumba->hasCollided_ = true;
     
    405387
    406388
    407 }
     389
     390// PRE: name is an existing name of a material. Example orxo_material for orxo_material.material in data_extern/materials
     391// POST: clothes of body of player are changed to name
     392void SOBFigure::changeClothes(std::string& name){
     393            std::set<WorldEntity*> attachedObjects = this->getAttachedObjects();
     394            std::set<WorldEntity*>::iterator it;
     395            for (it = attachedObjects.begin(); it != attachedObjects.end(); ++it)
     396            {
     397                Model* FiguresModel = orxonox_cast<Model*>(*it);
     398                if (FiguresModel != nullptr)
     399                {
     400
     401                    FiguresModel->setSubMaterial(name, 4); // 4 is the body
     402
     403                }
     404            }   
     405}
     406
     407}
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h

    r11418 r11538  
    4646            virtual void boost(bool boost) override;
    4747            virtual  bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
     48            void changeClothes(std::string& name);
    4849
    4950            bool dead_;
Note: See TracChangeset for help on using the changeset viewer.