Package com.ardor3d.math.functions

Examples of com.ardor3d.math.functions.Function3D


            updatedTerrainTiles[i] = Sets.newHashSet();
            updatedTextureTiles[i] = Sets.newHashSet();
        }

        final double procScale = 1.0 / 4000.0;
        final Function3D functionTmp = new FbmFunction3D(Functions.simplexNoise(), 9, 0.5, 0.5, 3.14);
        final Function3D function = Functions.scaleInput(functionTmp, procScale, procScale, 1);

        for (int y = 0; y < side; y++) {
            for (int x = 0; x < side; x++) {
                final int index = y * side + x;

                final float h = (float) function.eval(x, y, 0);
                heightData[index] = h;

                int col = (int) (h * h * 255 * 0.6);
                col = MathUtils.clamp(col, 0, 255);
                colorData[index * 4 + 0] = (byte) (col * 1.0);
 
View Full Code Here


    }

    private void updateTexture() {
        // Build up our function
        final MandelbrotFunction3D mandelBase = new MandelbrotFunction3D(Math.round(iterations));
        final Function3D translatedMandel = Functions.translateInput(mandelBase, trans.getX(), trans.getY(), 0);
        final Function3D finalMandel = Functions.scaleInput(translatedMandel, scale.getX(), scale.getY(), 1);

        final Camera cam = _canvas.getCanvasRenderer().getCamera();
        Image img = GeneratedImageFactory.createLuminance8Image(finalMandel, cam.getWidth(), cam.getHeight(), 1);

        img = GeneratedImageFactory.createColorImageFromLuminance8(img, false, colors);
View Full Code Here

            // Keep a separate camera to be able to freeze terrain update
            final Camera camera = _canvas.getCanvasRenderer().getCamera();
            terrainCamera = new Camera(camera);

            final double scale = 1.0 / 4000.0;
            Function3D functionTmp = new FbmFunction3D(Functions.simplexNoise(), 9, 0.5, 0.5, 3.14);
            functionTmp = Functions.clamp(functionTmp, -1.2, 1.2);
            final Function3D function = Functions.scaleInput(functionTmp, scale, scale, 1);

            final TerrainDataProvider terrainDataProvider = new ProceduralTerrainDataProvider(function, new Vector3(1,
                    200, 1), -1.2f, 1.2f);

            terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build();
View Full Code Here

        panel.setTooltipPopTime(25);

        final Texture tex = new Texture2D();

        // Build up our function
        final Function3D largeSlimeBase = new CloudsFunction3D(Functions.simplexNoise(), 1, 4.0, 0.5, 2.12);
        final Function3D largeSlime = Functions.scaleBias(largeSlimeBase, 1, 0.5);
        final Function3D smallSlimeBase = new CloudsFunction3D(Functions.simplexNoise(), 1, 24.0, 0.5, 2.14);
        final Function3D smallSlime = Functions.scaleBias(smallSlimeBase, 0.5, 0);
        final RidgeFunction3D slimeMap = new RidgeFunction3D(Functions.simplexNoise(), 3, 2.0, 2.207);
        final MapperFunction3D slimeMapper = new MapperFunction3D(slimeMap, -1, 1);
        slimeMapper.addFunction(largeSlime, 0, 0, 0);
        slimeMapper.addFunction(smallSlime, .125, 1, 1);
        slimeMapper.addFunction(largeSlime, 1.75, 0, 0);
        final Function3D finalSlime = new TurbulenceFunction3D(slimeMapper, 1 / 32.0, 2, 8.0);

        final ReadOnlyColorRGBA[] slimeColors = new ReadOnlyColorRGBA[256];
        slimeColors[0] = new ColorRGBA(160 / 255f, 64 / 255f, 42 / 255f, 1);
        slimeColors[127] = new ColorRGBA(64 / 255f, 192 / 255f, 64 / 255f, 1);
        slimeColors[255] = new ColorRGBA(128 / 255f, 255 / 255f, 128 / 255f, 1);
View Full Code Here

        // voronoi
        setVoronoi(srcs[index++]);

        // *** 'Planet' example:
        final Function3D terrain = Functions.scaleInput(Functions.simplexNoise(), 2, 2, 1);
        terrainColors = new ReadOnlyColorRGBA[256];
        terrainColors[0] = new ColorRGBA(0, 0, .5f, 1);
        terrainColors[95] = new ColorRGBA(0, 0, 1, 1);
        terrainColors[127] = new ColorRGBA(0, .5f, 1, 1);
        terrainColors[137] = new ColorRGBA(240 / 255f, 240 / 255f, 64 / 255f, 1);
View Full Code Here

        panel.setTooltipText("Simple Checkerboard pattern");

        final Texture tex = new Texture2D();

        // Build up our function
        final Function3D finalCheck = new CheckerFunction3D();

        final Image img = GeneratedImageFactory.createLuminance8Image(finalCheck, wside, hside, 1, 1, 9, 1, 9, 0, 0,
                -1, 1);
        tex.setImage(img);
        // No need for filtering on this one...
View Full Code Here

        panel.setTooltipText("The famous Mandelbrot fractal");

        final Texture tex = new Texture2D();

        // Build up our function
        final Function3D mandelBase = new MandelbrotFunction3D(256);
        final Function3D translatedMandel = Functions.translateInput(mandelBase, -.7, 0, 0);
        final Function3D finalMandel = Functions.scaleInput(translatedMandel, 1.5, 1.5, 1);

        final ReadOnlyColorRGBA[] colors = new ReadOnlyColorRGBA[256];
        colors[0] = ColorRGBA.BLUE;
        colors[10] = ColorRGBA.YELLOW;
        colors[25] = ColorRGBA.BLUE;
View Full Code Here

        applyTexture(tex, panel);
    }

    private void setTerrain(final UIPanel panel, final Function3D in, final boolean useFbm, final boolean useColor) {
        final Texture tex = new Texture2D();
        Function3D func = in;
        if (useFbm) {
            func = new FbmFunction3D(func, 5, 0.5, 0.5, 3.14);
        }
        Image img = GeneratedImageFactory.createLuminance8Image(func, wside, hside, 1);
        if (useColor) {
View Full Code Here

        panel.setTooltipText("Dark wood grain.");

        final Texture tex = new Texture2D();

        // Build up our function
        final Function3D baseWood = new CylinderFunction3D(18);
        final Function3D woodGrainNoise = new FbmFunction3D(Functions.simplexNoise(), 3, 40, 0.75, 2.3);
        final Function3D scaledBaseWoodGrain = Functions.scaleInput(woodGrainNoise, 1, .25, 1);
        final Function3D woodGrain = Functions.scaleBias(scaledBaseWoodGrain, .125, 0);
        final Function3D combinedWood = Functions.add(baseWood, woodGrain);
        final Function3D perturbedWood = new TurbulenceFunction3D(combinedWood, 1 / 256.0, 4, 4.0);
        final Function3D translatedWood = Functions.translateInput(perturbedWood, 0, 0, 1.5);
        final Function3D rotatedWood = Functions.rotateInput(translatedWood, new Matrix3().fromAngles(
                MathUtils.DEG_TO_RAD * 6, 0, 0));
        final Function3D finalWood = new TurbulenceFunction3D(rotatedWood, 1 / 512.0, 2, 2.0);

        final ReadOnlyColorRGBA[] woodColors = new ReadOnlyColorRGBA[256];
        woodColors[0] = new ColorRGBA(189 / 255f, 94 / 255f, 4 / 255f, 1);
        woodColors[127] = new ColorRGBA(144 / 255f, 48 / 255f, 6 / 255f, 1);
        woodColors[255] = new ColorRGBA(60 / 255f, 10 / 255f, 8 / 255f, 1);
View Full Code Here

        panel.setTooltipText("A Jade-like texture");

        final Texture tex = new Texture2D();

        // Build up our function
        final Function3D primaryJade = new RidgeFunction3D(Functions.simplexNoise(), 6, 2.0, 2.207);
        final Function3D baseSecondaryJade = new CylinderFunction3D(2);
        final Function3D rotatedBaseSecondaryJade = Functions.rotateInput(baseSecondaryJade, new Matrix3().fromAngles(
                0, MathUtils.DEG_TO_RAD * 65, MathUtils.DEG_TO_RAD * 85));
        final Function3D perturbedBaseSecondaryJade = new TurbulenceFunction3D(rotatedBaseSecondaryJade, 1.0 / 4.0, 4,
                4.0);
        final Function3D secondaryJade = Functions.scaleBias(perturbedBaseSecondaryJade, .25, 0);
        final Function3D combinedJade = Functions.add(primaryJade, secondaryJade);
        final Function3D finalJade = new TurbulenceFunction3D(combinedJade, 1 / 16.0, 2, 4.0);

        final ReadOnlyColorRGBA[] jadeColors = new ReadOnlyColorRGBA[256];
        jadeColors[0] = new ColorRGBA(24 / 255f, 146 / 255f, 102 / 255f, 1);
        jadeColors[127] = new ColorRGBA(78 / 255f, 154 / 255f, 115 / 255f, 1);
        jadeColors[159] = new ColorRGBA(128 / 255f, 204 / 255f, 165 / 255f, 1);
View Full Code Here

TOP

Related Classes of com.ardor3d.math.functions.Function3D

Copyright © 2018 www.massapicom. 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.