rl_bren.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. LICENSE
  3. -------
  4. Copyright 2005 Nullsoft, Inc.
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright notice,
  9. this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice,
  11. this list of conditions and the following disclaimer in the documentation
  12. and/or other materials provided with the distribution.
  13. * Neither the name of Nullsoft nor the names of its contributors may be used to
  14. endorse or promote products derived from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  16. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  18. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  21. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #ifdef LASER
  25. #include <windows.h>
  26. #include <commctrl.h>
  27. #include "../r_defs.h"
  28. #include "../resource.h"
  29. #include <math.h>
  30. #define C_THISCLASS CLASER_BrenClass
  31. #define MOD_NAME "Render / Brennan\'s Effect"
  32. typedef struct {
  33. float x, y;
  34. } PT;
  35. typedef struct {
  36. PT pt[4];
  37. } segment;
  38. #define BOUND (0.6f)
  39. #define NSEG 48
  40. #define VISSEG 6
  41. class C_THISCLASS : public C_RBASE {
  42. protected:
  43. public:
  44. C_THISCLASS();
  45. virtual ~C_THISCLASS();
  46. virtual int render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h); // returns 1 if fbout has dest
  47. virtual char *get_desc() { return MOD_NAME; }
  48. virtual HWND conf(HINSTANCE hInstance, HWND hwndParent);
  49. virtual void load_config(unsigned char *data, int len);
  50. virtual int save_config(unsigned char *data);
  51. segment seg[NSEG];
  52. PT d[4];
  53. float phase;
  54. int step;
  55. };
  56. #define PUT_INT(y) data[pos]=(y)&255; data[pos+1]=(y>>8)&255; data[pos+2]=(y>>16)&255; data[pos+3]=(y>>24)&255
  57. #define GET_INT() (data[pos]|(data[pos+1]<<8)|(data[pos+2]<<16)|(data[pos+3]<<24))
  58. void C_THISCLASS::load_config(unsigned char *data, int len)
  59. {
  60. int pos=0;
  61. }
  62. int C_THISCLASS::save_config(unsigned char *data)
  63. {
  64. int pos=0,x=0;
  65. return pos;
  66. }
  67. float frandom() {
  68. return (float)rand() / (float)RAND_MAX;
  69. }
  70. C_THISCLASS::C_THISCLASS()
  71. {
  72. int i, j;
  73. for (j = 0; j < NSEG; j++) {
  74. for (i = 0; i < 4; i++) {
  75. // seg[j].pt[i].x = frandom() * 2.0 - 1.0;
  76. // seg[j].pt[i].y = frandom() * 2.0 - 1.0;
  77. seg[j].pt[i].x = 0.f;
  78. seg[j].pt[i].y = 0.f;
  79. }
  80. }
  81. for (i = 0; i < 4; i++) {
  82. d[i].x = frandom() * 0.015 + 0.005;
  83. d[i].y = frandom() * 0.015 + 0.005;
  84. }
  85. phase = 0.0;
  86. step = 0;
  87. }
  88. C_THISCLASS::~C_THISCLASS()
  89. {
  90. }
  91. #define PI 3.14159
  92. int C_THISCLASS::render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h) // returns 1 if fbout has dest
  93. {
  94. if (isBeat&0x80000000) return 0;
  95. LineType l;
  96. int i, j;
  97. float s;
  98. s = sin(phase * 2 * PI)*0.10+0.9;
  99. //s = 1.0;
  100. //s = 0.8 + isBeat * 0.2;
  101. for (i = 0; i < 4; i++) {
  102. seg[0].pt[i].x += d[i].x * s;
  103. seg[0].pt[i].y += d[i].y * s;
  104. if (seg[0].pt[i].x < -BOUND || seg[0].pt[i].x > BOUND) d[i].x = -d[i].x;
  105. if (seg[0].pt[i].y < -BOUND || seg[0].pt[i].y > BOUND) d[i].y = -d[i].y;
  106. }
  107. for (j = 0; j < NSEG; j++) {
  108. static PT p;
  109. if ((step++ % (NSEG/VISSEG)) != 0) continue;
  110. for (i = 0; i < 4; i++) {
  111. l.mode=0;
  112. l.color=RGB(0, 0, 255);
  113. l.x1= seg[j].pt[i].x * s;
  114. l.y1= seg[j].pt[i].y * s;
  115. l.x2= (p.x)*s;
  116. l.y2= (p.y)*s;
  117. p = seg[j].pt[i];
  118. g_laser_linelist->AddLine(&l);
  119. l.x1 = l.x2;
  120. l.y1 = l.y2;
  121. l.mode=1;
  122. l.color=RGB(0, 255, 0);
  123. g_laser_linelist->AddLine(&l);
  124. }
  125. }
  126. for (i = NSEG-1; i > 0; i--) {
  127. seg[i] = seg[i-1];
  128. }
  129. phase += 0.005f;
  130. return 0;
  131. }
  132. C_RBASE *RLASER_Bren(char *desc)
  133. {
  134. if (desc) { strcpy(desc,MOD_NAME); return NULL; }
  135. return (C_RBASE *) new C_THISCLASS();
  136. }
  137. static C_THISCLASS *g_this;
  138. static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  139. {
  140. return 0;
  141. }
  142. HWND C_THISCLASS::conf(HINSTANCE hInstance, HWND hwndParent)
  143. {
  144. g_this = this;
  145. return 0;//WASABI_API_CREATEDIALOG(IDD_CFG_LINE,hwndParent,g_DlgProc);
  146. }
  147. #endif