Search in sources :

Example 1 with PerspectiveCamController

use of com.badlogic.gdx.tests.utils.PerspectiveCamController in project libgdx by libgdx.

the class MipMapTest method create.

@Override
public void create() {
    camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.set(0, 1.5f, 1.5f);
    camera.lookAt(0, 0, 0);
    camera.update();
    controller = new PerspectiveCamController(camera);
    mesh = new Mesh(true, 4, 4, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE));
    mesh.setVertices(new float[] { -1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, -1, 1, 0, -1, 0, -1, 0, 0 });
    mesh.setIndices(new short[] { 0, 1, 2, 3 });
    shader = new ShaderProgram(Gdx.files.internal("data/shaders/flattex-vert.glsl").readString(), Gdx.files.internal("data/shaders/flattex-frag.glsl").readString());
    if (!shader.isCompiled())
        throw new GdxRuntimeException("shader error: " + shader.getLog());
    textureHW = new Texture(Gdx.files.internal("data/badlogic.jpg"), Format.RGB565, true);
    MipMapGenerator.setUseHardwareMipMap(false);
    textureSW = new Texture(Gdx.files.internal("data/badlogic.jpg"), Format.RGB565, true);
    currTexture = textureHW;
    createUI();
    multiplexer = new InputMultiplexer();
    Gdx.input.setInputProcessor(multiplexer);
    multiplexer.addProcessor(ui);
    multiplexer.addProcessor(controller);
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) PerspectiveCamController(com.badlogic.gdx.tests.utils.PerspectiveCamController) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) ShaderProgram(com.badlogic.gdx.graphics.glutils.ShaderProgram) VertexAttribute(com.badlogic.gdx.graphics.VertexAttribute) Mesh(com.badlogic.gdx.graphics.Mesh) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) Texture(com.badlogic.gdx.graphics.Texture)

Example 2 with PerspectiveCamController

use of com.badlogic.gdx.tests.utils.PerspectiveCamController in project libgdx by libgdx.

the class ShapeRendererTest method create.

public void create() {
    renderer = new ShapeRenderer();
    cam = new PerspectiveCamera(47, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(0, 0, 2);
    cam.near = 0.1f;
    controller = new PerspectiveCamController(cam);
    Gdx.input.setInputProcessor(controller);
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
}
Also used : PerspectiveCamController(com.badlogic.gdx.tests.utils.PerspectiveCamController) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 3 with PerspectiveCamController

use of com.badlogic.gdx.tests.utils.PerspectiveCamController in project libgdx by libgdx.

the class ProjectiveTextureTest method setupScene.

public void setupScene() {
    plane = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
    plane.setVertices(new float[] { -10, -1, 10, 0, 1, 0, 10, -1, 10, 0, 1, 0, 10, -1, -10, 0, 1, 0, -10, -1, -10, 0, 1, 0 });
    plane.setIndices(new short[] { 3, 2, 1, 1, 0, 3 });
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), Format.RGB565, true);
    texture.setFilter(TextureFilter.MipMap, TextureFilter.Nearest);
    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(0, 5, 10);
    cam.lookAt(0, 0, 0);
    cam.update();
    controller = new PerspectiveCamController(cam);
    projector = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    projector.position.set(2, 3, 2);
    projector.lookAt(0, 0, 0);
    projector.normalizeUp();
    projector.update();
}
Also used : PerspectiveCamController(com.badlogic.gdx.tests.utils.PerspectiveCamController) VertexAttribute(com.badlogic.gdx.graphics.VertexAttribute) Mesh(com.badlogic.gdx.graphics.Mesh) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) Texture(com.badlogic.gdx.graphics.Texture)

Example 4 with PerspectiveCamController

use of com.badlogic.gdx.tests.utils.PerspectiveCamController in project libgdx by libgdx.

the class SimpleDecalTest method create.

public void create() {
    float width = Gdx.graphics.getWidth();
    float height = Gdx.graphics.getHeight();
    camera = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.near = 1;
    camera.far = 300;
    camera.position.set(0, 0, 5);
    controller = new PerspectiveCamController(camera);
    Gdx.input.setInputProcessor(controller);
    batch = new DecalBatch(new CameraGroupStrategy(camera));
    TextureRegion[] textures = { new TextureRegion(new Texture(Gdx.files.internal("data/egg.png"))), new TextureRegion(new Texture(Gdx.files.internal("data/wheel.png"))), new TextureRegion(new Texture(Gdx.files.internal("data/badlogic.jpg"))) };
    Decal decal = Decal.newDecal(1, 1, textures[1]);
    decal.setPosition(0, 0, 0);
    decals.add(decal);
    decal = Decal.newDecal(1, 1, textures[0], true);
    decal.setPosition(0.5f, 0.5f, 1);
    decals.add(decal);
    decal = Decal.newDecal(1, 1, textures[0], true);
    decal.setPosition(1, 1, -1);
    decals.add(decal);
    decal = Decal.newDecal(1, 1, textures[2]);
    decal.setPosition(1.5f, 1.5f, -2);
    decals.add(decal);
    decal = Decal.newDecal(1, 1, textures[1]);
    decal.setPosition(2, 2, -1.5f);
    decals.add(decal);
}
Also used : DecalBatch(com.badlogic.gdx.graphics.g3d.decals.DecalBatch) Decal(com.badlogic.gdx.graphics.g3d.decals.Decal) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) PerspectiveCamController(com.badlogic.gdx.tests.utils.PerspectiveCamController) CameraGroupStrategy(com.badlogic.gdx.graphics.g3d.decals.CameraGroupStrategy) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) Texture(com.badlogic.gdx.graphics.Texture)

Aggregations

PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)4 PerspectiveCamController (com.badlogic.gdx.tests.utils.PerspectiveCamController)4 Texture (com.badlogic.gdx.graphics.Texture)3 Mesh (com.badlogic.gdx.graphics.Mesh)2 VertexAttribute (com.badlogic.gdx.graphics.VertexAttribute)2 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)1 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 CameraGroupStrategy (com.badlogic.gdx.graphics.g3d.decals.CameraGroupStrategy)1 Decal (com.badlogic.gdx.graphics.g3d.decals.Decal)1 DecalBatch (com.badlogic.gdx.graphics.g3d.decals.DecalBatch)1 ShaderProgram (com.badlogic.gdx.graphics.glutils.ShaderProgram)1 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)1 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)1