Package NoiseGen.NoiseContainer.populated.combined

Source Code of NoiseGen.NoiseContainer.populated.combined.SimpleNoiseCombiner

package NoiseGen.NoiseContainer.populated.combined;

import NoiseGen.NoiseContainer.populated.GeneratedNoiseContainer;
import NoiseGen.NoiseGenerator.NoiseGenerator;
import util.Values.DimensionalValues.DimensionalValues3D;

import java.util.LinkedList;

/**
* Created by IntelliJ IDEA.
* Author: Jesse Weiman
* Date: 5/31/12
* Time: 2:19 AM
*/

public abstract class SimpleNoiseCombiner extends GeneratedNoiseContainer {

    private LinkedList<DimensionalValues3D<Integer, Double>> octaves;
    private int numOctaves = 4;
    private boolean fractalOctaves = false;
    private double scaleOctX = 0.05, scaleOctY = 0.05, scaleOctZ = 0.05;
    private double weight = 1, gain = 0.5;

    public SimpleNoiseCombiner(int x, int y, int z){
        super(x, y, z);

    }

    /**
     * Populates the NoiseContainer list with GeneratedLayer layers.
     * @param generator  The NoiseGenerator that provides the getValue method
     */
    public void populate(NoiseGenerator generator, int startX, int startY, int startZ, int endX, int endY, int endZ) {
        octaves = new LinkedList<>();
        long originalSeed = generator.getSeed();
        for(int o = 0; o < getNumOctaves(); o++){
            if(!isFractalOctaves())
                generator.setSeed(originalSeed + o);
            GeneratedNoiseContainer layer = new GeneratedNoiseContainer(getLength(), getHeight(), getDepth());
            layer.setScale(getScaleX() + (o * getScaleOctX()), getScaleY() + (o * getScaleOctY()), getScaleZ() + (o * getScaleOctZ()));
            layer.populate(generator);
            octaves.add(layer);
        }
        generator.setSeed(originalSeed);
        combine();
    }

    protected void combine() {
        for (int x = 0; x < getLength(); x++)
            for (int y = 0; y < getHeight(); y++)
                for (int z = 0; z < getDepth(); z++) {
                    setValue(x, y, z, getCombinedValue(x, y, z));
                }
    }

    protected abstract Double getCombinedValue(int x, int y, int z);

    public double getScaleOctX() {
        return scaleOctX;
    }

    public double getScaleOctY() {
        return scaleOctY;
    }

    public double getScaleOctZ() {
        return scaleOctZ;
    }

    public void setScaleOct(double scaleOctX, double scaleOctY, double scaleOctZ) {
        this.scaleOctX = scaleOctX;
        this.scaleOctY = scaleOctY;
        this.scaleOctZ = scaleOctZ;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    public double getGain() {
        return gain;
    }

    public void setGain(double g) {
        gain = g;
    }

    public int getNumOctaves() {
        return numOctaves;
    }

    public void setNumOctaves(int numOctaves) {
        this.numOctaves = numOctaves;
    }

    public boolean isFractalOctaves() {
        return fractalOctaves;
    }

    public void setFractalOctaves(boolean fractalOctaves) {
        this.fractalOctaves = fractalOctaves;
    }

    public LinkedList<DimensionalValues3D<Integer, Double>> getOctaves() {
        return octaves;
    }
}
TOP

Related Classes of NoiseGen.NoiseContainer.populated.combined.SimpleNoiseCombiner

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.