Example usage for com.badlogic.gdx.graphics GL20 GL_SRC_ALPHA

List of usage examples for com.badlogic.gdx.graphics GL20 GL_SRC_ALPHA

Introduction

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

Prototype

int GL_SRC_ALPHA

To view the source code for com.badlogic.gdx.graphics GL20 GL_SRC_ALPHA.

Click Source Link

Usage

From source file:com.lyeeedar.Roguelike3D.Game.LevelObjects.LevelObject.java

License:Open Source License

public static LevelObject checkObject(AbstractObject ao, float x, float y, float z, Level level,
        MonsterEvolver evolver) {/*from   w ww  .ja va  2  s  .  c  o m*/
    LevelObject lo = null;

    if (ao.type == ObjectType.STATIC) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Static(ao, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Static(ao, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Static(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao);

        }
    } else if (ao.type == ObjectType.DOOR_UNLOCKED) {
        lo = new Door(ao, new Color(1, 1, 1, 1), "tex+", (ao.x) * GameData.BLOCK_SIZE, 0,
                (ao.z) * GameData.BLOCK_SIZE, 1.0f, GL20.GL_TRIANGLES, "cube", "1", "1", "1");
    } else if (ao.type == ObjectType.FIRE_CAMP) {

        lo = new Static(false, x, y, z, ao);
        lo.shortDesc = ao.shortDesc;
        lo.longDesc = ao.longDesc;

        ParticleEffect effect = new ParticleEffect(15);
        ParticleEmitter flame = new ParticleEmitter(2, 2, 0.01f, 1.0f, 0.0f, 1.0f, 0, GL20.GL_SRC_ALPHA,
                GL20.GL_ONE, "f", "name");
        flame.createBasicEmitter(2, 1, new Color(0.8f, 0.9f, 0.1f, 1.0f), new Color(1.0f, 0.0f, 0.0f, 1.0f), 0,
                3.5f, 0);
        flame.setSpriteTimeline(true, new float[] { 0, 0 }, new float[] { 2, 2 });
        flame.addLight(true, 0.07f, 0.5f, Color.ORANGE, true, 0, 2, 0);
        flame.calculateParticles();
        effect.addEmitter(flame, 2, 0f, 2);
        effect.create();

        lo.addParticleEffect(effect);
    } else if (ao.type == ObjectType.FIRE_TORCH) {
        //
        //         lo = new Static(false, x, y, z, ao);
        //         lo.shortDesc = ao.shortDesc;
        //         lo.longDesc = ao.longDesc;
        //         
        //         ParticleEmitter p = new ParticleEmitter(x-0.3f, y+1.5f, z-0.3f, 1, 1, 1, 0.05f, 1);
        //         p.setTexture("texf", new Vector3(0.0f, 2.0f, 0.0f), new Colour(0.7f, 0.9f, 0.3f, 1.0f), new Colour(1.0f, 0.0f, 0.0f, 1.0f), true, 0.5f, 1.5f, false, true);
        //         
        //         level.getParticleEmitters().add(p);
        //         lo.addParticleEmitter(p);
    } else if (ao.type == ObjectType.STAIR_UP) {
        String texture = ao.texture;
        Color colour = ao.colour;
        if (ao.modelType.equalsIgnoreCase("model")) {
            lo = new Stair(ao, GameData.getCurrentLevelContainer().getUpLevel(), colour, texture,
                    (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao.modelScale,
                    GL20.GL_TRIANGLES, "file", ao.modelName);
        } else if (ao.modelType.equalsIgnoreCase("cube")) {
            lo = new Stair(ao, GameData.getCurrentLevelContainer().getUpLevel(), colour, texture,
                    (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao.modelScale,
                    GL20.GL_TRIANGLES, "cube", "" + ao.modelDimensions[0], "" + ao.modelDimensions[1],
                    "" + ao.modelDimensions[2]);
        }
    } else if (ao.type == ObjectType.STAIR_DOWN) {
        String texture = ao.texture;
        Color colour = ao.colour;
        if (ao.modelType.equalsIgnoreCase("model")) {
            lo = new Stair(ao, GameData.getCurrentLevelContainer().getDownLevel(), colour, texture,
                    (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao.modelScale,
                    GL20.GL_TRIANGLES, "file", ao.modelName);
        } else if (ao.modelType.equalsIgnoreCase("cube")) {
            lo = new Stair(ao, GameData.getCurrentLevelContainer().getDownLevel(), colour, texture,
                    (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao.modelScale,
                    GL20.GL_TRIANGLES, "cube", "" + ao.modelDimensions[0], "" + ao.modelDimensions[1],
                    "" + ao.modelDimensions[2]);
        }
    } else if (ao.type == ObjectType.PLAYER_PLACER) {
        lo = new PlayerPlacer(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao);
    } else if (ao.type == ObjectType.SPAWNER_0) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Spawner(ao, 0, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Spawner(ao, 0, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Spawner(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao, 0,
                    evolver);
        }
    } else if (ao.type == ObjectType.SPAWNER_1) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Spawner(ao, 1, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Spawner(ao, 1, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Spawner(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao, 1,
                    evolver);
        }
    } else if (ao.type == ObjectType.SPAWNER_2) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Spawner(ao, 2, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Spawner(ao, 2, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Spawner(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao, 2,
                    evolver);
        }
    } else if (ao.type == ObjectType.SPAWNER_3) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Spawner(ao, 3, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Spawner(ao, 3, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Spawner(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao, 3,
                    evolver);
        }
    } else if (ao.type == ObjectType.SPAWNER_4) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Spawner(ao, 4, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Spawner(ao, 4, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Spawner(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao, 4,
                    evolver);
        }
    } else if (ao.type == ObjectType.SPAWNER_5) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Spawner(ao, 5, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Spawner(ao, 5, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Spawner(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao, 5,
                    evolver);
        }
    } else if (ao.type == ObjectType.SPAWNER_6) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Spawner(ao, 6, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Spawner(ao, 6, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Spawner(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao, 6,
                    evolver);
        }
    } else if (ao.type == ObjectType.SPAWNER_7) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Spawner(ao, 7, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Spawner(ao, 7, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Spawner(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao, 7,
                    evolver);
        }
    } else if (ao.type == ObjectType.SPAWNER_8) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Spawner(ao, 8, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Spawner(ao, 8, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Spawner(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao, 8,
                    evolver);
        }
    } else if (ao.type == ObjectType.SPAWNER_9) {
        if (ao.visible) {
            String texture = ao.texture;
            Color colour = ao.colour;
            if (ao.modelType.equalsIgnoreCase("file")) {
                lo = new Spawner(ao, 9, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "file", ao.modelName);
            } else if (ao.modelType.equalsIgnoreCase("cube")) {
                lo = new Spawner(ao, 9, evolver, colour, texture, (ao.x) * GameData.BLOCK_SIZE, 0,
                        (ao.z) * GameData.BLOCK_SIZE, ao.modelScale, GL20.GL_TRIANGLES, "cube",
                        "" + ao.modelDimensions[0], "" + ao.modelDimensions[1], "" + ao.modelDimensions[2]);
            }
        } else {
            lo = new Spawner(false, (ao.x) * GameData.BLOCK_SIZE, 0, (ao.z) * GameData.BLOCK_SIZE, ao, 9,
                    evolver);
        }
    }

    return lo;
}

From source file:com.mob.client.artemis.systems.render.GridRenderingSystem.java

License:Open Source License

@Override
protected void begin() {
    super.begin();

    // Inicializamos el batch y lo necesario para renderizar
    Gdx.gl.glEnable(GL20.GL_BLEND);//w w w  .j av a 2  s  .  co  m
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    this.mCameraSystem.camera.update();
    this.mShapeRenderer.setProjectionMatrix(this.mCameraSystem.camera.combined);
    this.mShapeRenderer.begin();

}

From source file:com.mob.dao.objects.Map.java

License:Open Source License

/**
 * Renders a map layer to it's internal FrameBuffer Object
 *
 * @param layer/*from   w  ww  .  j  a v a  2  s  .c  o  m*/
 * @return void
 */
public void renderLayerToBuffer(int layer) {

    int width = (int) (Map.MAX_MAP_SIZE_WIDTH * Map.TILE_PIXEL_WIDTH);
    int height = (int) (Map.MAX_MAP_SIZE_HEIGHT * Map.TILE_PIXEL_HEIGHT);

    OrthographicCamera camera = new OrthographicCamera(width, height);
    camera.setToOrtho(true, width, height);

    FrameBuffer fbo = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, false);
    SpriteBatch sb = new SpriteBatch();
    sb.setProjectionMatrix(camera.combined);
    fbo.begin();

    sb.enableBlending();
    Gdx.gl.glBlendFuncSeparate(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_ONE,
            GL20.GL_ONE_MINUS_SRC_ALPHA);
    Gdx.gl.glViewport(0, 0, width, height);
    Gdx.gl.glClearColor(0, 0, 0, 0);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    sb.begin();
    this.renderLayer(sb, layer);
    sb.end();

    fbo.end();
    this.bufferedLayer = fbo.getColorBufferTexture();
}

From source file:com.mygdx.game.debugdrawers.NavMeshDebugDrawer.java

License:Apache License

public void drawNavMesh(MyShapeRenderer shapeRenderer, SpriteBatch spriteBatch, NavMesh navMesh,
        GameCharacter character, Bits visibleLayers, Camera camera, BitmapFont font) {

    this.visibleLayers = visibleLayers;
    this.shapeRenderer = shapeRenderer;
    this.navMesh = navMesh;

    if (shapeRenderer.isDrawing()) {
        shapeRenderer.end();/*  ww  w  . j av a 2 s  .  co m*/
    }

    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    shapeRenderer.begin(MyShapeRenderer.ShapeType.Line);
    drawNavMeshTriangles();
    if (character != null && character.steerer instanceof FollowPathSteerer) {
        FollowPathSteerer fpSteerer = (FollowPathSteerer) character.steerer;
        drawPathTriangles(fpSteerer.navMeshGraphPath, character.getCurrentTriangle());
        if (fpSteerer.navMeshPointPath.getSize() > 0) {
            drawPathPoints(fpSteerer.navMeshPointPath);
        }
        drawClosestPointDebug(character);
    }
    shapeRenderer.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);

    drawNavMeshIndices(spriteBatch, camera, font);
}

From source file:com.mygdx.game.simulation.Simulation.java

License:Apache License

private void populate() {
    ObjLoader objLoader = new ObjLoader();

    for (int i = 0; i < MAX_SHIPS; i++) {
        shipModels[i] = objLoader.loadModel(Gdx.files.internal("data/ship.obj"));
    }//from   w w  w .j  a  v a2 s. c  o m
    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 shipTexture2 = new Texture(Gdx.files.internal("data/ship.png"), Format.RGB565, true);
    shipTexture2.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);

    for (int i = 0; i < MAX_SHIPS; i++) {
        shipModels[i].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;
    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);

    Material explosionMeshMaterial = new Material(
            new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA),
            TextureAttribute.createDiffuse(explosionTexture));
    explosionModel = new Model();
    MeshPart meshPart = new MeshPart();
    meshPart.id = "part1";
    meshPart.offset = 0;
    meshPart.size = explosionMesh.getNumIndices();
    meshPart.primitiveType = GL20.GL_TRIANGLES;
    meshPart.mesh = explosionMesh;

    NodePart partMaterial = new NodePart();
    partMaterial.material = explosionMeshMaterial;
    partMaterial.meshPart = meshPart;
    Node node = new Node();
    node.id = "node1";
    node.parts.add(partMaterial);

    explosionModel.meshes.add(explosionMesh);
    explosionModel.materials.add(explosionMeshMaterial);
    explosionModel.nodes.add(node);
    explosionModel.meshParts.add(meshPart);
    explosionModel.manageDisposable(explosionMesh);

    for (int i = 0; i < MAX_SHIPS; i++) {
        ships[i] = new Ship(shipModels[i]);
        ships[i].transform.rotate(1, 0, 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.nsoft.boxuniverse.misc.BaseMaterial.java

License:Open Source License

public BaseMaterial(String name) {

    materialName = name;//from www. java 2  s  . c  o m
    material = materials.materials.get(name);
    t = new Texture(Gdx.files.internal(material.path));

    RealMaterial = new Material(TextureAttribute.createDiffuse(t)); //Create GD3 Material

    if (material.hasAlpha)
        RealMaterial.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)); //Set Alpha
    worldmaterials.put(name, this); // Add Material

    System.out.println("New Material Created");
}

From source file:com.o2d.pkayjava.editor.plugins.ninepatch.EditingZone.java

License:Apache License

public void drawBg(Batch batch, float parentAlpha) {
    batch.end();// w  w  w .  j av  a2s  . c  om
    Gdx.gl.glLineWidth(1.0f);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
    Matrix4 matrix = batch.getTransformMatrix();
    shapeRenderer.setTransformMatrix(matrix);

    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    BG.a = parentAlpha;
    shapeRenderer.setColor(BG);
    shapeRenderer.rect(getX(), getY(), getWidth(), getHeight());
    shapeRenderer.end();

    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
    batch.setColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, Color.WHITE.a * parentAlpha);
}

