Example usage for com.badlogic.gdx.utils FloatArray FloatArray

List of usage examples for com.badlogic.gdx.utils FloatArray FloatArray

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils FloatArray FloatArray.

Prototype

public FloatArray() 

Source Link

Document

Creates an ordered array with a capacity of 16.

Usage

From source file:com.andgate.ikou.render.TileMesh.java

License:Open Source License

public TileMesh() {
    vertices = new FloatArray();
    indicies = new ShortArray();
}

From source file:com.android.ringfly.common.Assets.java

License:Apache License

/**
 * /*from  ww  w  .ja  v a  2  s  .  c  om*/
 * 
 * @return
 */
private static float calculatePixelDensity() {
    FileHandle textureDir = Gdx.files.internal("data/textures");
    FileHandle[] availableDensities = textureDir.list();
    FloatArray densities = new FloatArray();
    for (int i = 0; i < availableDensities.length; i++) {
        try {
            float density = Float.parseFloat(availableDensities[i].name());
            densities.add(density);
        } catch (NumberFormatException ex) {
            // Ignore anything non-numeric, such as ".svn" folders.
        }
    }
    densities.shrink(); // Remove empty slots to get rid of zeroes.
    densities.sort(); // Now the lowest density comes first.
    return CameraHelper.bestDensity(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, densities.items);
}

From source file:com.badlogic.gdx.tests.TextAreaTest2.java

License:Apache License

@Override
public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);//www.  j ava2 s. c om
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));

    //Create a string that perfectly fills the float array used in the textarea float array
    FloatArray dummyArray = new FloatArray();
    String limit = "";
    // Minus one, because TextField adds a magic char
    for (int i = 0; i < dummyArray.items.length - 1; i++) {
        limit += "a";
    }

    TextArea textArea = new TextArea(limit, skin);
    textArea.setX(10);
    textArea.setY(10);
    textArea.setWidth(200);
    textArea.setHeight(200);

    stage.addActor(textArea);
}

From source file:com.badlydrawngames.veryangryrobots.Assets.java

License:Apache License

private static float calculatePixelDensity() {
    FileHandle textureDir = Gdx.files.internal("data/textures");
    FileHandle[] availableDensities = textureDir.list();
    FloatArray densities = new FloatArray();
    for (int i = 0; i < availableDensities.length; i++) {
        try {//  ww w.  j a v a  2  s  . co  m
            float density = Float.parseFloat(availableDensities[i].name());
            densities.add(density);
        } catch (NumberFormatException ex) {
            // Ignore anything non-numeric, such as ".svn" folders.
        }
    }
    densities.shrink(); // Remove empty slots to get rid of zeroes.
    densities.sort(); // Now the lowest density comes first.
    return CameraHelper.bestDensity(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, densities.items);
}

From source file:com.mbrlabs.mundus.commons.assets.TerrainAsset.java

License:Apache License

@Override
public void load() {
    // load height data from terra file
    final FloatArray floatArray = new FloatArray();

    DataInputStream is;/*from  w  w  w  . j  a v a  2s  . co m*/
    try {
        is = new DataInputStream(file.read());
        while (is.available() > 0) {
            floatArray.add(is.readFloat());
        }
        is.close();
    } catch (EOFException e) {
        // e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }
    data = floatArray.toArray();

    terrain = new Terrain(meta.getTerrain().getSize(), data);
    terrain.init();
    terrain.update();
}

From source file:com.mbrlabs.mundus.runtime.libgdx.TerraLoader.java

License:Apache License

public static float[] readTerraFile(FileHandle terra) {
    FloatArray floatArray = new FloatArray();

    DataInputStream is = null;//  ww w  .j a v a 2  s . c om
    try {
        is = new DataInputStream(new BufferedInputStream(new GZIPInputStream(terra.read())));
        while (is.available() > 0) {
            floatArray.add(is.readFloat());
        }
        is.close();
    } catch (EOFException e) {
        // e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return floatArray.toArray();
}

From source file:com.mbrlabs.mundus.utils.TerrainIO.java

License:Apache License

public static Terrain importTerrain(ProjectContext projectContext, Terrain terrain) {
    FloatArray floatArray = new FloatArray();

    String terraPath = FilenameUtils.concat(projectContext.path, terrain.terraPath);
    try (DataInputStream is = new DataInputStream(
            new BufferedInputStream(new GZIPInputStream(new FileInputStream(terraPath))))) {
        while (is.available() > 0) {
            floatArray.add(is.readFloat());
        }// w w w .  ja va2  s.c  om
    } catch (EOFException e) {
        //e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    //Log.debug("Terrain import. floats: " + floatArray.size);

    terrain.heightData = floatArray.toArray();
    terrain.init();
    terrain.update();

    // set default terrain base texture if none is present
    TerrainTexture terrainTexture = terrain.getTerrainTexture();
    if (terrainTexture.getTexture(SplatTexture.Channel.BASE) == null) {
        MTexture base = new MTexture();
        base.setId(-1);
        base.texture = TextureUtils.loadMipmapTexture(Gdx.files.internal("textures/terrain/chess.png"), true);
        terrainTexture.setSplatTexture(new SplatTexture(SplatTexture.Channel.BASE, base));
    }

    // load splat map if available
    SplatMap splatmap = terrainTexture.getSplatmap();
    if (splatmap != null) {
        String splatPath = FilenameUtils.concat(projectContext.path, splatmap.getPath());
        splatmap.loadPNG(Gdx.files.absolute(splatPath));
    }

    return terrain;
}

From source file:mobi.shad.s3lib.gfx.g3d.simpleobject.ObjectMesh.java

License:Apache License

/**
 * @param texture/*from  www . j a  v a  2s  . com*/
 * @param color
 * @param normal
 */
public ObjectMesh(boolean texture, boolean color, boolean normal) {

    this.hasTextureCoordinates = texture;
    this.hasNormal = normal;
    this.hasColor = color;
    vertexBuffer = new FloatArray();
    indicesBuffer = new ShortArray();
    initMesh();
}

From source file:org.tntstudio.utils.math.Polygon.java

License:Apache License

/** Constructs a new polygon with no vertices. */
public Polygon() {
    this.localVertices = new FloatArray();
}

From source file:org.tntstudio.utils.math.Polygon.java

License:Apache License

/** Constructs a new polygon from a float array of parts of vertex points.
 * //from   w w  w.  j a va2s.c o m
 * @param vertices an array where every even element represents the horizontal part of a point, and the following element
 *           representing the vertical part
 * 
 * @throws IllegalArgumentException if less than 6 elements, representing 3 points, are provided */
public Polygon(float[] vertices) {
    if (vertices.length < 6)
        throw new IllegalArgumentException("polygons must contain at least 3 points.");
    this.localVertices = new FloatArray();

    localVertices.items = vertices;
    localVertices.size = vertices.length;
    localVertices.ordered = true;

    getBoundingRectangle();

    origWidth = bounds.getWidth();
    origHeight = bounds.getHeight();
}