void TextureHelper::EnumerateTextures(DAVA::SceneNode *forNode, Map<String, Texture *> &textures) { if(!forNode) return; Vector<SceneNode *> nodes; forNode->GetChildNodes(nodes); nodes.push_back(forNode); for(int32 n = 0; n < (int32)nodes.size(); ++n) { RenderComponent *rc = static_cast<RenderComponent *>(nodes[n]->GetComponent(Component::RENDER_COMPONENT)); if(!rc) continue; RenderObject *ro = rc->GetRenderObject(); if(!ro) continue; uint32 count = ro->GetRenderBatchCount(); for(uint32 b = 0; b < count; ++b) { RenderBatch *renderBatch = ro->GetRenderBatch(b); Material *material = renderBatch->GetMaterial(); if(material) { for(int32 t = 0; t < Material::TEXTURE_COUNT; ++t) { CollectTexture(textures, material->GetTextureName((DAVA::Material::eTextureLevel)t), material->GetTexture((DAVA::Material::eTextureLevel)t)); } } InstanceMaterialState *instanceMaterial = renderBatch->GetMaterialInstance(); if(instanceMaterial) { CollectTexture(textures, instanceMaterial->GetLightmapName(), instanceMaterial->GetLightmap()); } } LandscapeNode *land = dynamic_cast<LandscapeNode *>(ro); if(land) { CollectLandscapeTextures(textures, land); } } }
void SceneHelper::EnumerateTextures(Entity *forNode, Map<String, Texture *> &textures) { if(!forNode) return; Vector<Entity *> nodes; forNode->GetChildNodes(nodes); nodes.push_back(forNode); for(int32 n = 0; n < (int32)nodes.size(); ++n) { RenderObject *ro = GetRenderObject(nodes[n]); if(!ro) continue; uint32 count = ro->GetRenderBatchCount(); for(uint32 b = 0; b < count; ++b) { RenderBatch *renderBatch = ro->GetRenderBatch(b); Material *material = renderBatch->GetMaterial(); if(material) { for(int32 t = 0; t < Material::TEXTURE_COUNT; ++t) { CollectTexture(textures, material->GetTextureName((DAVA::Material::eTextureLevel)t).GetAbsolutePathname(), material->GetTexture((DAVA::Material::eTextureLevel)t)); } } InstanceMaterialState *instanceMaterial = renderBatch->GetMaterialInstance(); if(instanceMaterial) { CollectTexture(textures, instanceMaterial->GetLightmapName().GetAbsolutePathname(), instanceMaterial->GetLightmap()); } } Landscape *land = dynamic_cast<Landscape *>(ro); if(land) { CollectLandscapeTextures(textures, land); } } }