watergen.h 926 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. #ifndef __C_WATERGEN__
  5. #define __C_WATERGEN__
  6. #include <QImage>
  7. #define WATERGEN_TABLE_LENGTH 1024
  8. #define WATERGEN_TABLE_AND 1023
  9. #define WATERGEN_TABLE_BITS 10
  10. class WaterGen {
  11. public:
  12. WaterGen();
  13. ~WaterGen();
  14. void reinitWaves( int amount, bool static_waves = true );
  15. int getNofWaves() { return waveComponentAmount; }
  16. void generate( QImage &targetImage,
  17. QImage &reflection,
  18. const float timePassed );
  19. protected:
  20. int cosineTable[ WATERGEN_TABLE_LENGTH ];
  21. int initializedWidth;
  22. int initializedHeight;
  23. int *waveHeightMap;
  24. struct SWaveComponent {
  25. int xm;
  26. int ym;
  27. int amplitude;
  28. int movingSpeed;
  29. int currentPos;
  30. };
  31. SWaveComponent *waveComponents;
  32. int waveComponentAmount;
  33. };
  34. #endif