Example usage for com.badlogic.gdx.graphics.g3d.environment DirectionalShadowLight DirectionalShadowLight

List of usage examples for com.badlogic.gdx.graphics.g3d.environment DirectionalShadowLight DirectionalShadowLight

Introduction

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

Prototype

public DirectionalShadowLight(int shadowMapWidth, int shadowMapHeight, float shadowViewportWidth,
        float shadowViewportHeight, float shadowNear, float shadowFar) 

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.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.  java2 s. c  o  m*/

    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);
}