Advertisement
zephyrtronium

rod

May 9th, 2011
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.48 KB | None | 0 0
  1. /*
  2.     rod Apophysis Plugin
  3.     Copyright 2011 Branden Brown, a.k.a. zephyrtronium
  4.  
  5.     This plugin is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 3 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This plugin is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this plugin; if not, see <http://www.gnu.org/licenses/>.
  17. */
  18.  
  19. typedef struct
  20. {
  21.     double rod_blur;
  22.  
  23.     int n; double r[4];
  24. } Variables;
  25.  
  26. #include "apoplugin.h"
  27.  
  28. APO_PLUGIN("rod");
  29.  
  30. APO_VARIABLES(
  31.     VAR_REAL(rod_blur, 1.25),
  32. );
  33.  
  34. int PluginVarPrepare(Variation* vp)
  35. {
  36.     VAR(n) = 0;
  37.     VAR(r)[0] = random01();
  38.     VAR(r)[1] = random01();
  39.     VAR(r)[2] = random01();
  40.     VAR(r)[3] = random01();
  41.  
  42.     return TRUE;
  43. }
  44.  
  45. int PluginVarCalc(Variation* vp)
  46. {
  47.     double r, sr, cr;
  48.  
  49.     fsincos(random01() * M_2PI, &sr, &cr);
  50.     r = VAR(rod_blur) * (VAR(r)[0] + VAR(r)[1] + VAR(r)[2] + VAR(r)[3] - 2.0);
  51.     VAR(r)[VAR(n)] = random01();
  52.     VAR(n) = VAR(n) + 1 & 3;
  53.    
  54.     FPx += VVAR * sin(FTx + r * sr);
  55.     FPy += r + FTy;
  56.     FPz += VVAR * cos(FTx + r * cr);
  57.    
  58.     return TRUE;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement