• Advertisement

whitechaos35

Member
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

100 Neutral

About whitechaos35

  • Rank
    Newbie
  1. N64 Quality Water...

    [quote name='projectionmatrix' timestamp='1318876917' post='4873576'] My question is i want to make the ripple temporary, like someone had dropped an object into the water. That is have it only start in the center, move outward then calm back down. Any ideas on how this effect could be achieved? Thanks for all the help so far everyone! [/quote] Every point within some radius of the impact point is going to oscillate. Points at an equal distance from the impact are going to be at the same value, which is determined by the phase at that distance and the attenuation value for that distance. A nice looking attenuation wave would look Gaussian. If you can get the DDS algorithm I provided to work for you, then you can get phase-continuous samples for a sine wave (meaning if you want the frequency to decrease over time it will look perfect). By taking each of these samples and multiplying it by the corresponding attenuation sample, you will construct a "ripple wave". You can then map the distance from impact into a phase-lookup in the ripple table. This solution eliminates your sine computation *for every value*, so long as you can output a sine wave from the DDS algorithm, which itself doesn't even compute sine values. You also mention that you were having trouble implementing the DDS algorithm. Are you calling the "UpdateSineWaves" equivalent function at an exact frequency? If so, what is that frequency (500Hz, 1KHz, 10KHz)? Is this value defined as INC_FREQ? Is the accumulator variable 32 bits? If not, you need to set ACC_BITS to the number of bits. Is it unsigned (This algorithm works because of wraparound)? Is ACC_VALUES 2^(ACC_BITS)? If SAMPLE_BITS is 8, do you have a sine wave with 2^8 (256) values? If you still can't get it to work, post what you have and I'll be happy to take a look.
  2. N64 Quality Water...

    [quote name='projectionmatrix' timestamp='1318605018' post='4872528'] Can anyone point me in the right direction to using a lookup table for this? [/quote] Take a look at [url="http://www.analog.com/library/analogDialogue/archives/38-08/dds.html"]Direct Digital Synthesis[/url]. No need to even calculate sine values, just keep them in a lookup table. If a function call at a fixed frequency is available to you, this is an efficient way to calculate sine values: [code] #define INC_FREQ 10000 // hertz #define ACC_BITS 32 #define ACC_VALUES 4294967296 #define SAMPLE_BITS 8 // There are 2^(SAMPLE_BITS) samples #define FREQ_INCR(f) ((long)f * (long)ACC_VALUES) / INC_FREQ void UpdateSineWaves() { for( int i=0; i<numSineWaves; i++ ) { sineWaves[i].accumulator += sineWaves[i].frequencyIncrement; sineWaves[i].amplitude = sineWave[sineWaves[i].accumulator>>(ACC_BITS-SAMPLE_BITS)]; } } [/code] To adjust the frequency of a sine wave, just change the frequency increment. This doesn't affect the phase, so the result is very smooth, like what might be wanted for water waves. ;)
  • Advertisement