bool StGLMesh::initVBOs(StGLContext& theCtx) { // reset all current VBOs clearVRAM(theCtx); if(myVertices.isEmpty() && !computeMesh()) { // no vertices - invalid mesh return false; } if(myVertices.isEmpty()) { // no vertices - invalid mesh return false; } bool isOK = myVertexBuf.init(theCtx, myVertices); if(!myNormals.isEmpty() && myNormals.size() == myVertices.size()) { isOK = isOK && myNormalBuf.init(theCtx, myNormals); } if(!myTCoords.isEmpty() && myTCoords.size() == myVertices.size()) { isOK = isOK && myTCoordBuf.init(theCtx, myTCoords); } if(!myColors.isEmpty() && myColors.size() == myVertices.size()) { isOK = isOK && myColorsBuf.init(theCtx, myColors); } if(!myIndices.isEmpty()) { isOK = isOK && myIndexBuf.init(theCtx, myIndices); } return isOK; };
//-------------------------------------------------------------- void WaveManager::setNbPoints(int nb) { if (m_nbPoints != nb) { m_nbPoints = nb; int nbWaves = m_waves.size(); for (int i=0; i<nbWaves;i++) m_waves[i]->setNbPoints(nb); computeMesh(); } }
//-------------------------------------------------------------- void WaveManager::update(float dt) { if (mp_parent==0) return; m_volumeAccum.m_valueTriggerIn = mp_parent->m_valueTriggerIn; m_volumeAccum.m_valueTriggerOut = mp_parent->m_valueTriggerOut; m_volumeAccum.update(dt); if ( mp_parent->m_enableTimeResetAccum && ( m_volumeAccum.m_state == VolumeAccum::STATE_WAVE_INSIDE && m_volumeAccum.m_stateTime >= mp_parent->m_timeResetAccum ) ) { m_volumeAccum.reset(); } if (mp_parent->hasPitch()) { // updateNbPoints(); } int nbWaves = m_waves.size(); for (int i=0; i<nbWaves;i++) { m_waves[i]->setAgeMax(mp_parent->m_ageMax); m_waves[i]->setSpeed(mp_parent->m_speed); m_waves[i]->update(dt); } // Remove old ones vector<Wave*>::iterator it = m_waves.begin(); while( it != m_waves.end()) { if ( (*it)->isOld() ) { delete *it; it = m_waves.erase(it); } else{ ++it; } } computeMesh(); }