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);
}
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));
}
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();
}
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);
}
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;
}
});
}
Aggregations