Example usage for com.badlogic.gdx.graphics GL10 GL_QUADRATIC_ATTENUATION

List of usage examples for com.badlogic.gdx.graphics GL10 GL_QUADRATIC_ATTENUATION

Introduction

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

Prototype

int GL_QUADRATIC_ATTENUATION

To view the source code for com.badlogic.gdx.graphics GL10 GL_QUADRATIC_ATTENUATION.

Click Source Link

Usage

From source file:com.badlogic.gdx.physics.bullet.demo.screens.DemoScreen.java

public DemoScreen(Game game) {
    // Physics is configured when super() finishes
    super();/*w  w w  . jav  a 2 s  .c o  m*/

    this.game = game;
    this.input = new DemoScreenInput(this, Gdx.input);

    Gdx.app.getInput().setInputProcessor(input);

    // Ambient light
    Gdx.gl10.glLightModelfv(GL10.GL_LIGHT_MODEL_AMBIENT, new float[] { .2f, .2f, .2f, 1 }, 0);

    // One directional light
    Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, new float[] { .2f, .2f, .2f, 1 }, 0);
    Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, new float[] { 1, 1, 1, 1 }, 0);
    Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_SPECULAR, new float[] { 1, 1, 1, 1 }, 0);
    Gdx.gl10.glLightf(GL10.GL_LIGHT0, GL10.GL_CONSTANT_ATTENUATION, 1);
    Gdx.gl10.glLightf(GL10.GL_LIGHT0, GL10.GL_LINEAR_ATTENUATION, 0);
    Gdx.gl10.glLightf(GL10.GL_LIGHT0, GL10.GL_QUADRATIC_ATTENUATION, 0);
    Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, new float[] { -10, -10, 10, 1 }, 0);
    Gdx.gl10.glEnable(GL10.GL_LIGHT0);

    PerspectiveCamera camera = getPerspectiveCamera();
    camera.position.set(-25, 0, 20);
    camera.lookAt(0, 0, 0);
    camera.up.set(0, 0, 1);
    camera.fieldOfView = 60;
    camera.update();

    // Load meshes
    cubeMesh = ObjLoader.loadObj(Gdx.app.getFiles().classpath("models/cube.obj").read(), false);
    icosphereMesh = ObjLoader.loadObj(Gdx.app.getFiles().classpath("models/icosphere.obj").read(), false);
    terrainMesh = ObjLoader.loadObj(Gdx.app.getFiles().classpath("models/terrain.obj").read(), false);

    // Load textures
    cubeTexture = new Texture(Gdx.files.classpath("textures/weird.png"), true);
    cubeTexture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest);
    icosphereTexture = new Texture(Gdx.files.classpath("textures/blue.png"), true);
    icosphereTexture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest);
    terrainTexture = new Texture(Gdx.files.classpath("textures/grass.png"), true);
    terrainTexture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest);
    terrainTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
}