mirror of https://github.com/axmolengine/axmol.git
add getMeshArrayByName method
This commit is contained in:
parent
4d08a08809
commit
0696041ea9
|
@ -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) {
|
||||
|
|
|
@ -60,11 +60,14 @@ 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); }
|
||||
|
|
Loading…
Reference in New Issue