Search in sources :

Example 1 with FrameBufferCubemap

use of com.badlogic.gdx.graphics.glutils.FrameBufferCubemap in project libgdx by libgdx.

the class FrameBufferCubemapTest method create.

@Override
public void create() {
    super.create();
    camFb = new PerspectiveCamera(90, 800, 800);
    camFb.position.set(10f, 10f, 10f);
    camFb.lookAt(0, 0, 0);
    camFb.near = 0.1f;
    camFb.far = 1000f;
    camFb.update();
    fb = new FrameBufferCubemap(Format.RGBA8888, 800, 800, true);
    cubemap = fb.getColorBufferTexture();
    ObjLoader objLoader = new ObjLoader();
    cubeMesh = objLoader.loadModel(Gdx.files.internal("data/cube.obj"));
    cubeInstance = new ModelInstance(cubeMesh);
    cubeBatch = new ModelBatch(Gdx.files.internal("data/shaders/cubemap-vert.glsl"), Gdx.files.internal("data/shaders/cubemap-frag.glsl"));
    cubeInstance.materials.get(0).set(new CubemapAttribute(CubemapAttribute.EnvironmentMap, cubemap));
    camCube = new PerspectiveCamera(67, Gdx.graphics.getWidth() * 0.5f, Gdx.graphics.getHeight() * 0.5f);
    camCube.position.set(0f, 2f, 2f);
    camCube.lookAt(0, 0, 0);
    camCube.near = 1f;
    camCube.far = 300f;
    camCube.update();
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) CubemapAttribute(com.badlogic.gdx.graphics.g3d.attributes.CubemapAttribute) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) ObjLoader(com.badlogic.gdx.graphics.g3d.loader.ObjLoader) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) FrameBufferCubemap(com.badlogic.gdx.graphics.glutils.FrameBufferCubemap)

Aggregations

PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)1 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)1 CubemapAttribute (com.badlogic.gdx.graphics.g3d.attributes.CubemapAttribute)1 ObjLoader (com.badlogic.gdx.graphics.g3d.loader.ObjLoader)1 FrameBufferCubemap (com.badlogic.gdx.graphics.glutils.FrameBufferCubemap)1