bool XRandBG::init(int w, int h, const char* filename, int objsSum, bool m_withUI) { if (m_isInited || w <= 0 || h <= 0) return false; resetParameter(); if (m_withUI) { XCFGManager.addGroup("背景参数"); XCFGManager.addAItem<float>(&m_minSpeed, CFG_DATA_FLOAT, "最小速度", 100.0f, 0.01f, 5.0f, nullptr, "背景参数"); XCFGManager.addAItem<float>(&m_maxSpeed, CFG_DATA_FLOAT, "最大速度", 100.0f, 0.01f, 10.0f, nullptr, "背景参数"); XCFGManager.addAItem<float>(&m_minScale, CFG_DATA_FLOAT, "最小缩放", 10.0f, 0.01f, 0.5f, nullptr, "背景参数"); XCFGManager.addAItem<float>(&m_maxScale, CFG_DATA_FLOAT, "最大缩放", 10.0f, 0.01f, 1.25f, nullptr, "背景参数"); XCFGManager.addAItem<float>(&m_minEnergy, CFG_DATA_FLOAT, "最小能量", 10000.0f, 1.0f, 400.0f, nullptr, "背景参数"); XCFGManager.addAItem<float>(&m_maxEnergy, CFG_DATA_FLOAT, "最大能量", 10000.0f, 1.0f, 800.0f, nullptr, "背景参数"); XCFGManager.addAItem<float>(&m_minStrength, CFG_DATA_FLOAT, "最小强度", 500.0f, 1.0f, 20.0f, nullptr, "背景参数"); XCFGManager.addAItem<float>(&m_maxStrength, CFG_DATA_FLOAT, "最大强度", 500.0f, 1.0f, 40.0f, nullptr, "背景参数"); XCFGManager.addAItem<float>(&m_minRecoveryRate, CFG_DATA_FLOAT, "最小恢复", 1000.0f, 1.0f, 150.0f, nullptr, "背景参数"); XCFGManager.addAItem<float>(&m_maxRecoveryRate, CFG_DATA_FLOAT, "最大恢复", 1000.0f, 1.0f, 250.0f, nullptr, "背景参数"); } m_w = w; m_h = h; m_buff.resize(m_w * m_h); if (!m_fbo.init(m_w, m_h, COLOR_GRAY)) return false; if (!m_tex.load(filename)) return false; m_avgBornTimer = 5.0f; m_bornTime = XRand::randomf(0.75f, 1.25f) * m_avgBornTimer; m_objs.resize(objsSum + 2); for (int i = 0; i < m_objs.size(); ++i) { m_freeObjs.push_back(&m_objs[i]); } for (int i = 0; i < objsSum; ++i) //初始化5个粒子 born(); m_isInited = true; return true; }
bool KNMusicBackendMpvThread::loadFile(const QString &filePath) { //Check out the file path. if(m_filePath==filePath) { ; } //Save the load file path. m_filePath=filePath; //Reset the thread data first. m_totalDuration=-1; resetParameter(); //Open file path in the mpv handle. //Prepare load file commands. const char *args[] = {"loadfile", filePath.toUtf8().constData(), NULL}; //Launch command. exeCommand(args); //Give back loaded signal. return true; }
void PolarEmitter::setEnabled(bool enabled) { resetParameter(); ParticleEmitter::setEnabled(enabled); }