Example usage for com.badlogic.gdx.graphics.g3d.utils DepthShaderProvider DepthShaderProvider

List of usage examples for com.badlogic.gdx.graphics.g3d.utils DepthShaderProvider DepthShaderProvider

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g3d.utils DepthShaderProvider DepthShaderProvider.

Prototype

public DepthShaderProvider() 

Source Link

Usage

From source file:com.andgate.ikou.view.GameScreen.java

License:Open Source License

private void createEnvironment() {
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
    environment.set(new ColorAttribute(ColorAttribute.Fog, 1f, 1f, 1f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));

    shadowLight = new DirectionalShadowLight(1024, 1024, 60f, 60f, .1f, 50f);
    shadowLight.set(0.8f, 0.8f, 0.8f, -1f, -.8f, -.2f);
    //environment.shadowMap = shadowLight;

    shadowBatch = new ModelBatch(new DepthShaderProvider());
}

From source file:com.bladecoder.engine.model.Sprite3DRenderer.java

License:Apache License

public static void createBatchs() {
    Config modelConfigShader = new Config(Gdx.files.classpath(VERTEX_SHADER).readString(),
            Gdx.files.classpath(FRAGMENT_SHADER).readString());

    modelConfigShader.numBones = MAX_BONES;
    modelConfigShader.numDirectionalLights = 0;
    modelConfigShader.numPointLights = 0;
    modelConfigShader.numSpotLights = 0;

    modelBatch = new ModelBatch(new DefaultShaderProvider(modelConfigShader));

    shadowBatch = new ModelBatch(new DepthShaderProvider());
    floorBatch = new ModelBatch(new DefaultShaderProvider(Gdx.files.classpath(VERTEX_SHADER),
            Gdx.files.classpath(FLOOR_FRAGMENT_SHADER)));
}

From source file:com.qualcomm.vuforia.samples.libGDX.screens.ChooseBallScreen.java

License:Apache License

@Override
public void create() {
    if (app.createServerScreen.create != null) {
        app.createServerScreen.create.resetUserChoiceState();
        app.createServerScreen.create.startBallsDistribute();
    } else if (app.joinServerScreen.join != null) {
        PropertiesSingleton.getInstance()
                .initRandomCoinPosition(PropertiesSingleton.getInstance().getChosenIsland());
        //PropertiesSingleton.getInstance().initRandomPowerupPosition(PropertiesSingleton.getInstance().getChosenIsland());
    }/*from w w w.  ja v a 2  s  .  c om*/

    modelBatch = new ModelBatch();

    fps = new FPSLogger();
    Gdx.app.log("height: " + Gdx.graphics.getHeight() + "", "width: " + Gdx.graphics.getWidth() + "");

    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
    environment.add((shadowLight = new DirectionalShadowLight(1024, 1024, 30f, 30f, 1f, 100f)).set(0.8f, 0.8f,
            0.8f, -1f, -.8f, -.2f));
    environment.shadowMap = shadowLight;

    shadowBatch = new ModelBatch(new DepthShaderProvider());

    cam = new VuforiaCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.near = 0.1f;
    cam.far = 300f;
    cam.update();

    instances = new Array<ModelInstance>();
    //       instances.add(new ModelInstance(model, "floor"));
    //        instances.add(ball = new Ball(model, "ball"));
    //        ball.setPosition(1f, 1f, 1f);

    this.stage = new Stage(new StretchViewport(Gdx.graphics.getHeight(), Gdx.graphics.getHeight()));

    initFonts();
    //        BitmapFont font = new BitmapFont();
    Label.LabelStyle labelStyle = new Label.LabelStyle(app.font60, Color.WHITE);
    Label.LabelStyle labelStyle2 = new Label.LabelStyle(app.font60, Color.WHITE);
    Label labelTitle = new Label("CHOOSE BALL ", labelStyle);
    LabelScore = new Label("apple", labelStyle2);
    //        labelTitle.setScale(Gdx.graphics.getWidth() / 10, Gdx.graphics.getHeight() / 10);
    Gdx.app.log("width: " + Gdx.graphics.getWidth(), "height: " + Gdx.graphics.getHeight());
    labelTitle.setPosition(Gdx.graphics.getHeight() / 2 - labelTitle.getWidth() / 2,
            Gdx.graphics.getHeight() - labelTitle.getHeight() * 2);

    LabelScore.setPosition(Gdx.graphics.getHeight() - (LabelScore.getWidth() + Gdx.graphics.getHeight() / 50),
            LabelScore.getHeight() / 2);

    swipe = new Image(new Sprite(new Texture(Gdx.files.internal("swipe2.png"))));
    swipe.addAction(Actions.sequence(Actions.fadeOut(0.00000001f), Actions.delay(2), Actions.fadeIn(1)));
    //        swipe.setSize((stage.getWidth()) / 6, stage.getHeight() / 6);
    swipe.setPosition(Gdx.graphics.getHeight() / 2 - swipe.getWidth() / 2,
            Gdx.graphics.getHeight() / 2 - swipe.getHeight() / 2);
    stage.addActor(swipe);

    accept = new Image(new Sprite(new Texture(Gdx.files.internal("accept.png"))));
    //        accept.addAction(Actions.sequence(Actions.fadeOut(0.00000001f), Actions.delay(2), Actions.fadeIn(1)));
    accept.setSize((stage.getWidth()) / 10, stage.getWidth() / 10);
    accept.setPosition(Gdx.graphics.getHeight() / 2 - accept.getWidth() / 2, accept.getHeight());
    //        stage.addActor(accept);

    stage.addActor(LabelScore);
    stage.addActor(labelTitle);

    TextureAtlas atlasVote = new TextureAtlas("Buttons.pack");

    Skin voteSkin = new Skin(atlasVote);

    ImageButton.ImageButtonStyle voteButtonStyle = new ImageButton.ImageButtonStyle(); //Instaciate
    voteButtonStyle.up = voteSkin.getDrawable("ready"); //Set image for not pressed button
    voteButtonStyle.checked = voteSkin.getDrawable("notready"); //Set image for not pressed button

    readyButton = new ImageButton(voteButtonStyle);

    readyButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (app.joinServerScreen.join != null) {
                app.joinServerScreen.join.sendBallChoice(ballNames.get(currentBall));
            } else if (app.createServerScreen.create != null) {
                app.createServerScreen.create.serverUser.setBallChoice(ballNames.get(currentBall));
                app.createServerScreen.create.serverUser.setChosen(true);
                app.createServerScreen.create.notifyBalls();
            }
        }
    });

    readyButton.setSize((stage.getWidth()) / 5, stage.getWidth() / 10);

    readyButton.setPosition(Gdx.graphics.getHeight() / 2 - readyButton.getWidth() / 2, 0);
    stage.addActor(readyButton);

    for (int i = 0; i < ballNames.size; i++) {
        Model tmpModel = assets.get("3d/balls/" + ballNames.get(i) + ".g3db", Model.class);

        for (int k = 0; k < tmpModel.meshes.size; k++)
            tmpModel.meshes.get(k).scale(5, 5, 5);
        //            String id = tmpModel.nodes.get(0).id;
        //            Node node = tmpModel.getNode(id);
        //            node.scale.set(30f, 30f, 30f);
        //            node.translation.set(0, 15f, 0);
        //            tmpModel.calculateTransforms();
        instances.add(new ModelInstance(tmpModel));
    }

    InputMultiplexer inputMultiplexer = new InputMultiplexer();
    inputMultiplexer.addProcessor(stage);
    inputMultiplexer.addProcessor(new GestureDetector(0.0f, 0.0f, 0.0f, 5f, this));
    Gdx.input.setInputProcessor(inputMultiplexer);
}

