Example usage for com.badlogic.gdx.graphics Mesh Mesh

List of usage examples for com.badlogic.gdx.graphics Mesh Mesh

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Mesh Mesh.

Prototype

public Mesh(VertexDataType type, boolean isStatic, int maxVertices, int maxIndices,
        VertexAttribute... attributes) 

Source Link

Document

Creates a new Mesh with the given attributes.

Usage

From source file:com.badlogic.gdx.physics.bullet.demo.simulationobjects.StaticPlaneSimulationObject.java

public StaticPlaneSimulationObject(Vector3 planeNormal, float planeConstant, float friction, int width,
        int height, Texture texture, boolean disposeTexture) {
    super();//from  w w w  .ja  v a  2  s  .co m

    this.texture = texture;
    this.disposeTexture = disposeTexture;

    this.mesh = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 3, "position"),
            new VertexAttribute(Usage.TextureCoordinates, 2, "texture"));

    this.mesh.setVertices(new float[] {
            // Bottom left, tex
            -width / 2f, -height / 2f, 0, 0, 0,
            // Bottom right, tex
            width / 2f, -height / 2f, 0, width, 0,
            // Top right, tex
            width / 2f, height / 2f, 0, width, height,
            // Top left, tex
            -width / 2f, height / 2f, 0, 0, height });
    this.mesh.setIndices(new short[] { 0, 1, 2, 0, 3, 2 });

    this.staticPlaneShape = new btStaticPlaneShape(planeNormal, planeConstant);

    initialize(this.staticPlaneShape, 0, -1, DEFAULT_START_TRANSFORM);
}

From source file:com.badlogic.gdx.tests.box2d.PhysicalCell.java

void buildMesh() {

    mesh = new Mesh(true, 4 * 4 * 4, 3 * 2 * 2 * 2, new VertexAttribute(Usage.Position, 2, "a_position"),
            new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));

    float vertices[] = new float[4 * 4 * 4];
    short indices[] = new short[3 * 2 * 2 * 2];

    Vector2 pos, tex;//  w  ww . j a v a2  s .c  om
    int v = 0;
    int ind = 0;

    // 4 x 1/4 cell

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            tex = buttomLeft[i][j];

            pos = bodies[i][j].getPosition();
            vertices[4 * (v + 0) + 0] = pos.x - (1 - i) * physicalSize.x / 6;
            vertices[4 * (v + 0) + 1] = pos.y - (1 - j) * physicalSize.y / 6;
            vertices[4 * (v + 0) + 2] = tex.x;
            vertices[4 * (v + 0) + 3] = tex.y;

            pos = bodies[i + 1][j].getPosition();
            vertices[4 * (v + 1) + 0] = pos.x - (0 - i) * physicalSize.x / 6;
            vertices[4 * (v + 1) + 1] = pos.y - (1 - j) * physicalSize.y / 6;
            vertices[4 * (v + 1) + 2] = tex.x + textureSize.x;
            vertices[4 * (v + 1) + 3] = tex.y;

            pos = bodies[i + 1][j + 1].getPosition();
            vertices[4 * (v + 2) + 0] = pos.x - (0 - i) * physicalSize.x / 6;
            vertices[4 * (v + 2) + 1] = pos.y - (0 - j) * physicalSize.y / 6;
            vertices[4 * (v + 2) + 2] = tex.x + textureSize.x;
            vertices[4 * (v + 2) + 3] = tex.y - textureSize.y; // rrrr!!               

            pos = bodies[i][j + 1].getPosition();
            vertices[4 * (v + 3) + 0] = pos.x - (1 - i) * physicalSize.x / 6;
            vertices[4 * (v + 3) + 1] = pos.y - (0 - j) * physicalSize.y / 6;
            vertices[4 * (v + 3) + 2] = tex.x;
            vertices[4 * (v + 3) + 3] = tex.y - textureSize.y; // rrrr!!               

            // two triangles
            indices[ind++] = (short) v;
            indices[ind++] = (short) (v + 1);
            indices[ind++] = (short) (v + 2);

            indices[ind++] = (short) v;
            indices[ind++] = (short) (v + 2);
            indices[ind++] = (short) (v + 3);

            v += 4;

        }
    }

    //Gdx.app.error("", "x = " + vertices[0] + " , y = " + vertices[1]);

    mesh.setVertices(vertices);
    mesh.setIndices(indices);

}

