本文整理汇总了Java中com.jme3.terrain.noise.fractal.FractalSum类的典型用法代码示例。如果您正苦于以下问题:Java FractalSum类的具体用法?Java FractalSum怎么用?Java FractalSum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FractalSum类属于com.jme3.terrain.noise.fractal包,在下文中一共展示了FractalSum类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createFractalGenerator
import com.jme3.terrain.noise.fractal.FractalSum; //导入依赖的package包/类
private Basis createFractalGenerator() {
final FractalSum fractalSum = new FractalSum();
fractalSum.setRoughness(getRoughness());
fractalSum.setFrequency(getFrequency());
fractalSum.setAmplitude(getBrushPower());
fractalSum.setLacunarity(getLacunarity()); // make it greater than 1.0f
fractalSum.setOctaves(getOctaves());
fractalSum.setScale(max(min(getScale(), 1.0F), 0F)); //0.02125f
fractalSum.addModulator((NoiseModulator) in -> ShaderUtils.clamp(in[0] * 0.5f + 0.5f, 0, 1));
final FilteredBasis ground = new FilteredBasis(fractalSum);
final PerturbFilter perturb = new PerturbFilter();
perturb.setMagnitude(0.2f);//0.119 the higher, the slower it is
final OptimizedErode therm = new OptimizedErode();
therm.setRadius(5);
therm.setTalus(0.011f);
final SmoothFilter smooth = new SmoothFilter();
smooth.setRadius(1);
smooth.setEffect(0.1f); // 0.7
final IterativeFilter iterate = new IterativeFilter();
iterate.addPreFilter(perturb);
iterate.addPostFilter(smooth);
iterate.setFilter(therm);
iterate.setIterations(1);
ground.addPreFilter(iterate);
return ground;
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:35,代码来源:RoughTerrainToolControl.java
示例2: createNoiseGenerator
import com.jme3.terrain.noise.fractal.FractalSum; //导入依赖的package包/类
private FilteredBasis createNoiseGenerator()
{
FractalSum base = new FractalSum();
base.setRoughness(0.7f);
base.setFrequency(1.0f);
base.setAmplitude(1.0f);
base.setLacunarity(3.12f);
base.setOctaves(8);
base.setScale(0.02125f);
base.addModulator(new NoiseModulator()
{
@Override public float value(float... in)
{
return ShaderUtils.clamp(in[0] * 0.5f + 0.5f, 0, 1);
}
});
FilteredBasis ground = new FilteredBasis(base);
PerturbFilter perturb = new PerturbFilter();
perturb.setMagnitude(0.119f);
OptimizedErode therm = new OptimizedErode();
therm.setRadius(5);
therm.setTalus(0.011f);
SmoothFilter smooth = new SmoothFilter();
smooth.setRadius(1);
smooth.setEffect(0.7f);
IterativeFilter iterate = new IterativeFilter();
iterate.addPreFilter(perturb);
iterate.addPostFilter(smooth);
iterate.setFilter(therm);
iterate.setIterations(1);
ground.addPreFilter(iterate);
return ground;
}
开发者ID:jayfella,项目名称:World,代码行数:40,代码来源:Example_NoiseHeightMap.java
示例3: filter
import com.jme3.terrain.noise.fractal.FractalSum; //导入依赖的package包/类
@Override
public FloatBuffer filter(float sx, float sy, float base, FloatBuffer data, int workSize) {
float[] arr = data.array();
int origSize = (int) Math.ceil(workSize / (2 * this.magnitude + 1));
int offset = (workSize - origSize) / 2;
Logger.getLogger(PerturbFilter.class.getCanonicalName()).info(
"Found origSize : " + origSize + " and offset: " + offset + " for workSize : " + workSize + " and magnitude : "
+ this.magnitude);
float[] retval = new float[workSize * workSize];
float[] perturbx = new FractalSum().setOctaves(8).setScale(5f).getBuffer(sx, sy, base, workSize).array();
float[] perturby = new FractalSum().setOctaves(8).setScale(5f).getBuffer(sx, sy, base + 1, workSize).array();
for (int y = 0; y < workSize; y++) {
for (int x = 0; x < workSize; x++) {
// Perturb our coordinates
float noisex = perturbx[y * workSize + x];
float noisey = perturby[y * workSize + x];
int px = (int) (origSize * noisex * this.magnitude);
int py = (int) (origSize * noisey * this.magnitude);
float c00 = arr[this.wrap(y - py, workSize) * workSize + this.wrap(x - px, workSize)];
float c01 = arr[this.wrap(y - py, workSize) * workSize + this.wrap(x + px, workSize)];
float c10 = arr[this.wrap(y + py, workSize) * workSize + this.wrap(x - px, workSize)];
float c11 = arr[this.wrap(y + py, workSize) * workSize + this.wrap(x + px, workSize)];
float c0 = ShaderUtils.mix(c00, c01, noisex);
float c1 = ShaderUtils.mix(c10, c11, noisex);
retval[y * workSize + x] = ShaderUtils.mix(c0, c1, noisey);
}
}
return FloatBuffer.wrap(retval);
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:33,代码来源:PerturbFilter.java
示例4: createFractalGenerator
import com.jme3.terrain.noise.fractal.FractalSum; //导入依赖的package包/类
private Basis createFractalGenerator(RoughExtraToolParams params, float weight) {
FractalSum base = new FractalSum();
base.setRoughness(params.roughness);
base.setFrequency(params.frequency);
base.setAmplitude(weight);
base.setLacunarity(params.lacunarity <= 1 ? 1.1f : params.lacunarity); // make it greater than 1.0f
base.setOctaves(params.octaves);
float scale = params.scale;
if (scale > 1.0f)
scale = 1.0f;
if (scale < 0)
scale = 0;
base.setScale(scale);//0.02125f
base.addModulator(new NoiseModulator() {
@Override
public float value(float... in) {
return ShaderUtils.clamp(in[0] * 0.5f + 0.5f, 0, 1);
}
});
FilteredBasis ground = new FilteredBasis(base);
PerturbFilter perturb = new PerturbFilter();
perturb.setMagnitude(0.2f);//0.119 the higher, the slower it is
OptimizedErode therm = new OptimizedErode();
therm.setRadius(5);
therm.setTalus(0.011f);
SmoothFilter smooth = new SmoothFilter();
smooth.setRadius(1);
smooth.setEffect(0.1f); // 0.7
IterativeFilter iterate = new IterativeFilter();
iterate.addPreFilter(perturb);
iterate.addPostFilter(smooth);
iterate.setFilter(therm);
iterate.setIterations(1);
ground.addPreFilter(iterate);
return ground;
}
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:44,代码来源:RoughTerrainToolAction.java
示例5: createWorldWithNoise
import com.jme3.terrain.noise.fractal.FractalSum; //导入依赖的package包/类
private void createWorldWithNoise()
{
NoiseBasedWorld newWorld = new NoiseBasedWorld(app, bulletAppState.getPhysicsSpace(), tileSize, blockSize);
newWorld.setWorldHeight(192f);
newWorld.setViewDistance(2);
// newWorld.setViewDistance(14, 1, 2, 1);
newWorld.setCacheTime(5000);
Material terrainMaterial = createTerrainMaterial();
newWorld.setMaterial(terrainMaterial);
// create a noise generator
FractalSum base = new FractalSum();
base.setRoughness(0.7f);
base.setFrequency(1.0f);
base.setAmplitude(1.0f);
base.setLacunarity(3.12f);
base.setOctaves(8);
base.setScale(0.02125f);
base.addModulator(new NoiseModulator()
{
@Override
public float value(float... in) {
return ShaderUtils.clamp(in[0] * 0.5f + 0.5f, 0, 1);
}
});
FilteredBasis ground = new FilteredBasis(base);
PerturbFilter perturb = new PerturbFilter();
perturb.setMagnitude(0.119f);
OptimizedErode therm = new OptimizedErode();
therm.setRadius(5);
therm.setTalus(0.011f);
SmoothFilter smooth = new SmoothFilter();
smooth.setRadius(1);
smooth.setEffect(0.7f);
IterativeFilter iterate = new IterativeFilter();
iterate.addPreFilter(perturb);
iterate.addPostFilter(smooth);
iterate.setFilter(therm);
iterate.setIterations(1);
ground.addPreFilter(iterate);
newWorld.setFilteredBasis(ground);
this.world = newWorld;
}
开发者ID:jayfella,项目名称:TerrainWorld,代码行数:57,代码来源:Main.java
注:本文中的com.jme3.terrain.noise.fractal.FractalSum类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论