Search in sources :

Example 26 with PerspectiveCamera

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

the class ModelLoaderTest method create.

@Override
public void create() {
    camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.set(0, 0, 5);
    camera.near = 1;
    camera.far = 100;
    camera.update();
    assets = new AssetManager();
    assets.load("data/g3d/cube.g3dj", Model.class);
    spriteBatch = new SpriteBatch();
    modelBatch = new ModelBatch();
// assets.getLogger().setLevel(Logger.DEBUG);
}
Also used : AssetManager(com.badlogic.gdx.assets.AssetManager) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 27 with PerspectiveCamera

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

the class BaseShadowSystem method addLight.

@Override
public void addLight(SpotLight spot) {
    PerspectiveCamera camera = new PerspectiveCamera(spot.cutoffAngle, 0, 0);
    camera.position.set(spot.position);
    camera.direction.set(spot.direction);
    camera.near = 1;
    camera.far = 100;
    camera.up.set(camera.direction.y, camera.direction.z, camera.direction.x);
    spotCameras.put(spot, new LightProperties(camera));
}
Also used : PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera)

Example 28 with PerspectiveCamera

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

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

Example 30 with PerspectiveCamera

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

the class ViewportTest3 method create.

public void create() {
    modelBatch = new ModelBatch();
    modelBuilder = new ModelBuilder();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, 1.f));
    shadowLight = new DirectionalLight();
    shadowLight.set(0.8f, 0.8f, 0.8f, -0.5f, -1f, 0.7f);
    environment.add(shadowLight);
    modelBatch = new ModelBatch();
    camera = new PerspectiveCamera();
    camera.fieldOfView = 67;
    camera.near = 0.1f;
    camera.far = 300f;
    camera.position.set(0, 0, 100);
    camera.lookAt(0, 0, 0);
    viewports = ViewportTest1.getViewports(camera);
    viewport = viewports.first();
    names = ViewportTest1.getViewportNames();
    name = names.first();
    ModelBuilder modelBuilder = new ModelBuilder();
    Model boxModel = modelBuilder.createBox(50f, 50f, 50f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal);
    boxInstance = new ModelInstance(boxModel);
    boxInstance.transform.rotate(1, 0, 0, 30);
    boxInstance.transform.rotate(0, 1, 0, 30);
    Gdx.input.setInputProcessor(new InputAdapter() {

        public boolean keyDown(int keycode) {
            if (keycode == Input.Keys.SPACE) {
                int index = (viewports.indexOf(viewport, true) + 1) % viewports.size;
                name = names.get(index);
                viewport = viewports.get(index);
                resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
            }
            return false;
        }
    });
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) InputAdapter(com.badlogic.gdx.InputAdapter) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Model(com.badlogic.gdx.graphics.g3d.Model) 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)

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