propane 3.8.0-java → 3.9.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +2 -2
- data/Rakefile +1 -0
- data/lib/propane/app.rb +3 -2
- data/lib/propane/version.rb +1 -1
- data/library/pdf/pdf.rb +7 -0
- data/library/svg/svg.rb +7 -0
- data/pom.rb +24 -2
- data/pom.xml +40 -1
- data/propane.gemspec +3 -1
- data/src/main/java/monkstone/noise/FastTerrain.java +874 -0
- data/src/main/java/monkstone/noise/Noise.java +0 -26
- data/src/main/java/monkstone/noise/NoiseGenerator.java +35 -23
- data/src/main/java/monkstone/noise/NoiseMode.java +15 -2
- data/src/main/java/monkstone/noise/OpenSimplex2F.java +881 -0
- data/src/main/java/monkstone/noise/OpenSimplex2S.java +1106 -0
- data/src/main/java/monkstone/noise/SmoothTerrain.java +1099 -0
- data/src/main/java/processing/core/PApplet.java +106 -127
- data/src/main/java/processing/core/PGraphics.java +116 -109
- data/src/main/java/processing/pdf/PGraphicsPDF.java +581 -0
- data/src/main/java/processing/svg/PGraphicsSVG.java +378 -0
- data/vendors/Rakefile +1 -1
- metadata +14 -6
- data/src/main/java/monkstone/noise/SimplexNoise.java +0 -470
- data/src/main/java/monkstone/noise/ValueNoise.java +0 -170
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e735f345da64c2f55adcad27c1df98b630e6a73aa3c3d0c6551ef440b13c5546
|
4
|
+
data.tar.gz: 6a31bd1774ac6fee490dc72cb4958b9c315a24c524cb946612e7815613407b23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c8b9399f233cfd4de9a05898ba8751762d2a082122163ebc690977f342efb03198dc59657a51419f19c7e8d3fa245e2fcb273fe75639c1d2d2aed1732e81cd5
|
7
|
+
data.tar.gz: 84e74e51efe2dae32c8457c3b163385e4db9d0c280282d593c4f61428d4945ede7e0e9005d4d70520774df8851ad58ed4c3a84b2bc08f481efde05ced17c8383
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -25,10 +25,10 @@ rake javadoc
|
|
25
25
|
|
26
26
|
```bash
|
27
27
|
jgem install propane # from rubygems
|
28
|
-
jgem install propane-3.
|
28
|
+
jgem install propane-3.9.0-java.gem # local install
|
29
29
|
# Alternative
|
30
30
|
jruby -S gem install propane # from rubygems
|
31
|
-
jruby -S gem install propane-3.
|
31
|
+
jruby -S gem install propane-3.9.0-java.gem # local install
|
32
32
|
```
|
33
33
|
|
34
34
|
## Check Install
|
data/Rakefile
CHANGED
data/lib/propane/app.rb
CHANGED
@@ -16,8 +16,9 @@ module Propane
|
|
16
16
|
java_import 'monkstone.vecmath.ShapeRender'
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
module NoiseModule
|
20
|
+
java_import 'monkstone.noise.NoiseMode'
|
21
|
+
end
|
21
22
|
|
22
23
|
# This class is the base class the user should inherit from when making
|
23
24
|
# their own sketch.
|
data/lib/propane/version.rb
CHANGED
data/library/pdf/pdf.rb
ADDED
data/library/svg/svg.rb
ADDED
data/pom.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
project 'propane', 'https://github.com/monkstone/propane' do
|
4
4
|
model_version '4.0.0'
|
5
|
-
id 'propane:propane:3.
|
5
|
+
id 'propane:propane:3.9.0'
|
6
6
|
packaging 'jar'
|
7
7
|
|
8
8
|
description 'An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.'
|
@@ -44,9 +44,13 @@ project 'propane', 'https://github.com/monkstone/propane' do
|
|
44
44
|
'polyglot.dump.pom' => 'pom.xml',
|
45
45
|
'project.build.sourceEncoding' => 'utf-8',
|
46
46
|
'jogl.version' => '2.3.2', # for compiling actual included 2.4.0-rc
|
47
|
+
'batik.version' => '1.14',
|
48
|
+
'itextpdf.version' => '5.5.13.2',
|
47
49
|
'jruby.api' => 'http://jruby.org/apidocs/')
|
48
50
|
|
49
|
-
|
51
|
+
pom 'org.jruby:jruby:9.2.16.0'
|
52
|
+
jar 'org.apache.xmlgraphics:batik-all:${batik.version}'
|
53
|
+
jar 'com.itextpdf:itextpdf:${itextpdf.version}'
|
50
54
|
jar 'org.processing:video:3.3.7' # only for compiling
|
51
55
|
jar 'org.jogamp.jogl:jogl-all:${jogl.version}'
|
52
56
|
jar 'org.jogamp.gluegen:gluegen-rt-main:${jogl.version}'
|
@@ -56,6 +60,24 @@ project 'propane', 'https://github.com/monkstone/propane' do
|
|
56
60
|
'generateBackupPoms' => 'false')
|
57
61
|
plugin(:compiler, '3.8.1',
|
58
62
|
'release' => '11')
|
63
|
+
plugin :dependency, '3.1.2' do
|
64
|
+
execute_goals( id: 'default-cli',
|
65
|
+
artifactItems:[
|
66
|
+
{ groupId: 'com.itextpdf',
|
67
|
+
artifactId: 'itextpdf',
|
68
|
+
version: '${itextpdf.version}',
|
69
|
+
type: 'jar',
|
70
|
+
outputDirectory: '${propane.basedir}/library/pdf'
|
71
|
+
},
|
72
|
+
{ groupId: 'org.apache.xmlgraphics',
|
73
|
+
artifactId: 'batik-all',
|
74
|
+
version: '${batik.version}',
|
75
|
+
type: 'jar',
|
76
|
+
outputDirectory: '${propane.basedir}/library/svg'
|
77
|
+
}
|
78
|
+
]
|
79
|
+
)
|
80
|
+
end
|
59
81
|
plugin(:javadoc, '3.2.0',
|
60
82
|
'detectOfflineLinks' => 'false',
|
61
83
|
'links' => ['${jruby.api}',
|
data/pom.xml
CHANGED
@@ -11,7 +11,7 @@ DO NOT MODIFY - GENERATED CODE
|
|
11
11
|
<modelVersion>4.0.0</modelVersion>
|
12
12
|
<groupId>propane</groupId>
|
13
13
|
<artifactId>propane</artifactId>
|
14
|
-
<version>3.
|
14
|
+
<version>3.9.0</version>
|
15
15
|
<name>propane</name>
|
16
16
|
<description>An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.</description>
|
17
17
|
<url>https://github.com/monkstone/propane</url>
|
@@ -62,6 +62,8 @@ DO NOT MODIFY - GENERATED CODE
|
|
62
62
|
<url>https://github.com/ruby-processing/propane/issues</url>
|
63
63
|
</issueManagement>
|
64
64
|
<properties>
|
65
|
+
<batik.version>1.14</batik.version>
|
66
|
+
<itextpdf.version>5.5.13.2</itextpdf.version>
|
65
67
|
<jogl.version>2.3.2</jogl.version>
|
66
68
|
<jruby.api>http://jruby.org/apidocs/</jruby.api>
|
67
69
|
<polyglot.dump.pom>pom.xml</polyglot.dump.pom>
|
@@ -77,6 +79,16 @@ DO NOT MODIFY - GENERATED CODE
|
|
77
79
|
<version>9.2.16.0</version>
|
78
80
|
<type>pom</type>
|
79
81
|
</dependency>
|
82
|
+
<dependency>
|
83
|
+
<groupId>org.apache.xmlgraphics</groupId>
|
84
|
+
<artifactId>batik-all</artifactId>
|
85
|
+
<version>${batik.version}</version>
|
86
|
+
</dependency>
|
87
|
+
<dependency>
|
88
|
+
<groupId>com.itextpdf</groupId>
|
89
|
+
<artifactId>itextpdf</artifactId>
|
90
|
+
<version>${itextpdf.version}</version>
|
91
|
+
</dependency>
|
80
92
|
<dependency>
|
81
93
|
<groupId>org.processing</groupId>
|
82
94
|
<artifactId>video</artifactId>
|
@@ -130,6 +142,33 @@ DO NOT MODIFY - GENERATED CODE
|
|
130
142
|
<release>11</release>
|
131
143
|
</configuration>
|
132
144
|
</plugin>
|
145
|
+
<plugin>
|
146
|
+
<artifactId>maven-dependency-plugin</artifactId>
|
147
|
+
<version>3.1.2</version>
|
148
|
+
<executions>
|
149
|
+
<execution>
|
150
|
+
<id>default-cli</id>
|
151
|
+
<configuration>
|
152
|
+
<artifactItems>
|
153
|
+
<artifactItem>
|
154
|
+
<groupId>com.itextpdf</groupId>
|
155
|
+
<artifactId>itextpdf</artifactId>
|
156
|
+
<version>${itextpdf.version}</version>
|
157
|
+
<type>jar</type>
|
158
|
+
<outputDirectory>${propane.basedir}/library/pdf</outputDirectory>
|
159
|
+
</artifactItem>
|
160
|
+
<artifactItem>
|
161
|
+
<groupId>org.apache.xmlgraphics</groupId>
|
162
|
+
<artifactId>batik-all</artifactId>
|
163
|
+
<version>${batik.version}</version>
|
164
|
+
<type>jar</type>
|
165
|
+
<outputDirectory>${propane.basedir}/library/svg</outputDirectory>
|
166
|
+
</artifactItem>
|
167
|
+
</artifactItems>
|
168
|
+
</configuration>
|
169
|
+
</execution>
|
170
|
+
</executions>
|
171
|
+
</plugin>
|
133
172
|
<plugin>
|
134
173
|
<artifactId>maven-javadoc-plugin</artifactId>
|
135
174
|
<version>3.2.0</version>
|
data/propane.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.email = ['mamba2928@yahoo.co.uk']
|
12
12
|
gem.licenses = %w[GPL-3.0 LGPL-2.0]
|
13
13
|
gem.description = <<-EOS
|
14
|
-
A batteries included version of processing in ruby targetting jdk11
|
14
|
+
A batteries included version of processing in ruby targetting jdk11+.
|
15
15
|
EOS
|
16
16
|
gem.summary = 'ruby implementation of processing-4.0 on MacOS, linux and windows (64bit only)'
|
17
17
|
gem.homepage = 'https://ruby-processing.github.io/propane/'
|
@@ -27,6 +27,8 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.files << 'lib/jogl-all-natives-macosx-universal.jar'
|
28
28
|
# gem.files << 'lib/jogl-all-natives-ios-arm64.jar'
|
29
29
|
gem.files << 'lib/jogl-all-natives-windows-amd64.jar'
|
30
|
+
gem.files << 'library/pdf/itextpdf-5.5.13.2.jar'
|
31
|
+
gem.files << 'library/svg/batik-all-1.14.jar'
|
30
32
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
31
33
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
32
34
|
gem.add_development_dependency 'jruby-openssl', '~> 0.1.0', '>=0.1.3'
|
@@ -0,0 +1,874 @@
|
|
1
|
+
package monkstone.noise;
|
2
|
+
|
3
|
+
/**
|
4
|
+
* K.jpg's OpenSimplex 2, faster variant
|
5
|
+
*
|
6
|
+
* - 2D is standard simplex implemented using a lookup table. - 3D is
|
7
|
+
* "Re-oriented 4-point BCC noise" which constructs a congruent BCC lattice in a
|
8
|
+
* much different way than usual. - 4D constructs the lattice as a union of five
|
9
|
+
* copies of its reciprocal. It successively finds the closest point on each.
|
10
|
+
*
|
11
|
+
* Multiple versions of each function are provided. See the documentation above
|
12
|
+
* each, for more info.
|
13
|
+
*/
|
14
|
+
public class FastTerrain implements Noise {
|
15
|
+
|
16
|
+
private static final int PSIZE = 2048;
|
17
|
+
private static final int PMASK = 2047;
|
18
|
+
|
19
|
+
private final short[] perm;
|
20
|
+
private final Grad2[] permGrad2;
|
21
|
+
private final Grad3[] permGrad3;
|
22
|
+
private final Grad4[] permGrad4;
|
23
|
+
|
24
|
+
public FastTerrain(long seed) {
|
25
|
+
perm = new short[PSIZE];
|
26
|
+
permGrad2 = new Grad2[PSIZE];
|
27
|
+
permGrad3 = new Grad3[PSIZE];
|
28
|
+
permGrad4 = new Grad4[PSIZE];
|
29
|
+
short[] source = new short[PSIZE];
|
30
|
+
for (short i = 0; i < PSIZE; i++) {
|
31
|
+
source[i] = i;
|
32
|
+
}
|
33
|
+
for (int i = PSIZE - 1; i >= 0; i--) {
|
34
|
+
seed = seed * 6364136223846793005L + 1442695040888963407L;
|
35
|
+
int r = (int) ((seed + 31) % (i + 1));
|
36
|
+
if (r < 0) {
|
37
|
+
r += (i + 1);
|
38
|
+
}
|
39
|
+
perm[i] = source[r];
|
40
|
+
permGrad2[i] = GRADIENTS_2D[perm[i]];
|
41
|
+
permGrad3[i] = GRADIENTS_3D[perm[i]];
|
42
|
+
permGrad4[i] = GRADIENTS_4D[perm[i]];
|
43
|
+
source[r] = source[i];
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
/*
|
48
|
+
* Noise Evaluators
|
49
|
+
*/
|
50
|
+
/**
|
51
|
+
* 2D Simplex noise, standard lattice orientation.
|
52
|
+
*
|
53
|
+
* @param x
|
54
|
+
* @param y
|
55
|
+
* @return
|
56
|
+
*/
|
57
|
+
public double noise2(double x, double y) {
|
58
|
+
|
59
|
+
// Get points for A2* lattice
|
60
|
+
double s = 0.366025403784439 * (x + y);
|
61
|
+
double xs = x + s, ys = y + s;
|
62
|
+
|
63
|
+
return noise2_Base(xs, ys);
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* 2D Simplex noise, with Y pointing down the main diagonal.Might be better
|
68
|
+
* for a 2D sandbox style game, where Y is vertical.Probably slightly less
|
69
|
+
* optimal for heightmaps or continent maps.
|
70
|
+
*
|
71
|
+
* @param x
|
72
|
+
* @param y
|
73
|
+
* @return
|
74
|
+
*/
|
75
|
+
public double noise2_XBeforeY(double x, double y) {
|
76
|
+
|
77
|
+
// Skew transform and rotation baked into one.
|
78
|
+
double xx = x * 0.7071067811865476;
|
79
|
+
double yy = y * 1.224744871380249;
|
80
|
+
|
81
|
+
return noise2_Base(yy + xx, yy - xx);
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* 2D Simplex noise base. Lookup table implementation inspired by
|
86
|
+
* DigitalShadow.
|
87
|
+
*/
|
88
|
+
private double noise2_Base(double xs, double ys) {
|
89
|
+
double value = 0;
|
90
|
+
|
91
|
+
// Get base points and offsets
|
92
|
+
int xsb = fastFloor(xs), ysb = fastFloor(ys);
|
93
|
+
double xsi = xs - xsb, ysi = ys - ysb;
|
94
|
+
|
95
|
+
// Index to point list
|
96
|
+
int index = (int) ((ysi - xsi) / 2 + 1);
|
97
|
+
|
98
|
+
double ssi = (xsi + ysi) * -0.211324865405187;
|
99
|
+
double xi = xsi + ssi, yi = ysi + ssi;
|
100
|
+
|
101
|
+
// Point contributions
|
102
|
+
for (int i = 0; i < 3; i++) {
|
103
|
+
LatticePoint2D c = LOOKUP_2D[index + i];
|
104
|
+
|
105
|
+
double dx = xi + c.dx, dy = yi + c.dy;
|
106
|
+
double attn = 0.5 - dx * dx - dy * dy;
|
107
|
+
if (attn <= 0) {
|
108
|
+
continue;
|
109
|
+
}
|
110
|
+
|
111
|
+
int pxm = (xsb + c.xsv) & PMASK, pym = (ysb + c.ysv) & PMASK;
|
112
|
+
Grad2 grad = permGrad2[perm[pxm] ^ pym];
|
113
|
+
double extrapolation = grad.dx * dx + grad.dy * dy;
|
114
|
+
|
115
|
+
attn *= attn;
|
116
|
+
value += attn * attn * extrapolation;
|
117
|
+
}
|
118
|
+
|
119
|
+
return value;
|
120
|
+
}
|
121
|
+
|
122
|
+
/**
|
123
|
+
* 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X,
|
124
|
+
* Y).Recommended for 3D terrain and time-varied animations.The Z coordinate
|
125
|
+
* should always be the "different" coordinate in your use case.If Y is
|
126
|
+
* vertical in world coordinates, call noise3_XYBeforeZ(x, z, Y) or use
|
127
|
+
* noise3_XZBeforeY.If Z is vertical in world coordinates, call
|
128
|
+
* noise3_XYBeforeZ(x, y, Z). For a time varied animation, call
|
129
|
+
* noise3_XYBeforeZ(x, y, T).
|
130
|
+
*
|
131
|
+
* @param x
|
132
|
+
* @param y
|
133
|
+
* @param z
|
134
|
+
* @return
|
135
|
+
*/
|
136
|
+
public double noise3_XYBeforeZ(double x, double y, double z) {
|
137
|
+
|
138
|
+
// Re-orient the cubic lattices without skewing, to make X and Y triangular like 2D.
|
139
|
+
// Orthonormal rotation. Not a skew transform.
|
140
|
+
double xy = x + y;
|
141
|
+
double s2 = xy * -0.211324865405187;
|
142
|
+
double zz = z * 0.577350269189626;
|
143
|
+
double xr = x + s2 - zz, yr = y + s2 - zz;
|
144
|
+
double zr = xy * 0.577350269189626 + zz;
|
145
|
+
|
146
|
+
// Evaluate both lattices to form a BCC lattice.
|
147
|
+
return noise3_BCC(xr, yr, zr);
|
148
|
+
}
|
149
|
+
|
150
|
+
/**
|
151
|
+
* 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X,
|
152
|
+
* Z).Recommended for 3D terrain and time-varied animations.The Y coordinate
|
153
|
+
* should always be the "different" coordinate in your use case.If Y is
|
154
|
+
* vertical in world coordinates, call noise3_XZBeforeY(x, Y, z).If Z is
|
155
|
+
* vertical in world coordinates, call noise3_XZBeforeY(x, Z, y) or use
|
156
|
+
* noise3_XYBeforeZ. For a time varied animation, call noise3_XZBeforeY(x,
|
157
|
+
* T, y) or use noise3_XYBeforeZ.
|
158
|
+
*
|
159
|
+
* @param x
|
160
|
+
* @param y
|
161
|
+
* @param z
|
162
|
+
* @return
|
163
|
+
*/
|
164
|
+
public double noise3_XZBeforeY(double x, double y, double z) {
|
165
|
+
|
166
|
+
// Re-orient the cubic lattices without skewing, to make X and Z triangular like 2D.
|
167
|
+
// Orthonormal rotation. Not a skew transform.
|
168
|
+
double xz = x + z;
|
169
|
+
double s2 = xz * -0.211324865405187;
|
170
|
+
double yy = y * 0.577350269189626;
|
171
|
+
double xr = x + s2 - yy;
|
172
|
+
double zr = z + s2 - yy;
|
173
|
+
double yr = xz * 0.577350269189626 + yy;
|
174
|
+
|
175
|
+
// Evaluate both lattices to form a BCC lattice.
|
176
|
+
return noise3_BCC(xr, yr, zr);
|
177
|
+
}
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Generate overlapping cubic lattices for 3D Re-oriented BCC noise. Lookup
|
181
|
+
* table implementation inspired by DigitalShadow. It was actually faster to
|
182
|
+
* narrow down the points in the loop itself, than to build up the index
|
183
|
+
* with enough info to isolate 4 points.
|
184
|
+
*/
|
185
|
+
private double noise3_BCC(double xr, double yr, double zr) {
|
186
|
+
|
187
|
+
// Get base and offsets inside cube of first lattice.
|
188
|
+
int xrb = fastFloor(xr), yrb = fastFloor(yr), zrb = fastFloor(zr);
|
189
|
+
double xri = xr - xrb, yri = yr - yrb, zri = zr - zrb;
|
190
|
+
|
191
|
+
// Identify which octant of the cube we're in. This determines which cell
|
192
|
+
// in the other cubic lattice we're in, and also narrows down one point on each.
|
193
|
+
int xht = (int) (xri + 0.5), yht = (int) (yri + 0.5), zht = (int) (zri + 0.5);
|
194
|
+
int index = (xht) | (yht << 1) | (zht << 2);
|
195
|
+
|
196
|
+
// Point contributions
|
197
|
+
double value = 0;
|
198
|
+
LatticePoint3D c = LOOKUP_3D[index];
|
199
|
+
while (c != null) {
|
200
|
+
double dxr = xri + c.dxr, dyr = yri + c.dyr, dzr = zri + c.dzr;
|
201
|
+
double attn = 0.5 - dxr * dxr - dyr * dyr - dzr * dzr;
|
202
|
+
if (attn < 0) {
|
203
|
+
c = c.nextOnFailure;
|
204
|
+
} else {
|
205
|
+
int pxm = (xrb + c.xrv) & PMASK, pym = (yrb + c.yrv) & PMASK, pzm = (zrb + c.zrv) & PMASK;
|
206
|
+
Grad3 grad = permGrad3[perm[perm[pxm] ^ pym] ^ pzm];
|
207
|
+
double extrapolation = grad.dx * dxr + grad.dy * dyr + grad.dz * dzr;
|
208
|
+
|
209
|
+
attn *= attn;
|
210
|
+
value += attn * attn * extrapolation;
|
211
|
+
c = c.nextOnSuccess;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
return value;
|
215
|
+
}
|
216
|
+
|
217
|
+
/**
|
218
|
+
* 4D FastTerrain noise, with XY and ZW forming orthogonal
|
219
|
+
* triangular-based planes.Recommended for 3D terrain, where X and Y (or Z
|
220
|
+
* and W) are horizontal.Recommended for noise(x, y, sin(time), cos(time))
|
221
|
+
* trick.
|
222
|
+
*
|
223
|
+
* @param x
|
224
|
+
* @param y
|
225
|
+
* @param z
|
226
|
+
* @param w
|
227
|
+
* @return
|
228
|
+
*/
|
229
|
+
public double noise4_XYBeforeZW(double x, double y, double z, double w) {
|
230
|
+
|
231
|
+
double s2 = (x + y) * -0.178275657951399372 + (z + w) * 0.215623393288842828;
|
232
|
+
double t2 = (z + w) * -0.403949762580207112 + (x + y) * -0.375199083010075342;
|
233
|
+
double xs = x + s2, ys = y + s2, zs = z + t2, ws = w + t2;
|
234
|
+
|
235
|
+
return noise4_Base(xs, ys, zs, ws);
|
236
|
+
}
|
237
|
+
|
238
|
+
/**
|
239
|
+
* 4D FastTerrain noise, with XYZ oriented like noise3_Classic, and W for
|
240
|
+
* an extra degree of freedom.W repeats eventually.Recommended for
|
241
|
+
* time-varied animations which texture a 3D object (W=time)
|
242
|
+
*
|
243
|
+
* @param x
|
244
|
+
* @param y
|
245
|
+
* @param z
|
246
|
+
* @param w
|
247
|
+
* @return
|
248
|
+
*/
|
249
|
+
public double noise4_XYZBeforeW(double x, double y, double z, double w) {
|
250
|
+
|
251
|
+
double xyz = x + y + z;
|
252
|
+
double ww = w * 0.2236067977499788;
|
253
|
+
double s2 = xyz * -0.16666666666666666 + ww;
|
254
|
+
double xs = x + s2, ys = y + s2, zs = z + s2, ws = -0.5 * xyz + ww;
|
255
|
+
|
256
|
+
return noise4_Base(xs, ys, zs, ws);
|
257
|
+
}
|
258
|
+
|
259
|
+
/**
|
260
|
+
* 4D FastTerrain noise base. Current implementation not fully optimized
|
261
|
+
* by lookup tables. But still comes out slightly ahead of Gustavson's
|
262
|
+
* Simplex in tests.
|
263
|
+
*/
|
264
|
+
private double noise4_Base(double xs, double ys, double zs, double ws) {
|
265
|
+
double value = 0;
|
266
|
+
|
267
|
+
// Get base points and offsets
|
268
|
+
int xsb = fastFloor(xs), ysb = fastFloor(ys), zsb = fastFloor(zs), wsb = fastFloor(ws);
|
269
|
+
double xsi = xs - xsb, ysi = ys - ysb, zsi = zs - zsb, wsi = ws - wsb;
|
270
|
+
|
271
|
+
// If we're in the lower half, flip so we can repeat the code for the upper half. We'll flip back later.
|
272
|
+
double siSum = xsi + ysi + zsi + wsi;
|
273
|
+
double ssi = siSum * 0.309016994374947; // Prep for vertex contributions.
|
274
|
+
boolean inLowerHalf = (siSum < 2);
|
275
|
+
if (inLowerHalf) {
|
276
|
+
xsi = 1 - xsi;
|
277
|
+
ysi = 1 - ysi;
|
278
|
+
zsi = 1 - zsi;
|
279
|
+
wsi = 1 - wsi;
|
280
|
+
siSum = 4 - siSum;
|
281
|
+
}
|
282
|
+
|
283
|
+
// Consider opposing vertex pairs of the octahedron formed by the central cross-section of the stretched tesseract
|
284
|
+
double aabb = xsi + ysi - zsi - wsi, abab = xsi - ysi + zsi - wsi, abba = xsi - ysi - zsi + wsi;
|
285
|
+
double aabbScore = Math.abs(aabb), ababScore = Math.abs(abab), abbaScore = Math.abs(abba);
|
286
|
+
|
287
|
+
// Find the closest point on the stretched tesseract as if it were the upper half
|
288
|
+
int vertexIndex, via, vib;
|
289
|
+
double asi, bsi;
|
290
|
+
if (aabbScore > ababScore && aabbScore > abbaScore) {
|
291
|
+
if (aabb > 0) {
|
292
|
+
asi = zsi;
|
293
|
+
bsi = wsi;
|
294
|
+
vertexIndex = 0b0011;
|
295
|
+
via = 0b0111;
|
296
|
+
vib = 0b1011;
|
297
|
+
} else {
|
298
|
+
asi = xsi;
|
299
|
+
bsi = ysi;
|
300
|
+
vertexIndex = 0b1100;
|
301
|
+
via = 0b1101;
|
302
|
+
vib = 0b1110;
|
303
|
+
}
|
304
|
+
} else if (ababScore > abbaScore) {
|
305
|
+
if (abab > 0) {
|
306
|
+
asi = ysi;
|
307
|
+
bsi = wsi;
|
308
|
+
vertexIndex = 0b0101;
|
309
|
+
via = 0b0111;
|
310
|
+
vib = 0b1101;
|
311
|
+
} else {
|
312
|
+
asi = xsi;
|
313
|
+
bsi = zsi;
|
314
|
+
vertexIndex = 0b1010;
|
315
|
+
via = 0b1011;
|
316
|
+
vib = 0b1110;
|
317
|
+
}
|
318
|
+
} else {
|
319
|
+
if (abba > 0) {
|
320
|
+
asi = ysi;
|
321
|
+
bsi = zsi;
|
322
|
+
vertexIndex = 0b1001;
|
323
|
+
via = 0b1011;
|
324
|
+
vib = 0b1101;
|
325
|
+
} else {
|
326
|
+
asi = xsi;
|
327
|
+
bsi = wsi;
|
328
|
+
vertexIndex = 0b0110;
|
329
|
+
via = 0b0111;
|
330
|
+
vib = 0b1110;
|
331
|
+
}
|
332
|
+
}
|
333
|
+
if (bsi > asi) {
|
334
|
+
via = vib;
|
335
|
+
double temp = bsi;
|
336
|
+
bsi = asi;
|
337
|
+
asi = temp;
|
338
|
+
}
|
339
|
+
if (siSum + asi > 3) {
|
340
|
+
vertexIndex = via;
|
341
|
+
if (siSum + bsi > 4) {
|
342
|
+
vertexIndex = 0b1111;
|
343
|
+
}
|
344
|
+
}
|
345
|
+
|
346
|
+
// Now flip back if we're actually in the lower half.
|
347
|
+
if (inLowerHalf) {
|
348
|
+
xsi = 1 - xsi;
|
349
|
+
ysi = 1 - ysi;
|
350
|
+
zsi = 1 - zsi;
|
351
|
+
wsi = 1 - wsi;
|
352
|
+
vertexIndex ^= 0b1111;
|
353
|
+
}
|
354
|
+
|
355
|
+
// Five points to add, total, from five copies of the A4 lattice.
|
356
|
+
for (int i = 0; i < 5; i++) {
|
357
|
+
|
358
|
+
// Update xsb/etc. and add the lattice point's contribution.
|
359
|
+
LatticePoint4D c = VERTICES_4D[vertexIndex];
|
360
|
+
xsb += c.xsv;
|
361
|
+
ysb += c.ysv;
|
362
|
+
zsb += c.zsv;
|
363
|
+
wsb += c.wsv;
|
364
|
+
double xi = xsi + ssi, yi = ysi + ssi, zi = zsi + ssi, wi = wsi + ssi;
|
365
|
+
double dx = xi + c.dx, dy = yi + c.dy, dz = zi + c.dz, dw = wi + c.dw;
|
366
|
+
double attn = 0.5 - dx * dx - dy * dy - dz * dz - dw * dw;
|
367
|
+
if (attn > 0) {
|
368
|
+
int pxm = xsb & PMASK, pym = ysb & PMASK, pzm = zsb & PMASK, pwm = wsb & PMASK;
|
369
|
+
Grad4 grad = permGrad4[perm[perm[perm[pxm] ^ pym] ^ pzm] ^ pwm];
|
370
|
+
double ramped = grad.dx * dx + grad.dy * dy + grad.dz * dz + grad.dw * dw;
|
371
|
+
|
372
|
+
attn *= attn;
|
373
|
+
value += attn * attn * ramped;
|
374
|
+
}
|
375
|
+
|
376
|
+
// Maybe this helps the compiler/JVM/LLVM/etc. know we can end the loop here. Maybe not.
|
377
|
+
if (i == 4) {
|
378
|
+
break;
|
379
|
+
}
|
380
|
+
|
381
|
+
// Update the relative skewed coordinates to reference the vertex we just added.
|
382
|
+
// Rather, reference its counterpart on the lattice copy that is shifted down by
|
383
|
+
// the vector <-0.2, -0.2, -0.2, -0.2>
|
384
|
+
xsi += c.xsi;
|
385
|
+
ysi += c.ysi;
|
386
|
+
zsi += c.zsi;
|
387
|
+
wsi += c.wsi;
|
388
|
+
ssi += c.ssiDelta;
|
389
|
+
|
390
|
+
// Next point is the closest vertex on the 4-simplex whose base vertex is the aforementioned vertex.
|
391
|
+
double score0 = 1.0 + ssi * (-1.0 / 0.309016994374947); // Seems slightly faster than 1.0-xsi-ysi-zsi-wsi
|
392
|
+
vertexIndex = 0b0000;
|
393
|
+
if (xsi >= ysi && xsi >= zsi && xsi >= wsi && xsi >= score0) {
|
394
|
+
vertexIndex = 0b0001;
|
395
|
+
} else if (ysi > xsi && ysi >= zsi && ysi >= wsi && ysi >= score0) {
|
396
|
+
vertexIndex = 0b0010;
|
397
|
+
} else if (zsi > xsi && zsi > ysi && zsi >= wsi && zsi >= score0) {
|
398
|
+
vertexIndex = 0b0100;
|
399
|
+
} else if (wsi > xsi && wsi > ysi && wsi > zsi && wsi >= score0) {
|
400
|
+
vertexIndex = 0b1000;
|
401
|
+
}
|
402
|
+
}
|
403
|
+
|
404
|
+
return value;
|
405
|
+
}
|
406
|
+
|
407
|
+
/*
|
408
|
+
* Utility
|
409
|
+
*/
|
410
|
+
private static int fastFloor(double x) {
|
411
|
+
int xi = (int) x;
|
412
|
+
return x < xi ? xi - 1 : xi;
|
413
|
+
}
|
414
|
+
|
415
|
+
/*
|
416
|
+
* Definitions
|
417
|
+
*/
|
418
|
+
private static final LatticePoint2D[] LOOKUP_2D;
|
419
|
+
private static final LatticePoint3D[] LOOKUP_3D;
|
420
|
+
private static final LatticePoint4D[] VERTICES_4D;
|
421
|
+
|
422
|
+
static {
|
423
|
+
LOOKUP_2D = new LatticePoint2D[4];
|
424
|
+
LOOKUP_3D = new LatticePoint3D[8];
|
425
|
+
VERTICES_4D = new LatticePoint4D[16];
|
426
|
+
|
427
|
+
LOOKUP_2D[0] = new LatticePoint2D(1, 0);
|
428
|
+
LOOKUP_2D[1] = new LatticePoint2D(0, 0);
|
429
|
+
LOOKUP_2D[2] = new LatticePoint2D(1, 1);
|
430
|
+
LOOKUP_2D[3] = new LatticePoint2D(0, 1);
|
431
|
+
|
432
|
+
for (int i = 0; i < 8; i++) {
|
433
|
+
int i1, j1, k1, i2, j2, k2;
|
434
|
+
i1 = (i) & 1;
|
435
|
+
j1 = (i >> 1) & 1;
|
436
|
+
k1 = (i >> 2) & 1;
|
437
|
+
i2 = i1 ^ 1;
|
438
|
+
j2 = j1 ^ 1;
|
439
|
+
k2 = k1 ^ 1;
|
440
|
+
|
441
|
+
// The two points within this octant, one from each of the two cubic half-lattices.
|
442
|
+
LatticePoint3D c0 = new LatticePoint3D(i1, j1, k1, 0);
|
443
|
+
LatticePoint3D c1 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + k2, 1);
|
444
|
+
|
445
|
+
// Each single step away on the first half-lattice.
|
446
|
+
LatticePoint3D c2 = new LatticePoint3D(i1 ^ 1, j1, k1, 0);
|
447
|
+
LatticePoint3D c3 = new LatticePoint3D(i1, j1 ^ 1, k1, 0);
|
448
|
+
LatticePoint3D c4 = new LatticePoint3D(i1, j1, k1 ^ 1, 0);
|
449
|
+
|
450
|
+
// Each single step away on the second half-lattice.
|
451
|
+
LatticePoint3D c5 = new LatticePoint3D(i1 + (i2 ^ 1), j1 + j2, k1 + k2, 1);
|
452
|
+
LatticePoint3D c6 = new LatticePoint3D(i1 + i2, j1 + (j2 ^ 1), k1 + k2, 1);
|
453
|
+
LatticePoint3D c7 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + (k2 ^ 1), 1);
|
454
|
+
|
455
|
+
// First two are guaranteed.
|
456
|
+
c0.nextOnFailure = c0.nextOnSuccess = c1;
|
457
|
+
c1.nextOnFailure = c1.nextOnSuccess = c2;
|
458
|
+
|
459
|
+
// Once we find one on the first half-lattice, the rest are out.
|
460
|
+
// In addition, knowing c2 rules out c5.
|
461
|
+
c2.nextOnFailure = c3;
|
462
|
+
c2.nextOnSuccess = c6;
|
463
|
+
c3.nextOnFailure = c4;
|
464
|
+
c3.nextOnSuccess = c5;
|
465
|
+
c4.nextOnFailure = c4.nextOnSuccess = c5;
|
466
|
+
|
467
|
+
// Once we find one on the second half-lattice, the rest are out.
|
468
|
+
c5.nextOnFailure = c6;
|
469
|
+
c5.nextOnSuccess = null;
|
470
|
+
c6.nextOnFailure = c7;
|
471
|
+
c6.nextOnSuccess = null;
|
472
|
+
c7.nextOnFailure = c7.nextOnSuccess = null;
|
473
|
+
|
474
|
+
LOOKUP_3D[i] = c0;
|
475
|
+
}
|
476
|
+
|
477
|
+
for (int i = 0; i < 16; i++) {
|
478
|
+
VERTICES_4D[i] = new LatticePoint4D((i) & 1, (i >> 1) & 1, (i >> 2) & 1, (i >> 3) & 1);
|
479
|
+
}
|
480
|
+
}
|
481
|
+
|
482
|
+
@Override
|
483
|
+
public float noise(float x, float y){
|
484
|
+
return (float)noise2_XBeforeY(x, y);
|
485
|
+
}
|
486
|
+
|
487
|
+
@Override
|
488
|
+
public float noise(float x, float y, float z) {
|
489
|
+
return (float)noise3_XYBeforeZ(x, y, z);
|
490
|
+
}
|
491
|
+
|
492
|
+
@Override
|
493
|
+
public float noise(float x, float y, float z, float w) {
|
494
|
+
return (float)noise4_XYBeforeZW(x, y, z, w);
|
495
|
+
}
|
496
|
+
|
497
|
+
@Override
|
498
|
+
public void noiseMode(NoiseMode mode) {
|
499
|
+
|
500
|
+
}
|
501
|
+
|
502
|
+
@Override
|
503
|
+
public void noiseSeed(long seed) {
|
504
|
+
}
|
505
|
+
|
506
|
+
private static class LatticePoint2D {
|
507
|
+
|
508
|
+
int xsv, ysv;
|
509
|
+
double dx, dy;
|
510
|
+
|
511
|
+
public LatticePoint2D(int xsv, int ysv) {
|
512
|
+
this.xsv = xsv;
|
513
|
+
this.ysv = ysv;
|
514
|
+
double ssv = (xsv + ysv) * -0.211324865405187;
|
515
|
+
this.dx = -xsv - ssv;
|
516
|
+
this.dy = -ysv - ssv;
|
517
|
+
}
|
518
|
+
}
|
519
|
+
|
520
|
+
private static class LatticePoint3D {
|
521
|
+
|
522
|
+
public double dxr, dyr, dzr;
|
523
|
+
public int xrv, yrv, zrv;
|
524
|
+
LatticePoint3D nextOnFailure, nextOnSuccess;
|
525
|
+
|
526
|
+
public LatticePoint3D(int xrv, int yrv, int zrv, int lattice) {
|
527
|
+
this.dxr = -xrv + lattice * 0.5;
|
528
|
+
this.dyr = -yrv + lattice * 0.5;
|
529
|
+
this.dzr = -zrv + lattice * 0.5;
|
530
|
+
this.xrv = xrv + lattice * 1024;
|
531
|
+
this.yrv = yrv + lattice * 1024;
|
532
|
+
this.zrv = zrv + lattice * 1024;
|
533
|
+
}
|
534
|
+
}
|
535
|
+
|
536
|
+
private static class LatticePoint4D {
|
537
|
+
|
538
|
+
int xsv, ysv, zsv, wsv;
|
539
|
+
double dx, dy, dz, dw;
|
540
|
+
double xsi, ysi, zsi, wsi;
|
541
|
+
double ssiDelta;
|
542
|
+
|
543
|
+
public LatticePoint4D(int xsv, int ysv, int zsv, int wsv) {
|
544
|
+
this.xsv = xsv + 409;
|
545
|
+
this.ysv = ysv + 409;
|
546
|
+
this.zsv = zsv + 409;
|
547
|
+
this.wsv = wsv + 409;
|
548
|
+
double ssv = (xsv + ysv + zsv + wsv) * 0.309016994374947;
|
549
|
+
this.dx = -xsv - ssv;
|
550
|
+
this.dy = -ysv - ssv;
|
551
|
+
this.dz = -zsv - ssv;
|
552
|
+
this.dw = -wsv - ssv;
|
553
|
+
this.xsi = xsi = 0.2 - xsv;
|
554
|
+
this.ysi = ysi = 0.2 - ysv;
|
555
|
+
this.zsi = zsi = 0.2 - zsv;
|
556
|
+
this.wsi = wsi = 0.2 - wsv;
|
557
|
+
this.ssiDelta = (0.8 - xsv - ysv - zsv - wsv) * 0.309016994374947;
|
558
|
+
}
|
559
|
+
}
|
560
|
+
|
561
|
+
/*
|
562
|
+
* Gradients
|
563
|
+
*/
|
564
|
+
private static class Grad2 {
|
565
|
+
|
566
|
+
double dx, dy;
|
567
|
+
|
568
|
+
public Grad2(double dx, double dy) {
|
569
|
+
this.dx = dx;
|
570
|
+
this.dy = dy;
|
571
|
+
}
|
572
|
+
}
|
573
|
+
|
574
|
+
private static class Grad3 {
|
575
|
+
|
576
|
+
double dx, dy, dz;
|
577
|
+
|
578
|
+
public Grad3(double dx, double dy, double dz) {
|
579
|
+
this.dx = dx;
|
580
|
+
this.dy = dy;
|
581
|
+
this.dz = dz;
|
582
|
+
}
|
583
|
+
}
|
584
|
+
|
585
|
+
private static class Grad4 {
|
586
|
+
|
587
|
+
double dx, dy, dz, dw;
|
588
|
+
|
589
|
+
public Grad4(double dx, double dy, double dz, double dw) {
|
590
|
+
this.dx = dx;
|
591
|
+
this.dy = dy;
|
592
|
+
this.dz = dz;
|
593
|
+
this.dw = dw;
|
594
|
+
}
|
595
|
+
}
|
596
|
+
|
597
|
+
private static final double N2 = 0.01001634121365712;
|
598
|
+
private static final double N3 = 0.030485933181293584;
|
599
|
+
private static final double N4 = 0.009202377986303158;
|
600
|
+
private static final Grad2[] GRADIENTS_2D;
|
601
|
+
private static final Grad3[] GRADIENTS_3D;
|
602
|
+
private static final Grad4[] GRADIENTS_4D;
|
603
|
+
|
604
|
+
static {
|
605
|
+
|
606
|
+
GRADIENTS_2D = new Grad2[PSIZE];
|
607
|
+
Grad2[] grad2 = {
|
608
|
+
new Grad2(0.130526192220052, 0.99144486137381),
|
609
|
+
new Grad2(0.38268343236509, 0.923879532511287),
|
610
|
+
new Grad2(0.608761429008721, 0.793353340291235),
|
611
|
+
new Grad2(0.793353340291235, 0.608761429008721),
|
612
|
+
new Grad2(0.923879532511287, 0.38268343236509),
|
613
|
+
new Grad2(0.99144486137381, 0.130526192220051),
|
614
|
+
new Grad2(0.99144486137381, -0.130526192220051),
|
615
|
+
new Grad2(0.923879532511287, -0.38268343236509),
|
616
|
+
new Grad2(0.793353340291235, -0.60876142900872),
|
617
|
+
new Grad2(0.608761429008721, -0.793353340291235),
|
618
|
+
new Grad2(0.38268343236509, -0.923879532511287),
|
619
|
+
new Grad2(0.130526192220052, -0.99144486137381),
|
620
|
+
new Grad2(-0.130526192220052, -0.99144486137381),
|
621
|
+
new Grad2(-0.38268343236509, -0.923879532511287),
|
622
|
+
new Grad2(-0.608761429008721, -0.793353340291235),
|
623
|
+
new Grad2(-0.793353340291235, -0.608761429008721),
|
624
|
+
new Grad2(-0.923879532511287, -0.38268343236509),
|
625
|
+
new Grad2(-0.99144486137381, -0.130526192220052),
|
626
|
+
new Grad2(-0.99144486137381, 0.130526192220051),
|
627
|
+
new Grad2(-0.923879532511287, 0.38268343236509),
|
628
|
+
new Grad2(-0.793353340291235, 0.608761429008721),
|
629
|
+
new Grad2(-0.608761429008721, 0.793353340291235),
|
630
|
+
new Grad2(-0.38268343236509, 0.923879532511287),
|
631
|
+
new Grad2(-0.130526192220052, 0.99144486137381)
|
632
|
+
};
|
633
|
+
for (Grad2 grad21 : grad2) {
|
634
|
+
grad21.dx /= N2;
|
635
|
+
grad21.dy /= N2;
|
636
|
+
}
|
637
|
+
for (int i = 0; i < PSIZE; i++) {
|
638
|
+
GRADIENTS_2D[i] = grad2[i % grad2.length];
|
639
|
+
}
|
640
|
+
|
641
|
+
GRADIENTS_3D = new Grad3[PSIZE];
|
642
|
+
Grad3[] grad3 = {
|
643
|
+
new Grad3(-2.22474487139, -2.22474487139, -1.0),
|
644
|
+
new Grad3(-2.22474487139, -2.22474487139, 1.0),
|
645
|
+
new Grad3(-3.0862664687972017, -1.1721513422464978, 0.0),
|
646
|
+
new Grad3(-1.1721513422464978, -3.0862664687972017, 0.0),
|
647
|
+
new Grad3(-2.22474487139, -1.0, -2.22474487139),
|
648
|
+
new Grad3(-2.22474487139, 1.0, -2.22474487139),
|
649
|
+
new Grad3(-1.1721513422464978, 0.0, -3.0862664687972017),
|
650
|
+
new Grad3(-3.0862664687972017, 0.0, -1.1721513422464978),
|
651
|
+
new Grad3(-2.22474487139, -1.0, 2.22474487139),
|
652
|
+
new Grad3(-2.22474487139, 1.0, 2.22474487139),
|
653
|
+
new Grad3(-3.0862664687972017, 0.0, 1.1721513422464978),
|
654
|
+
new Grad3(-1.1721513422464978, 0.0, 3.0862664687972017),
|
655
|
+
new Grad3(-2.22474487139, 2.22474487139, -1.0),
|
656
|
+
new Grad3(-2.22474487139, 2.22474487139, 1.0),
|
657
|
+
new Grad3(-1.1721513422464978, 3.0862664687972017, 0.0),
|
658
|
+
new Grad3(-3.0862664687972017, 1.1721513422464978, 0.0),
|
659
|
+
new Grad3(-1.0, -2.22474487139, -2.22474487139),
|
660
|
+
new Grad3(1.0, -2.22474487139, -2.22474487139),
|
661
|
+
new Grad3(0.0, -3.0862664687972017, -1.1721513422464978),
|
662
|
+
new Grad3(0.0, -1.1721513422464978, -3.0862664687972017),
|
663
|
+
new Grad3(-1.0, -2.22474487139, 2.22474487139),
|
664
|
+
new Grad3(1.0, -2.22474487139, 2.22474487139),
|
665
|
+
new Grad3(0.0, -1.1721513422464978, 3.0862664687972017),
|
666
|
+
new Grad3(0.0, -3.0862664687972017, 1.1721513422464978),
|
667
|
+
new Grad3(-1.0, 2.22474487139, -2.22474487139),
|
668
|
+
new Grad3(1.0, 2.22474487139, -2.22474487139),
|
669
|
+
new Grad3(0.0, 1.1721513422464978, -3.0862664687972017),
|
670
|
+
new Grad3(0.0, 3.0862664687972017, -1.1721513422464978),
|
671
|
+
new Grad3(-1.0, 2.22474487139, 2.22474487139),
|
672
|
+
new Grad3(1.0, 2.22474487139, 2.22474487139),
|
673
|
+
new Grad3(0.0, 3.0862664687972017, 1.1721513422464978),
|
674
|
+
new Grad3(0.0, 1.1721513422464978, 3.0862664687972017),
|
675
|
+
new Grad3(2.22474487139, -2.22474487139, -1.0),
|
676
|
+
new Grad3(2.22474487139, -2.22474487139, 1.0),
|
677
|
+
new Grad3(1.1721513422464978, -3.0862664687972017, 0.0),
|
678
|
+
new Grad3(3.0862664687972017, -1.1721513422464978, 0.0),
|
679
|
+
new Grad3(2.22474487139, -1.0, -2.22474487139),
|
680
|
+
new Grad3(2.22474487139, 1.0, -2.22474487139),
|
681
|
+
new Grad3(3.0862664687972017, 0.0, -1.1721513422464978),
|
682
|
+
new Grad3(1.1721513422464978, 0.0, -3.0862664687972017),
|
683
|
+
new Grad3(2.22474487139, -1.0, 2.22474487139),
|
684
|
+
new Grad3(2.22474487139, 1.0, 2.22474487139),
|
685
|
+
new Grad3(1.1721513422464978, 0.0, 3.0862664687972017),
|
686
|
+
new Grad3(3.0862664687972017, 0.0, 1.1721513422464978),
|
687
|
+
new Grad3(2.22474487139, 2.22474487139, -1.0),
|
688
|
+
new Grad3(2.22474487139, 2.22474487139, 1.0),
|
689
|
+
new Grad3(3.0862664687972017, 1.1721513422464978, 0.0),
|
690
|
+
new Grad3(1.1721513422464978, 3.0862664687972017, 0.0)
|
691
|
+
};
|
692
|
+
for (Grad3 grad31 : grad3) {
|
693
|
+
grad31.dx /= N3;
|
694
|
+
grad31.dy /= N3;
|
695
|
+
grad31.dz /= N3;
|
696
|
+
}
|
697
|
+
for (int i = 0; i < PSIZE; i++) {
|
698
|
+
GRADIENTS_3D[i] = grad3[i % grad3.length];
|
699
|
+
}
|
700
|
+
|
701
|
+
GRADIENTS_4D = new Grad4[PSIZE];
|
702
|
+
Grad4[] grad4 = {
|
703
|
+
new Grad4(-0.753341017856078, -0.37968289875261624, -0.37968289875261624, -0.37968289875261624),
|
704
|
+
new Grad4(-0.7821684431180708, -0.4321472685365301, -0.4321472685365301, 0.12128480194602098),
|
705
|
+
new Grad4(-0.7821684431180708, -0.4321472685365301, 0.12128480194602098, -0.4321472685365301),
|
706
|
+
new Grad4(-0.7821684431180708, 0.12128480194602098, -0.4321472685365301, -0.4321472685365301),
|
707
|
+
new Grad4(-0.8586508742123365, -0.508629699630796, 0.044802370851755174, 0.044802370851755174),
|
708
|
+
new Grad4(-0.8586508742123365, 0.044802370851755174, -0.508629699630796, 0.044802370851755174),
|
709
|
+
new Grad4(-0.8586508742123365, 0.044802370851755174, 0.044802370851755174, -0.508629699630796),
|
710
|
+
new Grad4(-0.9982828964265062, -0.03381941603233842, -0.03381941603233842, -0.03381941603233842),
|
711
|
+
new Grad4(-0.37968289875261624, -0.753341017856078, -0.37968289875261624, -0.37968289875261624),
|
712
|
+
new Grad4(-0.4321472685365301, -0.7821684431180708, -0.4321472685365301, 0.12128480194602098),
|
713
|
+
new Grad4(-0.4321472685365301, -0.7821684431180708, 0.12128480194602098, -0.4321472685365301),
|
714
|
+
new Grad4(0.12128480194602098, -0.7821684431180708, -0.4321472685365301, -0.4321472685365301),
|
715
|
+
new Grad4(-0.508629699630796, -0.8586508742123365, 0.044802370851755174, 0.044802370851755174),
|
716
|
+
new Grad4(0.044802370851755174, -0.8586508742123365, -0.508629699630796, 0.044802370851755174),
|
717
|
+
new Grad4(0.044802370851755174, -0.8586508742123365, 0.044802370851755174, -0.508629699630796),
|
718
|
+
new Grad4(-0.03381941603233842, -0.9982828964265062, -0.03381941603233842, -0.03381941603233842),
|
719
|
+
new Grad4(-0.37968289875261624, -0.37968289875261624, -0.753341017856078, -0.37968289875261624),
|
720
|
+
new Grad4(-0.4321472685365301, -0.4321472685365301, -0.7821684431180708, 0.12128480194602098),
|
721
|
+
new Grad4(-0.4321472685365301, 0.12128480194602098, -0.7821684431180708, -0.4321472685365301),
|
722
|
+
new Grad4(0.12128480194602098, -0.4321472685365301, -0.7821684431180708, -0.4321472685365301),
|
723
|
+
new Grad4(-0.508629699630796, 0.044802370851755174, -0.8586508742123365, 0.044802370851755174),
|
724
|
+
new Grad4(0.044802370851755174, -0.508629699630796, -0.8586508742123365, 0.044802370851755174),
|
725
|
+
new Grad4(0.044802370851755174, 0.044802370851755174, -0.8586508742123365, -0.508629699630796),
|
726
|
+
new Grad4(-0.03381941603233842, -0.03381941603233842, -0.9982828964265062, -0.03381941603233842),
|
727
|
+
new Grad4(-0.37968289875261624, -0.37968289875261624, -0.37968289875261624, -0.753341017856078),
|
728
|
+
new Grad4(-0.4321472685365301, -0.4321472685365301, 0.12128480194602098, -0.7821684431180708),
|
729
|
+
new Grad4(-0.4321472685365301, 0.12128480194602098, -0.4321472685365301, -0.7821684431180708),
|
730
|
+
new Grad4(0.12128480194602098, -0.4321472685365301, -0.4321472685365301, -0.7821684431180708),
|
731
|
+
new Grad4(-0.508629699630796, 0.044802370851755174, 0.044802370851755174, -0.8586508742123365),
|
732
|
+
new Grad4(0.044802370851755174, -0.508629699630796, 0.044802370851755174, -0.8586508742123365),
|
733
|
+
new Grad4(0.044802370851755174, 0.044802370851755174, -0.508629699630796, -0.8586508742123365),
|
734
|
+
new Grad4(-0.03381941603233842, -0.03381941603233842, -0.03381941603233842, -0.9982828964265062),
|
735
|
+
new Grad4(-0.6740059517812944, -0.3239847771997537, -0.3239847771997537, 0.5794684678643381),
|
736
|
+
new Grad4(-0.7504883828755602, -0.4004672082940195, 0.15296486218853164, 0.5029860367700724),
|
737
|
+
new Grad4(-0.7504883828755602, 0.15296486218853164, -0.4004672082940195, 0.5029860367700724),
|
738
|
+
new Grad4(-0.8828161875373585, 0.08164729285680945, 0.08164729285680945, 0.4553054119602712),
|
739
|
+
new Grad4(-0.4553054119602712, -0.08164729285680945, -0.08164729285680945, 0.8828161875373585),
|
740
|
+
new Grad4(-0.5029860367700724, -0.15296486218853164, 0.4004672082940195, 0.7504883828755602),
|
741
|
+
new Grad4(-0.5029860367700724, 0.4004672082940195, -0.15296486218853164, 0.7504883828755602),
|
742
|
+
new Grad4(-0.5794684678643381, 0.3239847771997537, 0.3239847771997537, 0.6740059517812944),
|
743
|
+
new Grad4(-0.3239847771997537, -0.6740059517812944, -0.3239847771997537, 0.5794684678643381),
|
744
|
+
new Grad4(-0.4004672082940195, -0.7504883828755602, 0.15296486218853164, 0.5029860367700724),
|
745
|
+
new Grad4(0.15296486218853164, -0.7504883828755602, -0.4004672082940195, 0.5029860367700724),
|
746
|
+
new Grad4(0.08164729285680945, -0.8828161875373585, 0.08164729285680945, 0.4553054119602712),
|
747
|
+
new Grad4(-0.08164729285680945, -0.4553054119602712, -0.08164729285680945, 0.8828161875373585),
|
748
|
+
new Grad4(-0.15296486218853164, -0.5029860367700724, 0.4004672082940195, 0.7504883828755602),
|
749
|
+
new Grad4(0.4004672082940195, -0.5029860367700724, -0.15296486218853164, 0.7504883828755602),
|
750
|
+
new Grad4(0.3239847771997537, -0.5794684678643381, 0.3239847771997537, 0.6740059517812944),
|
751
|
+
new Grad4(-0.3239847771997537, -0.3239847771997537, -0.6740059517812944, 0.5794684678643381),
|
752
|
+
new Grad4(-0.4004672082940195, 0.15296486218853164, -0.7504883828755602, 0.5029860367700724),
|
753
|
+
new Grad4(0.15296486218853164, -0.4004672082940195, -0.7504883828755602, 0.5029860367700724),
|
754
|
+
new Grad4(0.08164729285680945, 0.08164729285680945, -0.8828161875373585, 0.4553054119602712),
|
755
|
+
new Grad4(-0.08164729285680945, -0.08164729285680945, -0.4553054119602712, 0.8828161875373585),
|
756
|
+
new Grad4(-0.15296486218853164, 0.4004672082940195, -0.5029860367700724, 0.7504883828755602),
|
757
|
+
new Grad4(0.4004672082940195, -0.15296486218853164, -0.5029860367700724, 0.7504883828755602),
|
758
|
+
new Grad4(0.3239847771997537, 0.3239847771997537, -0.5794684678643381, 0.6740059517812944),
|
759
|
+
new Grad4(-0.6740059517812944, -0.3239847771997537, 0.5794684678643381, -0.3239847771997537),
|
760
|
+
new Grad4(-0.7504883828755602, -0.4004672082940195, 0.5029860367700724, 0.15296486218853164),
|
761
|
+
new Grad4(-0.7504883828755602, 0.15296486218853164, 0.5029860367700724, -0.4004672082940195),
|
762
|
+
new Grad4(-0.8828161875373585, 0.08164729285680945, 0.4553054119602712, 0.08164729285680945),
|
763
|
+
new Grad4(-0.4553054119602712, -0.08164729285680945, 0.8828161875373585, -0.08164729285680945),
|
764
|
+
new Grad4(-0.5029860367700724, -0.15296486218853164, 0.7504883828755602, 0.4004672082940195),
|
765
|
+
new Grad4(-0.5029860367700724, 0.4004672082940195, 0.7504883828755602, -0.15296486218853164),
|
766
|
+
new Grad4(-0.5794684678643381, 0.3239847771997537, 0.6740059517812944, 0.3239847771997537),
|
767
|
+
new Grad4(-0.3239847771997537, -0.6740059517812944, 0.5794684678643381, -0.3239847771997537),
|
768
|
+
new Grad4(-0.4004672082940195, -0.7504883828755602, 0.5029860367700724, 0.15296486218853164),
|
769
|
+
new Grad4(0.15296486218853164, -0.7504883828755602, 0.5029860367700724, -0.4004672082940195),
|
770
|
+
new Grad4(0.08164729285680945, -0.8828161875373585, 0.4553054119602712, 0.08164729285680945),
|
771
|
+
new Grad4(-0.08164729285680945, -0.4553054119602712, 0.8828161875373585, -0.08164729285680945),
|
772
|
+
new Grad4(-0.15296486218853164, -0.5029860367700724, 0.7504883828755602, 0.4004672082940195),
|
773
|
+
new Grad4(0.4004672082940195, -0.5029860367700724, 0.7504883828755602, -0.15296486218853164),
|
774
|
+
new Grad4(0.3239847771997537, -0.5794684678643381, 0.6740059517812944, 0.3239847771997537),
|
775
|
+
new Grad4(-0.3239847771997537, -0.3239847771997537, 0.5794684678643381, -0.6740059517812944),
|
776
|
+
new Grad4(-0.4004672082940195, 0.15296486218853164, 0.5029860367700724, -0.7504883828755602),
|
777
|
+
new Grad4(0.15296486218853164, -0.4004672082940195, 0.5029860367700724, -0.7504883828755602),
|
778
|
+
new Grad4(0.08164729285680945, 0.08164729285680945, 0.4553054119602712, -0.8828161875373585),
|
779
|
+
new Grad4(-0.08164729285680945, -0.08164729285680945, 0.8828161875373585, -0.4553054119602712),
|
780
|
+
new Grad4(-0.15296486218853164, 0.4004672082940195, 0.7504883828755602, -0.5029860367700724),
|
781
|
+
new Grad4(0.4004672082940195, -0.15296486218853164, 0.7504883828755602, -0.5029860367700724),
|
782
|
+
new Grad4(0.3239847771997537, 0.3239847771997537, 0.6740059517812944, -0.5794684678643381),
|
783
|
+
new Grad4(-0.6740059517812944, 0.5794684678643381, -0.3239847771997537, -0.3239847771997537),
|
784
|
+
new Grad4(-0.7504883828755602, 0.5029860367700724, -0.4004672082940195, 0.15296486218853164),
|
785
|
+
new Grad4(-0.7504883828755602, 0.5029860367700724, 0.15296486218853164, -0.4004672082940195),
|
786
|
+
new Grad4(-0.8828161875373585, 0.4553054119602712, 0.08164729285680945, 0.08164729285680945),
|
787
|
+
new Grad4(-0.4553054119602712, 0.8828161875373585, -0.08164729285680945, -0.08164729285680945),
|
788
|
+
new Grad4(-0.5029860367700724, 0.7504883828755602, -0.15296486218853164, 0.4004672082940195),
|
789
|
+
new Grad4(-0.5029860367700724, 0.7504883828755602, 0.4004672082940195, -0.15296486218853164),
|
790
|
+
new Grad4(-0.5794684678643381, 0.6740059517812944, 0.3239847771997537, 0.3239847771997537),
|
791
|
+
new Grad4(-0.3239847771997537, 0.5794684678643381, -0.6740059517812944, -0.3239847771997537),
|
792
|
+
new Grad4(-0.4004672082940195, 0.5029860367700724, -0.7504883828755602, 0.15296486218853164),
|
793
|
+
new Grad4(0.15296486218853164, 0.5029860367700724, -0.7504883828755602, -0.4004672082940195),
|
794
|
+
new Grad4(0.08164729285680945, 0.4553054119602712, -0.8828161875373585, 0.08164729285680945),
|
795
|
+
new Grad4(-0.08164729285680945, 0.8828161875373585, -0.4553054119602712, -0.08164729285680945),
|
796
|
+
new Grad4(-0.15296486218853164, 0.7504883828755602, -0.5029860367700724, 0.4004672082940195),
|
797
|
+
new Grad4(0.4004672082940195, 0.7504883828755602, -0.5029860367700724, -0.15296486218853164),
|
798
|
+
new Grad4(0.3239847771997537, 0.6740059517812944, -0.5794684678643381, 0.3239847771997537),
|
799
|
+
new Grad4(-0.3239847771997537, 0.5794684678643381, -0.3239847771997537, -0.6740059517812944),
|
800
|
+
new Grad4(-0.4004672082940195, 0.5029860367700724, 0.15296486218853164, -0.7504883828755602),
|
801
|
+
new Grad4(0.15296486218853164, 0.5029860367700724, -0.4004672082940195, -0.7504883828755602),
|
802
|
+
new Grad4(0.08164729285680945, 0.4553054119602712, 0.08164729285680945, -0.8828161875373585),
|
803
|
+
new Grad4(-0.08164729285680945, 0.8828161875373585, -0.08164729285680945, -0.4553054119602712),
|
804
|
+
new Grad4(-0.15296486218853164, 0.7504883828755602, 0.4004672082940195, -0.5029860367700724),
|
805
|
+
new Grad4(0.4004672082940195, 0.7504883828755602, -0.15296486218853164, -0.5029860367700724),
|
806
|
+
new Grad4(0.3239847771997537, 0.6740059517812944, 0.3239847771997537, -0.5794684678643381),
|
807
|
+
new Grad4(0.5794684678643381, -0.6740059517812944, -0.3239847771997537, -0.3239847771997537),
|
808
|
+
new Grad4(0.5029860367700724, -0.7504883828755602, -0.4004672082940195, 0.15296486218853164),
|
809
|
+
new Grad4(0.5029860367700724, -0.7504883828755602, 0.15296486218853164, -0.4004672082940195),
|
810
|
+
new Grad4(0.4553054119602712, -0.8828161875373585, 0.08164729285680945, 0.08164729285680945),
|
811
|
+
new Grad4(0.8828161875373585, -0.4553054119602712, -0.08164729285680945, -0.08164729285680945),
|
812
|
+
new Grad4(0.7504883828755602, -0.5029860367700724, -0.15296486218853164, 0.4004672082940195),
|
813
|
+
new Grad4(0.7504883828755602, -0.5029860367700724, 0.4004672082940195, -0.15296486218853164),
|
814
|
+
new Grad4(0.6740059517812944, -0.5794684678643381, 0.3239847771997537, 0.3239847771997537),
|
815
|
+
new Grad4(0.5794684678643381, -0.3239847771997537, -0.6740059517812944, -0.3239847771997537),
|
816
|
+
new Grad4(0.5029860367700724, -0.4004672082940195, -0.7504883828755602, 0.15296486218853164),
|
817
|
+
new Grad4(0.5029860367700724, 0.15296486218853164, -0.7504883828755602, -0.4004672082940195),
|
818
|
+
new Grad4(0.4553054119602712, 0.08164729285680945, -0.8828161875373585, 0.08164729285680945),
|
819
|
+
new Grad4(0.8828161875373585, -0.08164729285680945, -0.4553054119602712, -0.08164729285680945),
|
820
|
+
new Grad4(0.7504883828755602, -0.15296486218853164, -0.5029860367700724, 0.4004672082940195),
|
821
|
+
new Grad4(0.7504883828755602, 0.4004672082940195, -0.5029860367700724, -0.15296486218853164),
|
822
|
+
new Grad4(0.6740059517812944, 0.3239847771997537, -0.5794684678643381, 0.3239847771997537),
|
823
|
+
new Grad4(0.5794684678643381, -0.3239847771997537, -0.3239847771997537, -0.6740059517812944),
|
824
|
+
new Grad4(0.5029860367700724, -0.4004672082940195, 0.15296486218853164, -0.7504883828755602),
|
825
|
+
new Grad4(0.5029860367700724, 0.15296486218853164, -0.4004672082940195, -0.7504883828755602),
|
826
|
+
new Grad4(0.4553054119602712, 0.08164729285680945, 0.08164729285680945, -0.8828161875373585),
|
827
|
+
new Grad4(0.8828161875373585, -0.08164729285680945, -0.08164729285680945, -0.4553054119602712),
|
828
|
+
new Grad4(0.7504883828755602, -0.15296486218853164, 0.4004672082940195, -0.5029860367700724),
|
829
|
+
new Grad4(0.7504883828755602, 0.4004672082940195, -0.15296486218853164, -0.5029860367700724),
|
830
|
+
new Grad4(0.6740059517812944, 0.3239847771997537, 0.3239847771997537, -0.5794684678643381),
|
831
|
+
new Grad4(0.03381941603233842, 0.03381941603233842, 0.03381941603233842, 0.9982828964265062),
|
832
|
+
new Grad4(-0.044802370851755174, -0.044802370851755174, 0.508629699630796, 0.8586508742123365),
|
833
|
+
new Grad4(-0.044802370851755174, 0.508629699630796, -0.044802370851755174, 0.8586508742123365),
|
834
|
+
new Grad4(-0.12128480194602098, 0.4321472685365301, 0.4321472685365301, 0.7821684431180708),
|
835
|
+
new Grad4(0.508629699630796, -0.044802370851755174, -0.044802370851755174, 0.8586508742123365),
|
836
|
+
new Grad4(0.4321472685365301, -0.12128480194602098, 0.4321472685365301, 0.7821684431180708),
|
837
|
+
new Grad4(0.4321472685365301, 0.4321472685365301, -0.12128480194602098, 0.7821684431180708),
|
838
|
+
new Grad4(0.37968289875261624, 0.37968289875261624, 0.37968289875261624, 0.753341017856078),
|
839
|
+
new Grad4(0.03381941603233842, 0.03381941603233842, 0.9982828964265062, 0.03381941603233842),
|
840
|
+
new Grad4(-0.044802370851755174, 0.044802370851755174, 0.8586508742123365, 0.508629699630796),
|
841
|
+
new Grad4(-0.044802370851755174, 0.508629699630796, 0.8586508742123365, -0.044802370851755174),
|
842
|
+
new Grad4(-0.12128480194602098, 0.4321472685365301, 0.7821684431180708, 0.4321472685365301),
|
843
|
+
new Grad4(0.508629699630796, -0.044802370851755174, 0.8586508742123365, -0.044802370851755174),
|
844
|
+
new Grad4(0.4321472685365301, -0.12128480194602098, 0.7821684431180708, 0.4321472685365301),
|
845
|
+
new Grad4(0.4321472685365301, 0.4321472685365301, 0.7821684431180708, -0.12128480194602098),
|
846
|
+
new Grad4(0.37968289875261624, 0.37968289875261624, 0.753341017856078, 0.37968289875261624),
|
847
|
+
new Grad4(0.03381941603233842, 0.9982828964265062, 0.03381941603233842, 0.03381941603233842),
|
848
|
+
new Grad4(-0.044802370851755174, 0.8586508742123365, -0.044802370851755174, 0.508629699630796),
|
849
|
+
new Grad4(-0.044802370851755174, 0.8586508742123365, 0.508629699630796, -0.044802370851755174),
|
850
|
+
new Grad4(-0.12128480194602098, 0.7821684431180708, 0.4321472685365301, 0.4321472685365301),
|
851
|
+
new Grad4(0.508629699630796, 0.8586508742123365, -0.044802370851755174, -0.044802370851755174),
|
852
|
+
new Grad4(0.4321472685365301, 0.7821684431180708, -0.12128480194602098, 0.4321472685365301),
|
853
|
+
new Grad4(0.4321472685365301, 0.7821684431180708, 0.4321472685365301, -0.12128480194602098),
|
854
|
+
new Grad4(0.37968289875261624, 0.753341017856078, 0.37968289875261624, 0.37968289875261624),
|
855
|
+
new Grad4(0.9982828964265062, 0.03381941603233842, 0.03381941603233842, 0.03381941603233842),
|
856
|
+
new Grad4(0.8586508742123365, -0.044802370851755174, -0.044802370851755174, 0.508629699630796),
|
857
|
+
new Grad4(0.8586508742123365, -0.044802370851755174, 0.508629699630796, -0.044802370851755174),
|
858
|
+
new Grad4(0.7821684431180708, -0.12128480194602098, 0.4321472685365301, 0.4321472685365301),
|
859
|
+
new Grad4(0.8586508742123365, 0.508629699630796, -0.044802370851755174, -0.044802370851755174),
|
860
|
+
new Grad4(0.7821684431180708, 0.4321472685365301, -0.12128480194602098, 0.4321472685365301),
|
861
|
+
new Grad4(0.7821684431180708, 0.4321472685365301, 0.4321472685365301, -0.12128480194602098),
|
862
|
+
new Grad4(0.753341017856078, 0.37968289875261624, 0.37968289875261624, 0.37968289875261624)
|
863
|
+
};
|
864
|
+
for (Grad4 grad41 : grad4) {
|
865
|
+
grad41.dx /= N4;
|
866
|
+
grad41.dy /= N4;
|
867
|
+
grad41.dz /= N4;
|
868
|
+
grad41.dw /= N4;
|
869
|
+
}
|
870
|
+
for (int i = 0; i < PSIZE; i++) {
|
871
|
+
GRADIENTS_4D[i] = grad4[i % grad4.length];
|
872
|
+
}
|
873
|
+
}
|
874
|
+
}
|