From source file:com.badlogic.gdx.tests.g3d.voxel.VoxelWorld.java

License:Apache License

public VoxelWorld(TextureRegion[] tiles, int chunksX, int chunksY, int chunksZ) {
    this.tiles = tiles;
    this.chunks = new VoxelChunk[chunksX * chunksY * chunksZ];
    this.chunksX = chunksX;
    this.chunksY = chunksY;
    this.chunksZ = chunksZ;
    this.numChunks = chunksX * chunksY * chunksZ;
    this.voxelsX = chunksX * CHUNK_SIZE_X;
    this.voxelsY = chunksY * CHUNK_SIZE_Y;
    this.voxelsZ = chunksZ * CHUNK_SIZE_Z;
    int i = 0;//from ww  w  .  jav  a2s  .  c o  m
    for (int y = 0; y < chunksY; y++) {
        for (int z = 0; z < chunksZ; z++) {
            for (int x = 0; x < chunksX; x++) {
                VoxelChunk chunk = new VoxelChunk(CHUNK_SIZE_X, CHUNK_SIZE_Y, CHUNK_SIZE_Z);
                chunk.offset.set(x * CHUNK_SIZE_X, y * CHUNK_SIZE_Y, z * CHUNK_SIZE_Z);
                chunks[i++] = chunk;
            }
        }
    }
    int len = CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z * 6 * 6 / 3;
    short[] indices = new short[len];
    short j = 0;
    for (i = 0; i < len; i += 6, j += 4) {
        indices[i + 0] = (short) (j + 0);
        indices[i + 1] = (short) (j + 1);
        indices[i + 2] = (short) (j + 2);
        indices[i + 3] = (short) (j + 2);
        indices[i + 4] = (short) (j + 3);
        indices[i + 5] = (short) (j + 0);
    }
    this.meshes = new Mesh[chunksX * chunksY * chunksZ];
    for (i = 0; i < meshes.length; i++) {
        meshes[i] = new Mesh(true, CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z * 6 * 4,
                CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z * 36 / 3, VertexAttribute.Position(),
                VertexAttribute.Normal());
        meshes[i].setIndices(indices);
    }
    this.dirty = new boolean[chunksX * chunksY * chunksZ];
    for (i = 0; i < dirty.length; i++)
        dirty[i] = true;

    this.numVertices = new int[chunksX * chunksY * chunksZ];
    for (i = 0; i < numVertices.length; i++)
        numVertices[i] = 0;

    this.vertices = new float[VoxelChunk.VERTEX_SIZE * 6 * CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z];
    this.materials = new Material[chunksX * chunksY * chunksZ];
    for (i = 0; i < materials.length; i++) {
        materials[i] = new Material(new ColorAttribute(ColorAttribute.Diffuse, MathUtils.random(0.5f, 1f),
                MathUtils.random(0.5f, 1f), MathUtils.random(0.5f, 1f), 1));
    }
}

From source file:com.badlogic.gdx.tests.gles2.MipMap2D.java

License:Apache License

@Override
public void create() {
    String vertexShader = "uniform float u_offset;      \n" + "attribute vec4 a_position;   \n"
            + "attribute vec2 a_texCoord;   \n" + "varying vec2 v_texCoord;     \n"
            + "void main()                  \n" + "{                            \n"
            + "   gl_Position = a_position; \n" + "   gl_Position.x += u_offset;\n"
            + "   v_texCoord = a_texCoord;  \n" + "}                            \n";
    String fragmentShader = "#ifdef GL_ES\n" + "precision mediump float;\n" + "#endif\n"
            + "varying vec2 v_texCoord;                            \n"
            + "uniform sampler2D s_texture;                        \n"
            + "void main()                                         \n"
            + "{                                                   \n"
            + "  gl_FragColor = texture2D( s_texture, v_texCoord );\n"
            + "}                                                   \n";
    shader = new ShaderProgram(vertexShader, fragmentShader);
    mesh = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 4, "a_position"),
            new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord"));
    float[] vertices = { -0.5f, 0.5f, 0.0f, 1.5f, // Position 0
            0.0f, 0.0f, // TexCoord 0
            -0.5f, -0.5f, 0.0f, 0.75f, // Position 1
            0.0f, 1.0f, // TexCoord 1
            0.5f, -0.5f, 0.0f, 0.75f, // Position 2
            1.0f, 1.0f, // TexCoord 2
            0.5f, 0.5f, 0.0f, 1.5f, // Position 3
            1.0f, 0.0f // TexCoord 3
    };/* w  w  w . ja  v a  2 s  . com*/
    short[] indices = { 0, 1, 2, 0, 2, 3 };
    mesh.setVertices(vertices);
    mesh.setIndices(indices);
    createTexture();
}

