[Orxonox-commit 6917] r11538 - code/branches/SOBv2_HS17/src/modules/superorxobros
varxth at orxonox.net
varxth at orxonox.net
Mon Nov 6 15:43:57 CET 2017
Author: varxth
Date: 2017-11-06 15:43:57 +0100 (Mon, 06 Nov 2017)
New Revision: 11538
Modified:
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h
Log:
function to change clothes
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc 2017-11-06 14:32:04 UTC (rev 11537)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc 2017-11-06 14:43:57 UTC (rev 11538)
@@ -112,20 +112,11 @@
// now, change the clothes of the Figure to red
- std::set<WorldEntity*> attachedObjects = this->getAttachedObjects();
- std::set<WorldEntity*>::iterator it;
- for (it = attachedObjects.begin(); it != attachedObjects.end(); ++it)
- {
- Model* FiguresModel = orxonox_cast<Model*>(*it);
- if (FiguresModel != nullptr)
- {
- std::string name = "orxo_material_gross";
-
- FiguresModel->setSubMaterial(name, 4); // 4 is the body
-
- }
- }
+ std::string name = "orxo_material_gross";
+ this->changeClothes(name);
+
}
+
//Check if otherObject is a Gumba (that walking enemies)
else if (gumba != nullptr && !(gumba->hasCollided_)) {
@@ -145,18 +136,9 @@
gotPowerUp_ = false;
- // now, change the clothes of the Figure to old ones
- std::set<WorldEntity*> attachedObjects = this->getAttachedObjects();
- std::set<WorldEntity*>::iterator it;
- for (it = attachedObjects.begin(); it != attachedObjects.end(); ++it)
- {
- Model* FiguresModel = orxonox_cast<Model*>(*it);
- if (FiguresModel != nullptr)
- {
- std::string name = "orxo_material ";
- FiguresModel->setMaterial(name);
- }
- }
+ // now, change the clothes of the Figure to old ones
+ std::string name = "orxo_material";
+ this->changeClothes(name);
gumba->destroyLater();
gumba->hasCollided_ = true;
}
@@ -404,4 +386,22 @@
}
+
+// PRE: name is an existing name of a material. Example orxo_material for orxo_material.material in data_extern/materials
+// POST: clothes of body of player are changed to name
+void SOBFigure::changeClothes(std::string& name){
+ std::set<WorldEntity*> attachedObjects = this->getAttachedObjects();
+ std::set<WorldEntity*>::iterator it;
+ for (it = attachedObjects.begin(); it != attachedObjects.end(); ++it)
+ {
+ Model* FiguresModel = orxonox_cast<Model*>(*it);
+ if (FiguresModel != nullptr)
+ {
+
+ FiguresModel->setSubMaterial(name, 4); // 4 is the body
+
+ }
+ }
}
+
+}
\ No newline at end of file
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h 2017-11-06 14:32:04 UTC (rev 11537)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h 2017-11-06 14:43:57 UTC (rev 11538)
@@ -45,6 +45,7 @@
virtual void moveRightLeft(const Vector2& value) override; //!< Overloaded the function to steer the figure up and down.
virtual void boost(bool boost) override;
virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+ void changeClothes(std::string& name);
bool dead_;
bool predead_;
More information about the Orxonox-commit
mailing list