Search in sources :

Example 6 with PerspectiveCamera

use of com.badlogic.gdx.graphics.PerspectiveCamera 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)

Example 7 with PerspectiveCamera

use of com.badlogic.gdx.graphics.PerspectiveCamera in project libgdx by libgdx.

the class Basic3DTest method create.

@Override
public void create() {
    modelBatch = new ModelBatch(new DefaultShaderProvider());
    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));
    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(10f, 10f, 10f);
    cam.lookAt(0, 0, 0);
    cam.near = 1f;
    cam.far = 30f;
    cam.update();
    ModelBuilder modelBuilder = new ModelBuilder();
    model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal);
    instance = new ModelInstance(model);
    Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) DefaultShaderProvider(com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) CameraInputController(com.badlogic.gdx.graphics.g3d.utils.CameraInputController) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Environment(com.badlogic.gdx.graphics.g3d.Environment) Material(com.badlogic.gdx.graphics.g3d.Material) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)

Example 8 with PerspectiveCamera

use of com.badlogic.gdx.graphics.PerspectiveCamera in project libgdx by libgdx.

the class BaseShadowSystem method addLight.

@Override
public void addLight(PointLight point, Set<CubemapSide> sides) {
    PointLightProperties plProperty = new PointLightProperties();
    for (int i = 0; i < 6; i++) {
        CubemapSide cubemapSide = Cubemap.CubemapSide.values()[i];
        if (sides.contains(cubemapSide)) {
            PerspectiveCamera camera = new PerspectiveCamera(90, 0, 0);
            camera.position.set(point.position);
            camera.direction.set(cubemapSide.direction);
            camera.up.set(cubemapSide.up);
            camera.near = 1;
            camera.far = 100;
            LightProperties p = new LightProperties(camera);
            plProperty.properties.put(cubemapSide, p);
        }
    }
    pointCameras.put(point, plProperty);
}
Also used : PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) CubemapSide(com.badlogic.gdx.graphics.Cubemap.CubemapSide)

Example 9 with PerspectiveCamera

use of com.badlogic.gdx.graphics.PerspectiveCamera in project libgdx by libgdx.

the class ProjectTest method create.

@Override
public void create() {
    ObjLoader objLoader = new ObjLoader();
    sphere = objLoader.loadModel(Gdx.files.internal("data/sphere.obj"));
    sphere.materials.get(0).set(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE));
    cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.far = 200;
    Random rand = new Random();
    for (int i = 0; i < instances.length; i++) {
        instances[i] = new ModelInstance(sphere, rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * -100 - 3);
    }
    batch = new SpriteBatch();
    font = new BitmapFont();
    logo = new TextureRegion(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
    modelBatch = new ModelBatch();
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Random(java.util.Random) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) ObjLoader(com.badlogic.gdx.graphics.g3d.loader.ObjLoader) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 10 with PerspectiveCamera

use of com.badlogic.gdx.graphics.PerspectiveCamera 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)

Aggregations

PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)31 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)18 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)15 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)13 Material (com.badlogic.gdx.graphics.g3d.Material)12 Environment (com.badlogic.gdx.graphics.g3d.Environment)10 Texture (com.badlogic.gdx.graphics.Texture)9 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)9 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)9 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)9 CameraInputController (com.badlogic.gdx.graphics.g3d.utils.CameraInputController)8 Model (com.badlogic.gdx.graphics.g3d.Model)7 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)6 AssetManager (com.badlogic.gdx.assets.AssetManager)5 ShaderProgram (com.badlogic.gdx.graphics.glutils.ShaderProgram)5 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)4 TextureAttribute (com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute)4 DefaultShaderProvider (com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider)4 PerspectiveCamController (com.badlogic.gdx.tests.utils.PerspectiveCamController)4 Mesh (com.badlogic.gdx.graphics.Mesh)3