From source file:com.badlogic.gdx.tests.lw.WaterRipplesLW.java

License:Apache License

@Override
public void create() {

    camera = new PerspectiveCamera(90, Gdx.graphics.getWidth(), Gdx.graphics.getWidth());
    camera.position.set((WIDTH) / 2.0f, (HEIGHT) / 2.0f, WIDTH / 2.0f);
    camera.near = 0.1f;/*from  w w w  . j  ava 2 s .com*/
    camera.far = 1000;
    last = new float[WIDTH + 1][HEIGHT + 1];
    curr = new float[WIDTH + 1][HEIGHT + 1];
    intp = new float[WIDTH + 1][HEIGHT + 1];
    vertices = new float[(WIDTH + 1) * (HEIGHT + 1) * 5];
    mesh = new Mesh(false, (WIDTH + 1) * (HEIGHT + 1), WIDTH * HEIGHT * 6,
            new VertexAttribute(VertexAttributes.Usage.Position, 3, "a_Position"),
            new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords"));
    texture = new Texture(Gdx.files.internal("data/stones.jpg"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    createIndices();
    updateVertices(curr);
    initialized = true;

    batch = new SpriteBatch();
    Gdx.input.setInputProcessor(this);
    // font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);
}

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

@Override
public void create() {

    camera = new PerspectiveCamera();
    camera.getPosition().set((WIDTH) / 2.0f, (HEIGHT) / 2.0f, WIDTH / 2.0f);
    camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getWidth());
    camera.setFov(90);//from  w w  w . j  a  v  a 2 s  .co  m
    camera.setNear(0.1f);
    camera.setFar(1000);
    last = new float[WIDTH + 1][HEIGHT + 1];
    curr = new float[WIDTH + 1][HEIGHT + 1];
    intp = new float[WIDTH + 1][HEIGHT + 1];
    vertices = new float[(WIDTH + 1) * (HEIGHT + 1) * 5];
    mesh = new Mesh(false, (WIDTH + 1) * (HEIGHT + 1), WIDTH * HEIGHT * 6,
            new VertexAttribute(VertexAttributes.Usage.Position, 3, "a_Position"),
            new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords"));
    texture = new Texture(Gdx.files.internal("data/stones.jpg"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    createIndices();
    updateVertices(curr);
    initialized = true;

    batch = new SpriteBatch();
    Gdx.input.setInputProcessor(this);
    //font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);
}

From source file:com.badlogic.invaders.simulation.Simulation.java

License:Apache License

private void populate() {
    ObjLoader objLoader = new ObjLoader();
    shipModel = objLoader.loadModel(Gdx.files.internal("data/ship.obj"));
    invaderModel = objLoader.loadModel(Gdx.files.internal("data/invader.obj"));
    blockModel = objLoader.loadModel(Gdx.files.internal("data/block.obj"));
    shotModel = objLoader.loadModel(Gdx.files.internal("data/shot.obj"));

    final Texture shipTexture = new Texture(Gdx.files.internal("data/ship.png"), Format.RGB565, true);
    shipTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
    final Texture invaderTexture = new Texture(Gdx.files.internal("data/invader.png"), Format.RGB565, true);
    invaderTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
    shipModel.materials.get(0).set(TextureAttribute.createDiffuse(shipTexture));
    invaderModel.materials.get(0).set(TextureAttribute.createDiffuse(invaderTexture));

    ((ColorAttribute) blockModel.materials.get(0).get(ColorAttribute.Diffuse)).color.set(0, 0, 1, 0.5f);
    blockModel.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));

    shotModel.materials.get(0).set(ColorAttribute.createDiffuse(1, 1, 0, 1f));

    final Texture explosionTexture = new Texture(Gdx.files.internal("data/explode.png"), Format.RGBA4444, true);
    explosionTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

    final Mesh explosionMesh = new Mesh(true, 4 * 16, 6 * 16,
            new VertexAttribute(Usage.Position, 3, "a_position"),
            new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord0"));

    float[] vertices = new float[4 * 16 * (3 + 2)];
    short[] indices = new short[6 * 16];
    int idx = 0;/* w  w w.j  a  va  2s.  c o m*/
    int index = 0;
    for (int row = 0; row < 4; row++) {
        for (int column = 0; column < 4; column++) {
            vertices[idx++] = 1;
            vertices[idx++] = 1;
            vertices[idx++] = 0;
            vertices[idx++] = 0.25f + column * 0.25f;
            vertices[idx++] = 0 + row * 0.25f;

            vertices[idx++] = -1;
            vertices[idx++] = 1;
            vertices[idx++] = 0;
            vertices[idx++] = 0 + column * 0.25f;
            vertices[idx++] = 0 + row * 0.25f;

            vertices[idx++] = -1;
            vertices[idx++] = -1;
            vertices[idx++] = 0;
            vertices[idx++] = 0f + column * 0.25f;
            vertices[idx++] = 0.25f + row * 0.25f;

            vertices[idx++] = 1;
            vertices[idx++] = -1;
            vertices[idx++] = 0;
            vertices[idx++] = 0.25f + column * 0.25f;
            vertices[idx++] = 0.25f + row * 0.25f;

            final int t = (4 * row + column) * 4;
            indices[index++] = (short) (t);
            indices[index++] = (short) (t + 1);
            indices[index++] = (short) (t + 2);
            indices[index++] = (short) (t);
            indices[index++] = (short) (t + 2);
            indices[index++] = (short) (t + 3);
        }
    }

    explosionMesh.setVertices(vertices);
    explosionMesh.setIndices(indices);

    explosionModel = ModelBuilder.createFromMesh(explosionMesh, GL20.GL_TRIANGLES,
            new Material(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA),
                    TextureAttribute.createDiffuse(explosionTexture)));

    ship = new Ship(shipModel);
    ship.transform.rotate(0, 1, 0, 180);

    for (int row = 0; row < 4; row++) {
        for (int column = 0; column < 8; column++) {
            Invader invader = new Invader(invaderModel, -PLAYFIELD_MAX_X / 2 + column * 2f, 0,
                    PLAYFIELD_MIN_Z + row * 2f);
            invaders.add(invader);
        }
    }

    for (int shield = 0; shield < 3; shield++) {
        blocks.add(new Block(blockModel, -10 + shield * 10 - 1, 0, -2));
        blocks.add(new Block(blockModel, -10 + shield * 10 - 1, 0, -3));
        blocks.add(new Block(blockModel, -10 + shield * 10 + 0, 0, -3));
        blocks.add(new Block(blockModel, -10 + shield * 10 + 1, 0, -3));
        blocks.add(new Block(blockModel, -10 + shield * 10 + 1, 0, -2));
    }
}

From source file:com.badlogic.rtm.LevelRenderer.java

License:Apache License

private void load() {
    try {//from   ww w . java 2 s  . com
        tiles = new Texture(Gdx.files.internal("data/tiles-3.png"));
        tiles.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest);

        TextureAtlas atlas = new TextureAtlas();
        for (int i = 0; i < 12; i++) {
            TextureRegion region = new TextureRegion(tiles, i % 4 * 64 + 1, i / 4 * 64 + 1, 64, 64);
            atlas.addRegion("" + i, region);
        }
        float uSize = 62.0f / 256.0f;
        float vSize = 62.0f / 256.0f;

        BufferedReader reader = new BufferedReader(
                new InputStreamReader(Gdx.files.internal("data/level.map").read()));
        String line = reader.readLine();
        String tokens[] = line.split(",");
        camera.position.set(Float.parseFloat(tokens[0]), 0, Float.parseFloat(tokens[1]));
        int floors = Integer.parseInt(reader.readLine());
        int walls = Integer.parseInt(reader.readLine());
        float[] floorVertices = new float[floors * 20];
        float[] wallVertices = new float[walls * 20];
        short[] floorIndices = new short[floors * 6];
        short[] wallIndices = new short[walls * 6];

        int idx = 0;
        for (int i = 0, j = 0; i < floors; i++) {
            for (int k = 0; k < 4; k++) {
                tokens = reader.readLine().split(",");
                floorVertices[j++] = Float.parseFloat(tokens[0]);
                floorVertices[j++] = Float.parseFloat(tokens[1]);
                floorVertices[j++] = Float.parseFloat(tokens[2]);
                floorVertices[j++] = 0;
                floorVertices[j++] = 0;
            }

            short startIndex = (short) (i * 4);
            floorIndices[idx++] = startIndex;
            floorIndices[idx++] = (short) (startIndex + 1);
            floorIndices[idx++] = (short) (startIndex + 2);
            floorIndices[idx++] = (short) (startIndex + 2);
            floorIndices[idx++] = (short) (startIndex + 3);
            floorIndices[idx++] = startIndex;

            int type = Integer.parseInt(reader.readLine());
            String textureId = reader.readLine();
            TextureRegion region = atlas.findRegion(textureId);
            float u = region.getU();
            float v = region.getV();

            floorVertices[j - 2] = u + uSize;
            floorVertices[j - 1] = v;
            floorVertices[j - 2 - 5] = u + uSize;
            floorVertices[j - 1 - 5] = v + vSize;
            floorVertices[j - 2 - 10] = u;
            floorVertices[j - 1 - 10] = v + vSize;
            floorVertices[j - 2 - 15] = u;
            floorVertices[j - 1 - 15] = v;
        }

        idx = 0;
        short startIndex = 0;
        for (int i = 0, j = 0; i < walls; i++) {
            tokens = reader.readLine().split(",");
            if (!tokens[1].equals("0")) {
                for (int k = 0; k < 4; k++) {
                    wallVertices[j++] = Float.parseFloat(tokens[0]);
                    wallVertices[j++] = Float.parseFloat(tokens[1]);
                    wallVertices[j++] = Float.parseFloat(tokens[2]);
                    wallVertices[j++] = 0;
                    wallVertices[j++] = 0;
                    if (k < 3)
                        tokens = reader.readLine().split(",");
                }

                wallIndices[idx++] = startIndex;
                wallIndices[idx++] = (short) (startIndex + 1);
                wallIndices[idx++] = (short) (startIndex + 2);
                wallIndices[idx++] = (short) (startIndex + 2);
                wallIndices[idx++] = (short) (startIndex + 3);
                wallIndices[idx++] = startIndex;
                startIndex += 4;

                int type = Integer.parseInt(reader.readLine());
                String textureId = reader.readLine();
                TextureRegion region = atlas.findRegion(textureId);
                float u = region.getU();
                float v = region.getV();

                wallVertices[j - 2] = u + uSize;
                wallVertices[j - 1] = v;
                wallVertices[j - 2 - 5] = u + vSize;
                wallVertices[j - 1 - 5] = v + vSize;
                wallVertices[j - 2 - 10] = u;
                wallVertices[j - 1 - 10] = v + vSize;
                wallVertices[j - 2 - 15] = u;
                wallVertices[j - 1 - 15] = v;
            } else {
                reader.readLine();
                reader.readLine();
                reader.readLine();

                int type = Integer.parseInt(reader.readLine());
                int textureId = Integer.parseInt(reader.readLine());
            }
        }

        floorMesh = new Mesh(true, floors * 4, floors * 6,
                new VertexAttribute(VertexAttributes.Usage.Position, 3, "a_position"),
                new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoord"));
        floorMesh.setVertices(floorVertices);
        floorMesh.setIndices(floorIndices);

        wallMesh = new Mesh(true, walls * 4, walls * 6,
                new VertexAttribute(VertexAttributes.Usage.Position, 3, "a_position"),
                new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoord"));

        wallMesh.setVertices(wallVertices);
        wallMesh.setIndices(wallIndices);

        reader.close();
    } catch (IOException ex) {
        throw new GdxRuntimeException(ex);
    }
}

From source file:com.box2dLight.box2dLight.LightMap.java

License:Apache License

private Mesh createLightMapMesh() {
    // vertex coord
    verts[X1] = -1;/*  w ww .  j a  v a 2s.  com*/
    verts[Y1] = -1;
    verts[Z1] = 0;

    verts[X2] = 1;
    verts[Y2] = -1;
    verts[Z2] = 0;

    verts[X3] = 1;
    verts[Y3] = 1;
    verts[Z3] = 0;

    verts[X4] = -1;
    verts[Y4] = 1;
    verts[Z4] = 0;

    // tex coords
    verts[U1] = 0f;
    verts[V1] = 0f;

    verts[U2] = 1f;
    verts[V2] = 0f;

    verts[U3] = 1f;
    verts[V3] = 1f;

    verts[U4] = 0f;
    verts[V4] = 1f;

    Mesh tmpMesh = new Mesh(true, 4, 0, new VertexAttribute(Usage.Position, 3, "a_position"),
            new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord"));

    tmpMesh.setVertices(verts);
    return tmpMesh;

}

From source file:com.davidykay.shootout.Renderer.java

License:Apache License

public Renderer(Application app) {
    try {//from w  w  w.  j  ava 2  s . co  m
        spriteBatch = new SpriteBatch();

        InputStream in = Gdx.files.internal("data/emplacement.obj").read();
        shipMesh = ModelLoaderOld.loadObj(in);
        in.close();

        in = Gdx.files.internal("data/moon.obj").read();
        moonMesh = ModelLoaderOld.loadObj(in);
        in.close();

        //in = Gdx.files.internal("data/alien.obj").read();
        in = Gdx.files.internal("data/ufo.obj").read();
        alienMesh = ModelLoaderOld.loadObj(in);
        in.close();

        in = Gdx.files.internal("data/block.obj").read();
        blockMesh = ModelLoaderOld.loadObj(in);
        in.close();

        //in = Gdx.files.internal("data/shot.obj").read();
        //in = Gdx.files.internal("data/laser.obj").read();
        in = Gdx.files.internal("data/bomb.obj").read();
        shotMesh = ModelLoaderOld.loadObj(in);
        in.close();

        rayMesh = shotMesh;

        moonTexture = new Texture(Gdx.files.internal("data/moon.png"), Format.RGB565, true);
        moonTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
        shipTexture = new Texture(Gdx.files.internal("data/battery.png"), Format.RGB565, true);
        shipTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

        //alienTexture = new Texture(Gdx.files.internal("data/alien.png"), Format.RGB565, true);
        alienTexture = new Texture(Gdx.files.internal("data/ufo.png"), Format.RGB565, true);
        alienTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
        //alienTexture.setFilter(TextureFilter.MipMap, TextureFilter.MipMap);
        //alienTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        backgroundTexture = new Texture(Gdx.files.internal("data/starfield512.png"), Format.RGB565, true);
        backgroundTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
        earthTexture = new Texture(Gdx.files.internal("data/marble128.jpg"), Format.RGB565, true);
        earthTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

        explosionTexture = new Texture(Gdx.files.internal("data/explode.png"), Format.RGBA4444, true);
        explosionTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
        bombExplosionTexture = new Texture(Gdx.files.internal("data/explode-bomb.png"), Format.RGBA4444, true);
        bombExplosionTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

        explosionMesh = new Mesh(true, 4 * 16, 0, new VertexAttribute(Usage.Position, 3, "a_position"),
                new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord"));

        float[] vertices = new float[4 * 16 * (3 + 2)];
        int idx = 0;
        for (int row = 0; row < 4; row++) {
            for (int column = 0; column < 4; column++) {
                vertices[idx++] = 1;
                vertices[idx++] = 1;
                vertices[idx++] = 0;
                vertices[idx++] = 0.25f + column * 0.25f;
                vertices[idx++] = 0 + row * 0.25f;

                vertices[idx++] = -1;
                vertices[idx++] = 1;
                vertices[idx++] = 0;
                vertices[idx++] = 0 + column * 0.25f;
                vertices[idx++] = 0 + row * 0.25f;

                vertices[idx++] = -1;
                vertices[idx++] = -1;
                vertices[idx++] = 0;
                vertices[idx++] = 0f + column * 0.25f;
                vertices[idx++] = 0.25f + row * 0.25f;

                vertices[idx++] = 1;
                vertices[idx++] = -1;
                vertices[idx++] = 0;
                vertices[idx++] = 0.25f + column * 0.25f;
                vertices[idx++] = 0.25f + row * 0.25f;
            }
        }

        explosionMesh.setVertices(vertices);
        font = new BitmapFont(Gdx.files.internal(ShootOut.FONT10_FNT), Gdx.files.internal(ShootOut.FONT10_PNG),
                false);

        camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}