From source file:com.o2d.pkayjava.editor.plugins.ninepatch.EditingZone.java

License:Apache License

public void drawSplits(Batch batch, float parentAlpha) {
    batch.end();//from www.j a  v a 2s .co m
    Gdx.gl.glLineWidth(1.0f);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
    Matrix4 matrix = batch.getTransformMatrix();
    shapeRenderer.setTransformMatrix(matrix);

    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);

    // left, right, top , bottom
    Color guideColor = new Color(GUIDE_COLOR);
    guideColor.a *= parentAlpha;
    Color overColor = new Color(OVER_GUIDE_COLOR);
    overColor.a *= parentAlpha;

    splitPositions[0] = shift.x + getWidth() / 2f + (-texture.getRegionWidth() / 2f + splits[0]) * currZoom;
    splitPositions[1] = shift.x + getWidth() / 2f + (texture.getRegionWidth() / 2f - splits[1]) * currZoom;
    splitPositions[2] = shift.y + getHeight() / 2f + (texture.getRegionHeight() / 2 - splits[2]) * currZoom;
    splitPositions[3] = shift.y + getHeight() / 2f + (-texture.getRegionHeight() / 2 + splits[3]) * currZoom;

    if (mouseOverSplit == 0)
        shapeRenderer.setColor(overColor);
    else
        shapeRenderer.setColor(guideColor);
    shapeRenderer.line(getX() + splitPositions[0], getY(), getX() + splitPositions[0], getY() + getHeight());

    if (mouseOverSplit == 1)
        shapeRenderer.setColor(overColor);
    else
        shapeRenderer.setColor(guideColor);
    shapeRenderer.line(getX() + splitPositions[1], getY(), getX() + splitPositions[1], getY() + getHeight());

    if (mouseOverSplit == 2)
        shapeRenderer.setColor(overColor);
    else
        shapeRenderer.setColor(guideColor);
    shapeRenderer.line(getX(), getY() + splitPositions[2], getX() + getWidth(), getY() + splitPositions[2]);

    if (mouseOverSplit == 3)
        shapeRenderer.setColor(overColor);
    else
        shapeRenderer.setColor(guideColor);
    shapeRenderer.line(getX(), getY() + splitPositions[3], getX() + getWidth(), getY() + splitPositions[3]);

    shapeRenderer.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
    batch.setColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, Color.WHITE.a * parentAlpha);
}

