@ -28,7 +28,6 @@
* * * * * * END GPL LICENSE BLOCK * * * * *
* * * * * * END GPL LICENSE BLOCK * * * * *
*
*
* /
* /
package com.jme3.scene.plugins.blender.helpers.v249 ;
package com.jme3.scene.plugins.blender.helpers.v249 ;
import java.io.IOException ;
import java.io.IOException ;
@ -56,6 +55,7 @@ import com.jme3.scene.plugins.blender.utils.DataRepository;
* @author Marcin Roguski ( Kaelthas )
* @author Marcin Roguski ( Kaelthas )
* /
* /
public class NoiseHelper extends AbstractBlenderHelper {
public class NoiseHelper extends AbstractBlenderHelper {
private static final Logger LOGGER = Logger . getLogger ( NoiseHelper . class . getName ( ) ) ;
private static final Logger LOGGER = Logger . getLogger ( NoiseHelper . class . getName ( ) ) ;
/* return value */
/* return value */
@ -170,11 +170,12 @@ public class NoiseHelper extends AbstractBlenderHelper {
}
}
}
}
}
}
protected static Map < Integer , AbstractNoiseFunc > noiseFunctions = new HashMap < Integer , AbstractNoiseFunc > ( ) ;
protected static Map < Integer , AbstractNoiseFunc > noiseFunctions = new HashMap < Integer , AbstractNoiseFunc > ( ) ;
static {
static {
// orgBlenderNoise (*Was BLI_hnoise(), removed noisesize, so other functions can call it without scaling.*)
// orgBlenderNoise (*Was BLI_hnoise(), removed noisesize, so other functions can call it without scaling.*)
noiseFunctions . put ( Integer . valueOf ( 0 ) , new AbstractNoiseFunc ( ) {
noiseFunctions . put ( Integer . valueOf ( 0 ) , new AbstractNoiseFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z ) {
public float execute ( float x , float y , float z ) {
return this . orgBlenderNoise ( x , y , z ) ;
return this . orgBlenderNoise ( x , y , z ) ;
@ -187,6 +188,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
} ) ;
} ) ;
// orgPerlinNoise (*For use with BLI_gNoise/gTurbulence, returns signed noise.*)
// orgPerlinNoise (*For use with BLI_gNoise/gTurbulence, returns signed noise.*)
noiseFunctions . put ( Integer . valueOf ( 1 ) , new AbstractNoiseFunc ( ) {
noiseFunctions . put ( Integer . valueOf ( 1 ) , new AbstractNoiseFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z ) {
public float execute ( float x , float y , float z ) {
return 0 . 5f + 0 . 5f * this . noise3Perlin ( new float [ ] { x , y , z } ) ;
return 0 . 5f + 0 . 5f * this . noise3Perlin ( new float [ ] { x , y , z } ) ;
@ -199,6 +201,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
} ) ;
} ) ;
// newPerlin (* for use with BLI_gNoise()/BLI_gTurbulence(), returns unsigned improved perlin noise *)
// newPerlin (* for use with BLI_gNoise()/BLI_gTurbulence(), returns unsigned improved perlin noise *)
noiseFunctions . put ( Integer . valueOf ( 2 ) , new AbstractNoiseFunc ( ) {
noiseFunctions . put ( Integer . valueOf ( 2 ) , new AbstractNoiseFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z ) {
public float execute ( float x , float y , float z ) {
return 0 . 5f + 0 . 5f * this . newPerlin ( x , y , z ) ;
return 0 . 5f + 0 . 5f * this . newPerlin ( x , y , z ) ;
@ -211,6 +214,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
} ) ;
} ) ;
// voronoi_F1
// voronoi_F1
noiseFunctions . put ( Integer . valueOf ( 3 ) , new AbstractNoiseFunc ( ) {
noiseFunctions . put ( Integer . valueOf ( 3 ) , new AbstractNoiseFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z ) {
public float execute ( float x , float y , float z ) {
float [ ] da = new float [ 4 ] , pa = new float [ 12 ] ;
float [ ] da = new float [ 4 ] , pa = new float [ 12 ] ;
@ -227,6 +231,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
} ) ;
} ) ;
// voronoi_F2
// voronoi_F2
noiseFunctions . put ( Integer . valueOf ( 4 ) , new AbstractNoiseFunc ( ) {
noiseFunctions . put ( Integer . valueOf ( 4 ) , new AbstractNoiseFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z ) {
public float execute ( float x , float y , float z ) {
float [ ] da = new float [ 4 ] , pa = new float [ 12 ] ;
float [ ] da = new float [ 4 ] , pa = new float [ 12 ] ;
@ -243,6 +248,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
} ) ;
} ) ;
// voronoi_F3
// voronoi_F3
noiseFunctions . put ( Integer . valueOf ( 5 ) , new AbstractNoiseFunc ( ) {
noiseFunctions . put ( Integer . valueOf ( 5 ) , new AbstractNoiseFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z ) {
public float execute ( float x , float y , float z ) {
float [ ] da = new float [ 4 ] , pa = new float [ 12 ] ;
float [ ] da = new float [ 4 ] , pa = new float [ 12 ] ;
@ -259,6 +265,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
} ) ;
} ) ;
// voronoi_F4
// voronoi_F4
noiseFunctions . put ( Integer . valueOf ( 6 ) , new AbstractNoiseFunc ( ) {
noiseFunctions . put ( Integer . valueOf ( 6 ) , new AbstractNoiseFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z ) {
public float execute ( float x , float y , float z ) {
float [ ] da = new float [ 4 ] , pa = new float [ 12 ] ;
float [ ] da = new float [ 4 ] , pa = new float [ 12 ] ;
@ -275,6 +282,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
} ) ;
} ) ;
// voronoi_F1F2
// voronoi_F1F2
noiseFunctions . put ( Integer . valueOf ( 7 ) , new AbstractNoiseFunc ( ) {
noiseFunctions . put ( Integer . valueOf ( 7 ) , new AbstractNoiseFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z ) {
public float execute ( float x , float y , float z ) {
float [ ] da = new float [ 4 ] , pa = new float [ 12 ] ;
float [ ] da = new float [ 4 ] , pa = new float [ 12 ] ;
@ -291,6 +299,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
} ) ;
} ) ;
// voronoi_Cr
// voronoi_Cr
noiseFunctions . put ( Integer . valueOf ( 8 ) , new AbstractNoiseFunc ( ) {
noiseFunctions . put ( Integer . valueOf ( 8 ) , new AbstractNoiseFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z ) {
public float execute ( float x , float y , float z ) {
float t = 10 * noiseFunctions . get ( Integer . valueOf ( 7 ) ) . execute ( x , y , z ) ; // voronoi_F1F2
float t = 10 * noiseFunctions . get ( Integer . valueOf ( 7 ) ) . execute ( x , y , z ) ; // voronoi_F1F2
@ -305,6 +314,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
} ) ;
} ) ;
// cellNoise
// cellNoise
noiseFunctions . put ( Integer . valueOf ( 14 ) , new AbstractNoiseFunc ( ) {
noiseFunctions . put ( Integer . valueOf ( 14 ) , new AbstractNoiseFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z ) {
public float execute ( float x , float y , float z ) {
int xi = ( int ) Math . floor ( x ) ;
int xi = ( int ) Math . floor ( x ) ;
@ -321,33 +331,37 @@ public class NoiseHelper extends AbstractBlenderHelper {
}
}
} ) ;
} ) ;
}
}
/** Distance metrics for voronoi. e parameter only used in Minkovsky. */
/** Distance metrics for voronoi. e parameter only used in Minkovsky. */
protected static Map < Integer , IDistanceFunc > distanceFunctions = new HashMap < Integer , NoiseHelper . IDistanceFunc > ( ) ;
protected static Map < Integer , DistanceFunc > distanceFunctions = new HashMap < Integer , NoiseHelper . DistanceFunc > ( ) ;
static {
static {
// real distance
// real distance
distanceFunctions . put ( Integer . valueOf ( 0 ) , new IDistanceFunc ( ) {
distanceFunctions . put ( Integer . valueOf ( 0 ) , new DistanceFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z , float e ) {
public float execute ( float x , float y , float z , float e ) {
return ( float ) Math . sqrt ( x * x + y * y + z * z ) ;
return ( float ) Math . sqrt ( x * x + y * y + z * z ) ;
}
}
} ) ;
} ) ;
// distance squared
// distance squared
distanceFunctions . put ( Integer . valueOf ( 1 ) , new IDistanceFunc ( ) {
distanceFunctions . put ( Integer . valueOf ( 1 ) , new DistanceFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z , float e ) {
public float execute ( float x , float y , float z , float e ) {
return x * x + y * y + z * z ;
return x * x + y * y + z * z ;
}
}
} ) ;
} ) ;
// manhattan/taxicab/cityblock distance
// manhattan/taxicab/cityblock distance
distanceFunctions . put ( Integer . valueOf ( 2 ) , new IDistanceFunc ( ) {
distanceFunctions . put ( Integer . valueOf ( 2 ) , new DistanceFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z , float e ) {
public float execute ( float x , float y , float z , float e ) {
return FastMath . abs ( x ) + FastMath . abs ( y ) + FastMath . abs ( z ) ;
return FastMath . abs ( x ) + FastMath . abs ( y ) + FastMath . abs ( z ) ;
}
}
} ) ;
} ) ;
// Chebychev
// Chebychev
distanceFunctions . put ( Integer . valueOf ( 3 ) , new IDistanceFunc ( ) {
distanceFunctions . put ( Integer . valueOf ( 3 ) , new DistanceFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z , float e ) {
public float execute ( float x , float y , float z , float e ) {
x = FastMath . abs ( x ) ;
x = FastMath . abs ( x ) ;
@ -358,7 +372,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
}
}
} ) ;
} ) ;
// minkovsky preset exponent 0.5 (MinkovskyH)
// minkovsky preset exponent 0.5 (MinkovskyH)
distanceFunctions . put ( Integer . valueOf ( 4 ) , new IDistanceFunc ( ) {
distanceFunctions . put ( Integer . valueOf ( 4 ) , new DistanceFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z , float e ) {
public float execute ( float x , float y , float z , float e ) {
float d = ( float ) ( Math . sqrt ( FastMath . abs ( x ) ) + Math . sqrt ( FastMath . abs ( y ) ) + Math . sqrt ( FastMath . abs ( z ) ) ) ;
float d = ( float ) ( Math . sqrt ( FastMath . abs ( x ) ) + Math . sqrt ( FastMath . abs ( y ) ) + Math . sqrt ( FastMath . abs ( z ) ) ) ;
@ -366,7 +381,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
}
}
} ) ;
} ) ;
// minkovsky preset exponent 4 (Minkovsky4)
// minkovsky preset exponent 4 (Minkovsky4)
distanceFunctions . put ( Integer . valueOf ( 5 ) , new IDistanceFunc ( ) {
distanceFunctions . put ( Integer . valueOf ( 5 ) , new DistanceFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z , float e ) {
public float execute ( float x , float y , float z , float e ) {
x * = x ;
x * = x ;
@ -376,17 +392,19 @@ public class NoiseHelper extends AbstractBlenderHelper {
}
}
} ) ;
} ) ;
// Minkovsky, general case, slow, maybe too slow to be useful
// Minkovsky, general case, slow, maybe too slow to be useful
distanceFunctions . put ( Integer . valueOf ( 6 ) , new IDistanceFunc ( ) {
distanceFunctions . put ( Integer . valueOf ( 6 ) , new DistanceFunc ( ) {
@Override
@Override
public float execute ( float x , float y , float z , float e ) {
public float execute ( float x , float y , float z , float e ) {
return ( float ) Math . pow ( Math . pow ( FastMath . abs ( x ) , e ) + Math . pow ( FastMath . abs ( y ) , e ) + Math . pow ( FastMath . abs ( z ) , e ) , 1 . 0f / e ) ;
return ( float ) Math . pow ( Math . pow ( FastMath . abs ( x ) , e ) + Math . pow ( FastMath . abs ( y ) , e ) + Math . pow ( FastMath . abs ( z ) , e ) , 1 . 0f / e ) ;
}
}
} ) ;
} ) ;
}
}
protected static Map < Integer , MusgraveFunction > musgraveFunctions = new HashMap < Integer , NoiseHelper . MusgraveFunction > ( ) ;
protected static Map < Integer , IMusgraveFunction > musgraveFunctions = new HashMap < Integer , NoiseHelper . IMusgraveFunction > ( ) ;
static {
static {
musgraveFunctions . put ( Integer . valueOf ( TEX_MFRACTAL ) , new IMusgraveFunction ( ) {
musgraveFunctions . put ( Integer . valueOf ( TEX_MFRACTAL ) , new MusgraveFunction ( ) {
@Override
@Override
public float execute ( Structure tex , float x , float y , float z ) {
public float execute ( Structure tex , float x , float y , float z ) {
float mg_H = ( ( Number ) tex . getFieldValue ( "mg_H" ) ) . floatValue ( ) ;
float mg_H = ( ( Number ) tex . getFieldValue ( "mg_H" ) ) . floatValue ( ) ;
@ -414,7 +432,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
return value ;
return value ;
}
}
} ) ;
} ) ;
musgraveFunctions . put ( Integer . valueOf ( TEX_RIDGEDMF ) , new IMusgraveFunction ( ) {
musgraveFunctions . put ( Integer . valueOf ( TEX_RIDGEDMF ) , new MusgraveFunction ( ) {
@Override
@Override
public float execute ( Structure tex , float x , float y , float z ) {
public float execute ( Structure tex , float x , float y , float z ) {
float mg_H = ( ( Number ) tex . getFieldValue ( "mg_H" ) ) . floatValue ( ) ;
float mg_H = ( ( Number ) tex . getFieldValue ( "mg_H" ) ) . floatValue ( ) ;
@ -456,7 +475,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
return result ;
return result ;
}
}
} ) ;
} ) ;
musgraveFunctions . put ( Integer . valueOf ( TEX_HYBRIDMF ) , new IMusgraveFunction ( ) {
musgraveFunctions . put ( Integer . valueOf ( TEX_HYBRIDMF ) , new MusgraveFunction ( ) {
@Override
@Override
public float execute ( Structure tex , float x , float y , float z ) {
public float execute ( Structure tex , float x , float y , float z ) {
float mg_H = ( ( Number ) tex . getFieldValue ( "mg_H" ) ) . floatValue ( ) ;
float mg_H = ( ( Number ) tex . getFieldValue ( "mg_H" ) ) . floatValue ( ) ;
@ -499,7 +519,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
return result ;
return result ;
}
}
} ) ;
} ) ;
musgraveFunctions . put ( Integer . valueOf ( TEX_FBM ) , new IMusgraveFunction ( ) {
musgraveFunctions . put ( Integer . valueOf ( TEX_FBM ) , new MusgraveFunction ( ) {
@Override
@Override
public float execute ( Structure tex , float x , float y , float z ) {
public float execute ( Structure tex , float x , float y , float z ) {
float mg_H = ( ( Number ) tex . getFieldValue ( "mg_H" ) ) . floatValue ( ) ;
float mg_H = ( ( Number ) tex . getFieldValue ( "mg_H" ) ) . floatValue ( ) ;
@ -528,7 +549,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
return value ;
return value ;
}
}
} ) ;
} ) ;
musgraveFunctions . put ( Integer . valueOf ( TEX_HTERRAIN ) , new IMusgraveFunction ( ) {
musgraveFunctions . put ( Integer . valueOf ( TEX_HTERRAIN ) , new MusgraveFunction ( ) {
@Override
@Override
public float execute ( Structure tex , float x , float y , float z ) {
public float execute ( Structure tex , float x , float y , float z ) {
float mg_H = ( ( Number ) tex . getFieldValue ( "mg_H" ) ) . floatValue ( ) ;
float mg_H = ( ( Number ) tex . getFieldValue ( "mg_H" ) ) . floatValue ( ) ;
@ -792,18 +814,21 @@ public class NoiseHelper extends AbstractBlenderHelper {
}
}
interface IWaveForm {
interface IWaveForm {
float execute ( float x ) ;
float execute ( float x ) ;
}
}
protected static IWaveForm [ ] waveformFunctions = new IWaveForm [ 3 ] ;
protected static IWaveForm [ ] waveformFunctions = new IWaveForm [ 3 ] ;
static {
static {
waveformFunctions [ 0 ] = new IWaveForm ( ) { // tex_sin
waveformFunctions [ 0 ] = new IWaveForm ( ) { // tex_sin
@Override
@Override
public float execute ( float x ) {
public float execute ( float x ) {
return 0 . 5f + 0 . 5f * ( float ) Math . sin ( x ) ;
return 0 . 5f + 0 . 5f * ( float ) Math . sin ( x ) ;
}
}
} ;
} ;
waveformFunctions [ 1 ] = new IWaveForm ( ) { // tex_saw
waveformFunctions [ 1 ] = new IWaveForm ( ) { // tex_saw
@Override
@Override
public float execute ( float x ) {
public float execute ( float x ) {
int n = ( int ) ( x / FastMath . TWO_PI ) ;
int n = ( int ) ( x / FastMath . TWO_PI ) ;
@ -815,6 +840,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
}
}
} ;
} ;
waveformFunctions [ 2 ] = new IWaveForm ( ) { // tex_tri
waveformFunctions [ 2 ] = new IWaveForm ( ) { // tex_tri
@Override
@Override
public float execute ( float x ) {
public float execute ( float x ) {
return 1 . 0f - 2 . 0f * FastMath . abs ( ( float ) Math . floor ( x * 1 . 0f / FastMath . TWO_PI + 0 . 5f ) - x * 1 . 0f / FastMath . TWO_PI ) ;
return 1 . 0f - 2 . 0f * FastMath . abs ( ( float ) Math . floor ( x * 1 . 0f / FastMath . TWO_PI + 0 . 5f ) - x * 1 . 0f / FastMath . TWO_PI ) ;
@ -891,7 +917,6 @@ public class NoiseHelper extends AbstractBlenderHelper {
/ * *
/ * *
* THE FOLLOWING METHODS HELP IN NOISE COMPUTATIONS
* THE FOLLOWING METHODS HELP IN NOISE COMPUTATIONS
* /
* /
/ * *
/ * *
* Separated from orgBlenderNoise above , with scaling .
* Separated from orgBlenderNoise above , with scaling .
* @param noisesize
* @param noisesize
@ -1104,7 +1129,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
float contrast = ( ( Number ) tex . getFieldValue ( "contrast" ) ) . floatValue ( ) ;
float contrast = ( ( Number ) tex . getFieldValue ( "contrast" ) ) . floatValue ( ) ;
float brightness = ( ( Number ) tex . getFieldValue ( "bright" ) ) . floatValue ( ) ;
float brightness = ( ( Number ) tex . getFieldValue ( "bright" ) ) . floatValue ( ) ;
I MusgraveFunction mgravefunc = stype = = TEX_MFRACTAL ? musgraveFunctions . get ( Integer . valueOf ( stype ) ) : musgraveFunctions . get ( Integer . valueOf ( TEX_FBM ) ) ;
MusgraveFunction mgravefunc = stype = = TEX_MFRACTAL ? musgraveFunctions . get ( Integer . valueOf ( stype ) ) : musgraveFunctions . get ( Integer . valueOf ( TEX_FBM ) ) ;
texres . tin = nsOutscale * mgravefunc . execute ( tex , texvec [ 0 ] , texvec [ 1 ] , texvec [ 2 ] ) ;
texres . tin = nsOutscale * mgravefunc . execute ( tex , texvec [ 0 ] , texvec [ 1 ] , texvec [ 2 ] ) ;
if ( texres . nor ! = null ) {
if ( texres . nor ! = null ) {
@ -1126,7 +1151,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
float contrast = ( ( Number ) tex . getFieldValue ( "contrast" ) ) . floatValue ( ) ;
float contrast = ( ( Number ) tex . getFieldValue ( "contrast" ) ) . floatValue ( ) ;
float brightness = ( ( Number ) tex . getFieldValue ( "bright" ) ) . floatValue ( ) ;
float brightness = ( ( Number ) tex . getFieldValue ( "bright" ) ) . floatValue ( ) ;
I MusgraveFunction mgravefunc = stype = = TEX_RIDGEDMF ? musgraveFunctions . get ( Integer . valueOf ( stype ) ) : musgraveFunctions . get ( Integer . valueOf ( TEX_HYBRIDMF ) ) ;
MusgraveFunction mgravefunc = stype = = TEX_RIDGEDMF ? musgraveFunctions . get ( Integer . valueOf ( stype ) ) : musgraveFunctions . get ( Integer . valueOf ( TEX_HYBRIDMF ) ) ;
texres . tin = nsOutscale * mgravefunc . execute ( tex , texvec [ 0 ] , texvec [ 1 ] , texvec [ 2 ] ) ;
texres . tin = nsOutscale * mgravefunc . execute ( tex , texvec [ 0 ] , texvec [ 1 ] , texvec [ 2 ] ) ;
if ( texres . nor ! = null ) {
if ( texres . nor ! = null ) {
@ -1147,7 +1172,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
float contrast = ( ( Number ) tex . getFieldValue ( "contrast" ) ) . floatValue ( ) ;
float contrast = ( ( Number ) tex . getFieldValue ( "contrast" ) ) . floatValue ( ) ;
float brightness = ( ( Number ) tex . getFieldValue ( "bright" ) ) . floatValue ( ) ;
float brightness = ( ( Number ) tex . getFieldValue ( "bright" ) ) . floatValue ( ) ;
I MusgraveFunction musgraveFunction = musgraveFunctions . get ( Integer . valueOf ( TEX_HTERRAIN ) ) ;
MusgraveFunction musgraveFunction = musgraveFunctions . get ( Integer . valueOf ( TEX_HTERRAIN ) ) ;
texres . tin = nsOutscale * musgraveFunction . execute ( tex , texvec [ 0 ] , texvec [ 1 ] , texvec [ 2 ] ) ;
texres . tin = nsOutscale * musgraveFunction . execute ( tex , texvec [ 0 ] , texvec [ 1 ] , texvec [ 2 ] ) ;
if ( texres . nor ! = null ) {
if ( texres . nor ! = null ) {
float offs = nabla / noisesize ; // also scaling of texvec
float offs = nabla / noisesize ; // also scaling of texvec
@ -1166,6 +1191,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
* @author Marcin Roguski ( Kaelthas )
* @author Marcin Roguski ( Kaelthas )
* /
* /
protected static abstract class AbstractNoiseFunc {
protected static abstract class AbstractNoiseFunc {
/ * *
/ * *
* This method calculates the unsigned value of the noise .
* This method calculates the unsigned value of the noise .
* @param x
* @param x
@ -1196,7 +1222,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
protected static void voronoi ( float x , float y , float z , float [ ] da , float [ ] pa , float me , int dtype ) {
protected static void voronoi ( float x , float y , float z , float [ ] da , float [ ] pa , float me , int dtype ) {
float xd , yd , zd , d , p [ ] ;
float xd , yd , zd , d , p [ ] ;
I DistanceFunc distanceFunc = distanceFunctions . get ( Integer . valueOf ( dtype ) ) ;
DistanceFunc distanceFunc = distanceFunctions . get ( Integer . valueOf ( dtype ) ) ;
if ( distanceFunc = = null ) {
if ( distanceFunc = = null ) {
distanceFunc = distanceFunctions . get ( Integer . valueOf ( 0 ) ) ;
distanceFunc = distanceFunctions . get ( Integer . valueOf ( 0 ) ) ;
}
}
@ -1281,7 +1307,6 @@ public class NoiseHelper extends AbstractBlenderHelper {
// b1 = (b0+1) & 255; \
// b1 = (b0+1) & 255; \
// r0 = t - (int)t; \
// r0 = t - (int)t; \
// r1 = r0 - 1.;
// r1 = r0 - 1.;
// vec[3]
// vec[3]
public float noise3Perlin ( float [ ] vec ) {
public float noise3Perlin ( float [ ] vec ) {
int bx0 , bx1 , by0 , by1 , bz0 , bz1 , b00 , b10 , b01 , b11 ;
int bx0 , bx1 , by0 , by1 , bz0 , bz1 , b00 , b10 , b01 , b11 ;
@ -1509,7 +1534,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
* This interface is used for distance calculation classes . Distance metrics for voronoi . e parameter only used in
* This interface is used for distance calculation classes . Distance metrics for voronoi . e parameter only used in
* Minkovsky .
* Minkovsky .
* /
* /
interface IDistanceFunc {
interface DistanceFunc {
/ * *
/ * *
* This method calculates the distance for voronoi algorithms .
* This method calculates the distance for voronoi algorithms .
* @param x
* @param x
@ -1525,7 +1551,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
float execute ( float x , float y , float z , float e ) ;
float execute ( float x , float y , float z , float e ) ;
}
}
interface IMusgraveFunction {
interface MusgraveFunction {
float execute ( Structure tex , float x , float y , float z ) ;
float execute ( Structure tex , float x , float y , float z ) ;
}
}
}
}