From source file:com.qualcomm.vuforia.samples.libGDX.screens.ChooseIslandScreen.java

License:Apache License

@Override
public void create() {
    if (app.createServerScreen.create != null) {
        app.createServerScreen.create.resetUserChoiceState();
        app.createServerScreen.create.startIslandVote();
    }/*ww  w .ja  v a2s . c  om*/

    modelBatch = new ModelBatch();

    fps = new FPSLogger();
    Gdx.app.log("height: " + Gdx.graphics.getHeight() + "", "width: " + Gdx.graphics.getWidth() + "");

    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
    //        environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
    //        environment.add((shadowLight = new DirectionalShadowLight(1024, 1024, 30f, 30f, 1f, 100f)).set(0.8f, 0.8f, 0.8f, -1f, -.8f,
    //                -.2f));
    //        environment.shadowMap = shadowLight;

    shadowBatch = new ModelBatch(new DepthShaderProvider());

    cam = new VuforiaCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.near = 0.1f;
    cam.far = 300f;
    cam.update();

    instances = new Array<ModelInstance>();
    voteButtons = new Array<ImageButton>();

    this.stage = new Stage(new StretchViewport(Gdx.graphics.getHeight(), Gdx.graphics.getHeight()));

    initFonts();
    //        BitmapFont font = new BitmapFont();
    Label.LabelStyle labelStyle = new Label.LabelStyle(app.font60, Color.WHITE);
    Label.LabelStyle labelStyle2 = new Label.LabelStyle(app.font60, Color.WHITE);
    Label labelTitle = new Label("CHOOSE ISLAND ", labelStyle);
    LabelScore = new Label("forest", labelStyle2);
    //        labelTitle.setScale(Gdx.graphics.getWidth() / 10, Gdx.graphics.getHeight() / 10);
    Gdx.app.log("width: " + Gdx.graphics.getWidth(), "height: " + Gdx.graphics.getHeight());
    labelTitle.setPosition(Gdx.graphics.getHeight() / 2 - labelTitle.getWidth() / 2,
            Gdx.graphics.getHeight() - labelTitle.getHeight() * 2);

    LabelScore.setPosition(Gdx.graphics.getHeight() - (LabelScore.getWidth() + Gdx.graphics.getHeight() / 50),
            LabelScore.getHeight() / 2);

    swipe = new Image(new Sprite(new Texture(Gdx.files.internal("swipe2.png"))));
    swipe.addAction(Actions.sequence(Actions.fadeOut(0.00000001f), Actions.delay(2), Actions.fadeIn(1)));
    //        swipe.setSize((stage.getWidth()) / 6, stage.getHeight() / 6);
    swipe.setPosition(Gdx.graphics.getHeight() / 2 - swipe.getWidth() / 2,
            Gdx.graphics.getHeight() / 2 - swipe.getHeight() / 2);
    stage.addActor(swipe);

    accept = new Image(new Sprite(new Texture(Gdx.files.internal("accept.png"))));
    accept.setSize((stage.getWidth()) / 10, stage.getWidth() / 10);
    accept.setPosition(Gdx.graphics.getHeight() / 2 - accept.getWidth() / 2, accept.getHeight());

    stage.addActor(LabelScore);
    stage.addActor(labelTitle);

    TextureAtlas atlasVote = new TextureAtlas("Buttons.pack");

    Skin voteSkin = new Skin(atlasVote);

    ImageButton.ImageButtonStyle voteButtonStyle = new ImageButton.ImageButtonStyle(); //Instaciate
    voteButtonStyle.up = voteSkin.getDrawable("notvoted"); //Set image for not pressed button
    voteButtonStyle.checked = voteSkin.getDrawable("voted"); //Set image for pressed

    for (int i = 0; i < islandNames.size; i++) {
        Model tmpModel = assets.get("3d/islands/" + islandNames.get(i) + ".g3db", Model.class);
        //            tmpModel.meshes.get(0).scale(3,3,3);
        //            Texture texture2 = new Texture(Gdx.files.internal("3d/islands/"+islandNames.get(i)+".jpg"), Pixmap.Format.RGB888, false);
        //            TextureAttribute textureAttribute = new TextureAttribute(TextureAttribute.Diffuse, texture2);
        //            Material material = tmpModel.materials.get(0);
        //            material.set(textureAttribute);
        instances.add(new ModelInstance(tmpModel));
    }

    int numberOfIslands = islandNames.size;
    for (int i = 0; i < numberOfIslands; i++) {
        ImageButton item1Button = new ImageButton(voteButtonStyle);
        item1Button.setSize((stage.getWidth()) / 10, stage.getWidth() / 6);

        //        Gdx.input.setInputProcessor(stage);

        item1Button.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                voted = islandNames.get(currentIsland);
                if (app.joinServerScreen.join != null) {
                    app.joinServerScreen.join.sendIslandChoice(voted);
                } else if (app.createServerScreen != null) {
                    app.createServerScreen.create.serverUser.setIslandChoice(voted);
                    app.createServerScreen.create.serverUser.setChosen(true);
                    app.createServerScreen.create.notifyIsland();
                }
                //boolean found = false;
                /*for(int k = 0; k < voted.size; k++)
                {
                if(voted.get(k) == islandNames.get(currentIsland))
                    found = true;
                }
                        
                if(!found)
                voted.add(islandNames.get(currentIsland));
                        
                Gdx.app.log("voted", voted + "");
                        
                PropertiesSingleton.getInstance().setChoosenIsland(islandNames.get(currentIsland));*/

                //app.setScreen(new ChooseBallScreen(app));
            }
        });

        item1Button.setPosition(0, -item1Button.getHeight());
        voteButtons.add(item1Button);
        stage.addActor(voteButtons.get(i));
    }

    voteButtons.get(currentIsland).setPosition(Gdx.graphics.getHeight() / 2 - accept.getWidth() / 2,
            accept.getHeight());

    InputMultiplexer inputMultiplexer = new InputMultiplexer();
    inputMultiplexer.addProcessor(stage);
    inputMultiplexer.addProcessor(new GestureDetector(0.0f, 0.0f, 0.0f, 5f, this));
    Gdx.input.setInputProcessor(inputMultiplexer);
}

From source file:org.bladecoder.bladeengine.model.Sprite3DRenderer.java

License:Apache License

public static void createBatchs() {
    Config modelConfigShader = new Config(
            Gdx.files.classpath("org/bladecoder/engine/shading/cel.vertex.glsl").readString(),
            Gdx.files.classpath("org/bladecoder/engine/shading/cel.fragment.glsl").readString());

    modelConfigShader.numBones = MAX_BONES;
    modelConfigShader.numDirectionalLights = 0;
    modelConfigShader.numPointLights = 0;
    modelConfigShader.numSpotLights = 0;

    modelBatch = new ModelBatch(new DefaultShaderProvider(modelConfigShader));

    shadowBatch = new ModelBatch(new DepthShaderProvider());
    floorBatch = new ModelBatch(
            new DefaultShaderProvider(Gdx.files.classpath("org/bladecoder/engine/shading/cel.vertex.glsl"),
                    Gdx.files.classpath("org/bladecoder/engine/shading/floor.fragment.glsl")));
}