From source file:com.o2d.pkayjava.editor.view.ui.followers.PolygonFollower.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    if (polygonComponent != null && polygonComponent.vertices != null) {
        batch.end();//from w  ww.ja  v a 2  s.  co  m

        Gdx.gl.glLineWidth(1.7f);
        Gdx.gl.glEnable(GL20.GL_BLEND);
        Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

        shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
        Matrix4 matrix = batch.getTransformMatrix();
        matrix.scale(pixelsPerWU / runtimeCamera.zoom, pixelsPerWU / runtimeCamera.zoom, 1f);
        shapeRenderer.setTransformMatrix(matrix);

        drawTriangulatedPolygons();
        drawOutlines();
        drawPoints();

        Gdx.gl.glDisable(GL20.GL_BLEND);

        batch.begin();
    }
}

From source file:com.o2d.pkayjava.editor.view.ui.widget.actors.GridView.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    batch.end();/*from   www  . j  ava 2 s  .  c o  m*/

    OrthographicCamera uiCamera = (OrthographicCamera) Sandbox.getInstance().getUIStage().getCamera();

    Gdx.gl.glLineWidth(1.0f);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    shapeRenderer.setProjectionMatrix(uiCamera.projection);

    drawLines();

    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
    batch.setColor(Color.WHITE);

    OrthographicCamera runtimeCamera = Sandbox.getInstance().getCamera();
    batch.setProjectionMatrix(uiCamera.projection);
    zeroLabel.draw(batch, parentAlpha);
    zeroLabel.setX(-(runtimeCamera.position.x * pixelsPerWU) / runtimeCamera.zoom - 5 - zeroLabel.getWidth());
    zeroLabel.setY(-(runtimeCamera.position.y * pixelsPerWU) / runtimeCamera.zoom - zeroLabel.getHeight());
}