Example usage for com.badlogic.gdx.graphics.g3d.particles ParticleSystem get

List of usage examples for com.badlogic.gdx.graphics.g3d.particles ParticleSystem get

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g3d.particles ParticleSystem get.

Prototype

public static ParticleSystem get() 

Source Link

Usage

From source file:com.mygdx.game.scene.GameScene.java

License:Apache License

private GameObject spawnFromBlueprint(GameObjectBlueprint bp) {
    if (bp.pfx != null) {
        ParticleEffect originalEffect = assets.getAsset(bp.pfx, ParticleEffect.class);
        // we cannot use the originalEffect, we must make a copy each time we create new particle effect
        ParticleEffect effect = originalEffect.copy();
        particleEffects.add(effect);/*from  w w  w.ja va 2  s. c  o  m*/
        effect.translate(bp.position);
        effect.rotate(Vector3.X, 180);
        effect.init();
        effect.start();
        ParticleSystem particleSystem = ParticleSystem.get();
        particleSystem.add(effect);
        return null;
    }
    if (bp.model != null && bp.shape != null) {

        return spawnGameModelBody(bp, bp.position);

    } else if (bp.model == null && bp.shape != null) {
        InvisibleBody obj = new InvisibleBody(bp.name, bp.shape, bp.mass, bp.position, bp.rotation,
                bp.belongsToFlag, bp.collidesWithFlag, bp.callback, bp.noDeactivate);
        addGameObject(obj);
        return obj;

    } else if (bp.model != null) {
        GameModel obj = new GameModel(bp.model, bp.name, bp.position, bp.rotation, bp.scale);
        obj.visibleOnLayers.clear();
        obj.visibleOnLayers.or(bp.visibleOnLayers);
        addGameObject(obj);
        return obj;
    } else {
        throw new GdxRuntimeException("Could not read blueprint " + bp);
    }
}

From source file:com.mygdx.game.scene.GameScene.java

License:Apache License

public void dispose() {
    ParticleSystem particleSystem = ParticleSystem.get();
    for (ParticleEffect pfx : particleEffects) {
        particleSystem.remove(pfx);/*www  . ja  v  a 2 s . co m*/
        pfx.dispose();
    }
    particleEffects.clear();
    navMesh.dispose();
    for (Array<GameObject> objs : gameObjects.values()) {
        for (GameObject obj : objs) {
            obj.dispose();
        }
    }
    gameObjects.clear();
    assets.dispose();
}

From source file:net.osaris.exterminate.Assets.java

License:Apache License

public static void load() {

    loaded = false;/*from w ww . j av  a  2s.c  om*/

    System.out.println("Loading Assets");
    fonttexture = new Texture(Gdx.files.internal("data/skin/ext.png"), true); // true enables mipmaps
    fonttexture.setFilter(TextureFilter.MipMapLinearLinear, TextureFilter.Linear); // linear filtering in nearest mipmap image
    font = new BitmapFont(Gdx.files.internal("data/skin/ext.fnt"), new TextureRegion(fonttexture), false);

    UniVertexBufferObject.initBufferPool();
    Ground.prepare();

    fontShader = new ShaderProgram(Gdx.files.internal("net/osaris/exterminate/shaders/font.vertex.glsl"),
            Gdx.files.internal("net/osaris/exterminate/shaders/font.fragment.glsl"));
    if (!fontShader.isCompiled()) {
        Gdx.app.error("fontShader", "compilation failed:\n" + fontShader.getLog());
    }
    Assets.fontShader.begin();
    Assets.fontShader.setUniformf("smoothing", 1f / 11f);
    Assets.fontShader.end();

    SoundManager.musics[0] = Gdx.audio.newMusic(Gdx.files.internal("data/music/starbound.mp3"));

    //      SoundManager.ambient[0] = Gdx.audio.newMusic(Gdx.files.internal("data/music/ambient1.mp3"));
    //      SoundManager.ambient[1] = Gdx.audio.newMusic(Gdx.files.internal("data/music/ambient2.mp3"));

    SoundManager.boom = Gdx.audio.newSound(Gdx.files.internal("data/sounds/boom.mp3"));
    SoundManager.blam = Gdx.audio.newSound(Gdx.files.internal("data/sounds/woosh.mp3"));
    SoundManager.launch = Gdx.audio.newSound(Gdx.files.internal("data/sounds/launch4.mp3"));
    SoundManager.launch2 = Gdx.audio.newSound(Gdx.files.internal("data/sounds/launch5.mp3"));
    //   SoundManager.sounds[0] = Gdx.audio.newSound(Gdx.files.internal("data/sounds/extreminate1.mp3"));
    SoundManager.sounds[10] = Gdx.audio.newSound(Gdx.files.internal("data/sounds/extreminate2.mp3"));
    SoundManager.sounds[11] = Gdx.audio.newSound(Gdx.files.internal("data/sounds/extreminate3.mp3"));
    SoundManager.sounds[12] = Gdx.audio.newSound(Gdx.files.internal("data/sounds/destroy.mp3"));

    //      SoundManager.effect[SoundManager.VENT] = Gdx.audio.newMusic(Gdx.files.internal("data/sounds/vent.mp3"));

    // ParticleSystem is a singleton class, we get the instance instead of creating a new object:
    ParticleSystem particleSystem = ParticleSystem.get();
    billboardBatch = new BillboardParticleBatch();
    particleSystem.add(billboardBatch);

    if (assets == null)
        assets = new AssetManager();

    if (doneOnce) {
        assets.clear();
    }

    BitmapFontLoader.BitmapFontParameter param = new BitmapFontLoader.BitmapFontParameter();
    param.magFilter = Texture.TextureFilter.Linear;
    param.minFilter = Texture.TextureFilter.Linear;
    //   font = new BitmapFont(Gdx.files.internal("data/ex.fnt"), Gdx.files.internal("data/ex.png"), false);

    ParticleEffectLoader.ParticleEffectLoadParameter loadParam = new ParticleEffectLoader.ParticleEffectLoadParameter(
            particleSystem.getBatches());
    ParticleEffectLoader loader = new ParticleEffectLoader(new InternalFileHandleResolver());
    assets.setLoader(ParticleEffect.class, loader);
    assets.load("data/effects/boullefeu", ParticleEffect.class, loadParam);
    assets.load("data/effects/feu", ParticleEffect.class, loadParam);
    assets.load("data/effects/feuflamme", ParticleEffect.class, loadParam);

    assets.load("data/objs/shark.g3db", Model.class);
    assets.load("data/objs/missile2.g3db", Model.class);
    assets.load("data/objs/monster.g3db", Model.class);
    assets.load("data/objs/golem.g3db", Model.class);

    boolean wasgl3 = ExterminateGame.useGL3;
    InGame.loadShaders();
    if (wasgl3 && !ExterminateGame.useGL3) {
        InGame.loadShaders();
    }
    System.out.println("GL3: " + ExterminateGame.useGL3);
    System.out.println("Deffered shading: " + InGame.DEFFERED);
    Biome.initBiomesTextures();
    Biome.initBiomes();

    Chunk.init();
    doneOnce = true;
    loaded = true;
}