add getMeshArrayByName method

This commit is contained in:
yangxiao 2014-10-25 12:27:03 +08:00
parent 4d08a08809
commit 0696041ea9
2 changed files with 16 additions and 3 deletions

View File

@ -684,7 +684,7 @@ Mesh* Sprite3D::getMeshByIndex(int index) const
return _meshes.at(index);
}
/**get SubMeshState by Name */
/**get Mesh by Name */
Mesh* Sprite3D::getMeshByName(const std::string& name) const
{
for (const auto& it : _meshes) {
@ -694,6 +694,16 @@ Mesh* Sprite3D::getMeshByName(const std::string& name) const
return nullptr;
}
std::vector<Mesh*> Sprite3D::getMeshArrayByName(const std::string& name) const
{
std::vector<Mesh*> meshes;
for (const auto& it : _meshes) {
if (it->getName() == name)
meshes.push_back(it);
}
return meshes;
}
MeshSkin* Sprite3D::getSkin() const
{
for (const auto& it : _meshes) {

View File

@ -60,12 +60,15 @@ public:
void setTexture(const std::string& texFile);
void setTexture(Texture2D* texture);
/**get SubMeshState by index*/
/**get Mesh by index*/
Mesh* getMeshByIndex(int index) const;
/**get SubMeshState by Name */
/**get Mesh by Name, it returns the first one if there are more than one mesh with the same name */
Mesh* getMeshByName(const std::string& name) const;
/** get mesh array by name, returns all meshes with the given name */
std::vector<Mesh*> getMeshArrayByName(const std::string& name) const;
/**get mesh*/
Mesh* getMesh() const { return _meshes.at(0); }