/
waves3_wf.cpp
207 lines (181 loc) · 7 KB
/
waves3_wf.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#define PLUGIN_WARNING "NOTE_modded_for_jwildfire_workflow"
/*
Apophysis Plugin: waves3_wf
Port of: https://github.com/thargor6/JWildfire/blob/master/src/org/jwildfire/create/tina/variation/Waves3WFFunc.java
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "datahelpers.h"
typedef struct
{
double scalex;
double scaley;
double freqx; // M_PI / 2
double freqy; // M_PI / 4
int use_cos_x;
int use_cos_y;
double dampx;
double dampy;
double _dampingX;
double _dampingY;
} Variables;
#define APO_VARIABLE_PREFIX "waves3_wf_"
#include "plugin.h"
APO_PLUGIN("waves3_wf");
APO_VARIABLES(
VAR_REAL(scalex, 0.25),
VAR_REAL(scaley, 0.5),
VAR_REAL(freqx, M_PI / 2),
VAR_REAL(freqy, M_PI / 4),
VAR_INTEGER(use_cos_x, 1),
VAR_INTEGER(use_cos_y, 0),
VAR_REAL(dampx, 0.0),
VAR_REAL(dampy, 0.0)
);
int PluginVarPrepare(Variation* vp)
{
VAR(_dampingX) = fabs(VAR(dampx)) < EPSILON ? 1.0 : exp(VAR(dampx));
VAR(_dampingY) = fabs(VAR(dampy)) < EPSILON ? 1.0 : exp(VAR(dampy));
return TRUE;
}
int PluginVarCalc(Variation* vp)
{
/* Modified version of waves2 from Joel F */
if (VAR(use_cos_x) == 1) {
FPx += VVAR * (FTx + VAR(_dampingX) * VAR(scalex) * cos(FTy * VAR(freqx)) * cos(FTy * VAR(freqx))) * VAR(_dampingX);
} else {
FPx += VVAR * (FTx + VAR(_dampingX) * VAR(scalex) * sin(FTy * VAR(freqx)) * sin(FTy * VAR(freqx))) * VAR(_dampingX);
}
if (VAR(use_cos_y) == 1) {
FPy += VVAR * (FTy + VAR(_dampingY) * VAR(scaley) * cos(FTx * VAR(freqy)) * cos(FTx * VAR(freqy))) * VAR(_dampingY);
} else {
FPy += VVAR * (FTy + VAR(_dampingY) * VAR(scaley) * sin(FTx * VAR(freqy)) * sin(FTx * VAR(freqy))) * VAR(_dampingY);
}
if (true /* pContext\.isPreserveZCoordinate() */) {
FPz += VVAR * FTz;
}
return TRUE;
}
// original java file embedded here:
//
// /*
// JWildfire - an image and animation processor written in Java
// Copyright (C) 1995-2011 Andreas Maschke
//
// This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
// General Public License as published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along with this software;
// if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301 USA, or see the FSF site: http://www.fsf.org.
// */
// package org.jwildfire.create.tina.variation;
//
// import org.jwildfire.base.Tools;
// import org.jwildfire.create.tina.base.Layer;
// import org.jwildfire.create.tina.base.XForm;
// import org.jwildfire.create.tina.base.XYZPoint;
//
// import static org.jwildfire.base.mathlib.MathLib.*;
//
// public class Waves3WFFunc extends VariationFunc {
// private static final long serialVersionUID = 1L;
//
// private static final String PARAM_SCALEX = "scalex";
// private static final String PARAM_SCALEY = "scaley";
// private static final String PARAM_FREQX = "freqx";
// private static final String PARAM_FREQY = "freqy";
// private static final String PARAM_USECOSX = "use_cos_x";
// private static final String PARAM_USECOSY = "use_cos_y";
// private static final String PARAM_DAMPX = "dampx";
// private static final String PARAM_DAMPY = "dampy";
// private static final String[] paramNames = {PARAM_SCALEX, PARAM_SCALEY, PARAM_FREQX, PARAM_FREQY, PARAM_USECOSX, PARAM_USECOSY, PARAM_DAMPX, PARAM_DAMPY};
//
// private double scalex = 0.25;
// private double scaley = 0.5;
// private double freqx = M_PI / 2;
// private double freqy = M_PI / 4;
// private int use_cos_x = 1;
// private int use_cos_y = 0;
// private double dampx = 0.0;
// private double dampy = 0.0;
//
// @Override
// public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
// /* Modified version of waves2 from Joel F */
// if (use_cos_x == 1) {
// pVarTP.x += pAmount * (pAffineTP.x + _dampingX * scalex * cos(pAffineTP.y * freqx) * cos(pAffineTP.y * freqx)) * _dampingX;
// } else {
// pVarTP.x += pAmount * (pAffineTP.x + _dampingX * scalex * sin(pAffineTP.y * freqx) * sin(pAffineTP.y * freqx)) * _dampingX;
// }
// if (use_cos_y == 1) {
// pVarTP.y += pAmount * (pAffineTP.y + _dampingY * scaley * cos(pAffineTP.x * freqy) * cos(pAffineTP.x * freqy)) * _dampingY;
// } else {
// pVarTP.y += pAmount * (pAffineTP.y + _dampingY * scaley * sin(pAffineTP.x * freqy) * sin(pAffineTP.x * freqy)) * _dampingY;
// }
// if (pContext.isPreserveZCoordinate()) {
// pVarTP.z += pAmount * pAffineTP.z;
// }
// }
//
// @Override
// public String[] getParameterNames() {
// return paramNames;
// }
//
// @Override
// public Object[] getParameterValues() {
// return new Object[]{scalex, scaley, freqx, freqy, use_cos_x, use_cos_y, dampx, dampy};
// }
//
// @Override
// public void setParameter(String pName, double pValue) {
// if (PARAM_SCALEX.equalsIgnoreCase(pName))
// scalex = pValue;
// else if (PARAM_SCALEY.equalsIgnoreCase(pName))
// scaley = pValue;
// else if (PARAM_FREQX.equalsIgnoreCase(pName))
// freqx = pValue;
// else if (PARAM_FREQY.equalsIgnoreCase(pName))
// freqy = pValue;
// else if (PARAM_USECOSX.equalsIgnoreCase(pName))
// use_cos_x = Tools.FTOI(pValue);
// else if (PARAM_USECOSY.equalsIgnoreCase(pName))
// use_cos_y = Tools.FTOI(pValue);
// else if (PARAM_DAMPX.equalsIgnoreCase(pName))
// dampx = pValue;
// else if (PARAM_DAMPY.equalsIgnoreCase(pName))
// dampy = pValue;
// else
// throw new IllegalArgumentException(pName);
// }
//
// @Override
// public String getName() {
// return "waves3_wf";
// }
//
// private double _dampingX, _dampingY;
//
// @Override
// public void init(FlameTransformationContext pContext, Layer pLayer, XForm pXForm, double pAmount) {
// _dampingX = fabs(dampx) < EPSILON ? 1.0 : exp(dampx);
// _dampingY = fabs(dampy) < EPSILON ? 1.0 : exp(dampy);
// }
//
// }
//