1 /********************************************************* 2 / MANDELBULBER 3 / definition of structures for fractal parameters 4 / 5 / 6 / author: Krzysztof Marczak 7 / contact: buddhi1980@gmail.com 8 / licence: GNU GPL v3.0 9 / 10 ********************************************************/ 11 12 #ifndef FRACTAL_H_ 13 #define FRACTAL_H_ 14 15 #include <vector> 16 #include "common_math.h" 17 #ifndef MANDELBULBER_EMBEDDED 18 #include "fractparams.h" 19 #endif 20 #include <stddef.h> 21 #include <string> 22 23 const int IFS_VECTOR_COUNT = 9; 24 const int HYBRID_COUNT = 5; 25 const int MANDELBOX_FOLDS = 2; 26 27 enum enumFractalFormula 28 { 29 none = 0, 30 trig_DE = 1, 31 trig_optim = 2, 32 fast_trig = 3, 33 hypercomplex = 4, 34 quaternion = 5, 35 minus_fast_trig = 6, 36 menger_sponge = 7, 37 tglad = 8, 38 kaleidoscopic = 10, 39 xenodreambuie = 11, 40 hybrid = 12, 41 mandelbulb2 = 13, 42 mandelbulb3 = 14, 43 mandelbulb4 = 15, 44 foldingIntPow2 = 16, 45 smoothMandelbox = 17, 46 mandelboxVaryScale4D = 18, 47 aexion = 19, 48 benesi = 20, 49 bristorbrot = 21, 50 invertX = 22, 51 invertY = 23, 52 invertZ = 24, 53 invertR = 25, 54 sphericalFold = 26, 55 powXYZ = 27, 56 scaleX = 28, 57 scaleY = 29, 58 scaleZ = 30, 59 offsetX = 31, 60 offsetY = 32, 61 offsetZ = 33, 62 angleMultiplyX = 34, 63 angleMultiplyY = 35, 64 angleMultiplyZ = 36, 65 generalizedFoldBox = 37, 66 ocl_custom = 38 67 }; 68 69 enum enumCalculationMode 70 { 71 normal_mode = 0, colouring = 1, fake_AO = 2, deltaDE1 = 3, deltaDE2 = 4, orbitTrap = 5 72 }; 73 74 enum enumGeneralizedFoldBoxType 75 { 76 foldTet = 0, 77 foldCube = 1, 78 foldOct = 2, 79 foldDodeca = 3, 80 foldOctCube = 4, 81 foldIcosa = 5, 82 foldBox6 = 6, 83 foldBox5 = 7 84 }; 85 86 enum enumObjectType 87 { 88 objFractal = 0, 89 objPlane = 1, 90 objWater = 2, 91 objSphere = 3, 92 objSphereInv = 4, 93 objBox = 5, 94 objBoxInv = 6 95 }; 96 97 enum enumOCLDEMode 98 { 99 calculated = 0, 100 deltaDE = 1, 101 noDE = 2 102 }; 103 104 struct sFractalIFSD 105 { 106 double rotationGamma; 107 double rotationAlfa; 108 double rotationBeta; 109 double scale; 110 double distance[IFS_VECTOR_COUNT]; 111 double alfa[IFS_VECTOR_COUNT]; 112 double beta[IFS_VECTOR_COUNT]; 113 double gamma[IFS_VECTOR_COUNT]; 114 double intensity[IFS_VECTOR_COUNT]; 115 CVector3 offset; 116 CVector3 direction[IFS_VECTOR_COUNT]; 117 CVector3 edge; 118 }; 119 120 struct sFractalGeneralizedFoldBox 121 { 122 enum enumGeneralizedFoldBoxType type; 123 CVector3 Nv_tet[4]; 124 CVector3 Nv_cube[6]; 125 CVector3 Nv_oct[8]; 126 CVector3 Nv_oct_cube[14]; 127 CVector3 Nv_dodeca[12]; 128 CVector3 Nv_icosa[20]; 129 CVector3 Nv_box6[8]; 130 CVector3 Nv_box5[7]; 131 int sides_tet; 132 int sides_cube; 133 int sides_oct; 134 int sides_oct_cube; 135 int sides_dodeca; 136 int sides_icosa; 137 int sides_box6; 138 int sides_box5; 139 }; 140 141 struct sFractalIFS 142 { 143 sFractalIFSD doubles; 144 bool absX, absY, absZ; 145 bool foldingMode; // Kaleidoscopic IFS folding mode 146 bool enabled[IFS_VECTOR_COUNT]; 147 bool mengerSpongeMode; 148 int foldingCount; 149 CRotationMatrix mainRot; 150 CRotationMatrix rot[IFS_VECTOR_COUNT]; 151 }; 152 153 struct sFractalMandelboxVary4D 154 { 155 double fold; 156 double minR; 157 double scaleVary; 158 double wadd; 159 double rPower; 160 }; 161 162 struct sFractalMandelboxD 163 { 164 double rotationMain[3]; 165 double rotation[MANDELBOX_FOLDS][3][3]; 166 double colorFactorX; 167 double colorFactorY; 168 double colorFactorZ; 169 double colorFactorR; 170 double colorFactorSp1; 171 double colorFactorSp2; 172 double scale; 173 double foldingLimit; 174 double foldingValue; 175 double foldingSphericalMin; 176 double foldingSphericalFixed; 177 double sharpness; 178 double solid; 179 double melt; 180 CVector3 offset; 181 sFractalMandelboxVary4D vary4D; 182 }; 183 184 struct sFractalMandelbox 185 { 186 sFractalMandelboxD doubles; 187 bool rotationsEnabled; 188 CRotationMatrix mainRot; 189 CRotationMatrix rot[MANDELBOX_FOLDS][3]; 190 CRotationMatrix rotinv[MANDELBOX_FOLDS][3]; 191 }; 192 193 struct sFractalPrimitivesD 194 { 195 CVector3 planeCentre; 196 CVector3 planeNormal; 197 CVector3 boxCentre; 198 CVector3 boxSize; 199 CVector3 invertedBoxCentre; 200 CVector3 invertedBoxSize; 201 CVector3 sphereCentre; 202 double sphereRadius; 203 CVector3 invertedSphereCentre; 204 double invertedSphereRadius; 205 double waterHeight; 206 double waterAmplitude; 207 double waterLength; 208 double waterRotation; 209 double waterAnimSpeed; 210 }; 211 212 struct sFractalPrimitives 213 { 214 bool planeEnable; 215 bool boxEnable; 216 bool invertedBoxEnable; 217 bool sphereEnable; 218 bool invertedSphereEnable; 219 bool waterEnable; 220 bool onlyPlane; 221 int waterIterations; 222 }; 223 224 struct sFractalD 225 { 226 double N; 227 double amin; //fractal limits 228 double amax; 229 double bmin; 230 double bmax; 231 double cmin; 232 double cmax; 233 double constantFactor; 234 double FoldingIntPowZfactor; 235 double FoldingIntPowFoldFactor; 236 double foldingLimit; //paramters of TGlad's folding 237 double foldingValue; 238 double foldingSphericalMin; 239 double foldingSphericalFixed; 240 double detailSize; 241 double power; //power of fractal formula 242 double cadd; 243 double hybridPower[HYBRID_COUNT]; 244 #ifdef CLSUPPORT 245 double customParameters[15]; 246 double deltaDEStep; 247 #endif 248 CVector3 julia; // Julia constant 249 CVector3 fakeLightsOrbitTrap; 250 sFractalPrimitivesD primitives; 251 }; 252 253 struct sFractal 254 { 255 sFractalD doubles; 256 257 // maximum number of iterations 258 int minN; // minimum number of iterations 259 260 bool limits_enabled; // enable limits (intersections) 261 bool iterThresh; //maxiter threshold mode 262 bool analitycDE; //analytic DE mode 263 bool juliaMode; // Julia mode 264 bool tgladFoldingMode; // Tglad's folding mode 265 bool sphericalFoldingMode; // spherical folding mode 266 bool interiorMode; 267 bool hybridCyclic; 268 bool linearDEmode; 269 bool constantDEThreshold; 270 bool useCustomOCLFormula; 271 bool normalCalculationMode; 272 273 enumFractalFormula formula; 274 275 int hybridIters[HYBRID_COUNT]; 276 enumFractalFormula hybridFormula[HYBRID_COUNT]; 277 278 std::vector<enumFractalFormula> formulaSequence; 279 std::vector<double> hybridPowerSequence; 280 char customOCLFormulaName[100]; 281 enumOCLDEMode customOCLFormulaDEMode; 282 283 sFractalIFS IFS; 284 sFractalMandelbox mandelbox; 285 sFractalGeneralizedFoldBox genFoldBox; 286 sFractalPrimitives primitives; 287 288 int frameNo; 289 290 int itersOut; 291 enumObjectType objectOut; 292 293 int fakeLightsMinIter; 294 int fakeLightsMaxIter; 295 }; 296 297 template <int Mode> double Compute(CVector3 z, const sFractal &par, int *iter_count = NULL); 298 double CalculateDistance(CVector3 point, sFractal &par, bool *max_iter = NULL); 299 300 #endif /* FRACTAL_H_ */ 301