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