void parseEffects() { Parser parser(false, true); parser.readStream(filesystem::FilePackageManager::getInstance().getFile(fileName)); ParserGroup &global = parser.getGlobals(); int groupAmount = global.getSubGroupAmount(); for(int i = 0; i < groupAmount; ++i) { const std::string &name = global.getSubGroupName(i); const ParserGroup &group = global.getSubGroup(i); const ParserGroup &textures = group.getSubGroup("textures"); if(name.empty()) continue; effects.push_back(parseEffectProperties(name, group)); Effect &effect = effects[effects.size() - 1]; int lineCount = textures.getLineCount(); for(int j = 0; j < lineCount; ++j) { const string &texture = textures.getLine(j); addSpawner(effect, manager, texture, storm); } if(lineCount == 0) { Logger::getInstance()->warning("Decal effect with no textures defined"); Logger::getInstance()->warning(name.c_str()); } } }
void spawn(DecalIdentifier &identifier, int id, const VC3 &position, const QUAT &rotation, const COL &light, bool inBuilding) { assert(id >= 0 && id < int(effects.size())); Effect &effect = effects[id]; if(effect.spawners.empty()) return; float size = effect.sizeMin; float sizeDelta = effect.sizeMax - effect.sizeMin; size += (rand() / float(RAND_MAX)) * sizeDelta; int spawnerIndex = rand() % effect.spawners.size(); DecalSpawner &spawner = *effect.spawners[spawnerIndex]; spawner.setSize(VC2(size, size)); if(!effect.randomRotation) spawner.spawnDecal(identifier, position, rotation, light, inBuilding); else { float angle = rand() % 6000 / 1000.f; QUAT r; r.MakeFromAngles(0, 0, angle); r = r * rotation; spawner.spawnDecal(identifier, position, r, light, inBuilding); } }
void SimpleAudioEngine::preloadEffect(const char* pszFilePath) { int nRet = 0; CCAudioOut* pEffectPlayer = NULL; do { BREAK_IF(! pszFilePath); string strFilePath = fullPathFromRelativePath(pszFilePath); nRet = _Hash(strFilePath.c_str()); BREAK_IF(s_List.end() != s_List.find(nRet)); //AppLog("not find effect, create it..."); if (s_List.size() >= 64) { // get the first effect, and remove it form list //AppLog("effect preload more than 64, delete the first effect"); pEffectPlayer = s_List.begin()->second; pEffectPlayer->Finalize(); s_List.erase(s_List.begin()->first); } if (pEffectPlayer == NULL) pEffectPlayer = new CCAudioOut; pEffectPlayer->Initialize(strFilePath.c_str()); s_List.insert(Effect(nRet, pEffectPlayer)); } while (0); }
float getMaxSize(int id) const { assert(id >= 0 && id < int(effects.size())); return effects[id].sizeMax; }