//--------------------------------------------------------------------- // Add a sound by tag to the list //--------------------------------------------------------------------- void CSoundOBJ::AddSound(int No,Tag idn) { CAudioManager *snd = globals->snd; CSoundBUF *sbf = snd->GetSoundBUF(idn); if (sounds[No]) gtfo("Sound conflict"); sounds[No] = sbf; if (0 == sbf) return; if (No > sEnd) sEnd = No; return; }
//--------------------------------------------------------------------- // Store Flap positions // NOTE: for each position there is a corresponding keyframe // and the full range (0, 1) needs T seconds. //--------------------------------------------------------------------- void CAnimatedModel::InitFlap(int n,FLAP_POS *p,float time) { nPos = n; aPos = p; cPos = 0; int dg0 = p[0].degre; int dtv = p[n-1].degre - dg0; float dkf = float(1) / dtv; //----Compute positional keyframe in table ------------ for (int k=0; k != n; k++) {float kf = float(p[k].degre - dg0) * dkf; p[k].kFrame = kf; } //---Propagate the time constant to all flaps --------- aFlap.SetTime(time); //---Init sounds -------------------------------------- CAudioManager *snd = globals->snd; Tag id1 = '1flp'; CVector lef(-10,0,0); s1Flap = new CSoundOBJ(id1,lef); s1Flap->SetGain(0.4f); Tag id2 = '2flp'; CVector rit(+10,0,0); //MEMORY_LEAK_MARKER ("s2Flap"); s2Flap = new CSoundOBJ(id2,rit); //MEMORY_LEAK_MARKER ("s2Flap"); s2Flap->SetGain(0.4f); //---Init flap sounds -------------------------------- for (int k=1; k < n; k++) { Tag snn = 'Flp0' + k; CSoundBUF *sb1 = snd->GetSoundBUF(snn); if (sb1) s1Flap->SetSBUF(k,sb1); CSoundBUF *sb2 = snd->GetSoundBUF(snn); if (sb2) s2Flap->SetSBUF(k,sb2); } //---Dupplicate sound up to max ----------------------- s1Flap->FillFlaps(); s2Flap->FillFlaps(); return; }