//------------------------------------------------------------------------------------ Ogre::TextureUnitState* MaterialService::createAnimatedTextureState(Pass* pass, const String& baseTextureName, const String& resourceGroup, float fps) { // // Texture unit state for the main texture... TextureUnitState* tus = pass->createTextureUnitState(baseTextureName); StringVectorPtr mat_textures; // if if was found, then we'll proceed by enumerating all the resources with the same name, // but with _NUMBER mat_textures = getAnimTextureNames(baseTextureName, resourceGroup); // if we have anim. textures: if (!mat_textures.isNull() && mat_textures->size() > 1) { // convert to String* array size_t size = mat_textures->size(); String* sarray = new String[size]; size_t s = 0; for (StringVector::iterator it = mat_textures->begin(); s < size; ++it, ++s) { sarray[s] = *it; } tus->setAnimatedTextureName(sarray, size, size/fps); delete[] sarray; } return tus; }
//------------------------------------------------------------------------------------ Ogre::TextureUnitState *MaterialService::createAnimatedTextureState( Pass *pass, const String &baseTextureName, const String &resourceGroup, float fps) { // // Texture unit state for the main texture... TextureUnitState *tus = pass->createTextureUnitState(baseTextureName); // if if was found, then we'll proceed by enumerating all the resources with // the same name, but with _NUMBER auto mat_textures = getAnimTextureNames(baseTextureName, resourceGroup); // if we have anim. textures: if (mat_textures.size() > 1) { // convert to String* array size_t size = mat_textures.size(); std::unique_ptr<String[]> sarray(new String[size]); size_t i = 0; for (const String &s : mat_textures) { sarray[i++] = s; } tus->setAnimatedTextureName(sarray.get(), size, size / fps); } return tus; }