int Heartbeat::value(unsigned long time) { fadeAmplitude(time); float portion = adjustTime(time)/((float) _period) * N_ECG; // normalize the proportion to 2PI return (int)(ECG[(int)portion] * (_amplitude/255.0)); }
int SineWave::value(unsigned long time) { fadeAmplitude(time); float portion = adjustTime(time)/((float) _period) * 2 * M_PI; // normalize the proportion to 2PI return (int) ((sin(portion) + 1) * _amplitude) / 2; }
//-------------------------------------------------------------------------- // Update //-------------------------------------------------------------------------- void CameraShake::update( F32 dt ) { Parent::update( dt ); fadeAmplitude(); VectorF camOffset; camOffset.x = mAmp.x * sin( M_2PI * (mTimeOffset.x + mElapsedTime) * mFreq.x ); camOffset.y = mAmp.y * sin( M_2PI * (mTimeOffset.y + mElapsedTime) * mFreq.y ); camOffset.z = mAmp.z * sin( M_2PI * (mTimeOffset.z + mElapsedTime) * mFreq.z ); VectorF rotAngles; rotAngles.x = camOffset.x * 10.0 * M_PI/180.0; rotAngles.y = camOffset.y * 10.0 * M_PI/180.0; rotAngles.z = camOffset.z * 10.0 * M_PI/180.0; MatrixF rotMatrix( EulerF( rotAngles.x, rotAngles.y, rotAngles.z ) ); mCamFXTrans = rotMatrix; mCamFXTrans.setPosition( camOffset ); }