List of usage examples for com.badlogic.gdx.graphics PerspectiveCamera update
@Override
public void update()
From source file:com.badlogic.gdx.physics.bullet.demo.screens.DemoScreen.java
public DemoScreen(Game game) { // Physics is configured when super() finishes super();// ww w .j a v a 2s . c o m this.game = game; this.input = new DemoScreenInput(this, Gdx.input); Gdx.app.getInput().setInputProcessor(input); // Ambient light Gdx.gl10.glLightModelfv(GL10.GL_LIGHT_MODEL_AMBIENT, new float[] { .2f, .2f, .2f, 1 }, 0); // One directional light Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, new float[] { .2f, .2f, .2f, 1 }, 0); Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, new float[] { 1, 1, 1, 1 }, 0); Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_SPECULAR, new float[] { 1, 1, 1, 1 }, 0); Gdx.gl10.glLightf(GL10.GL_LIGHT0, GL10.GL_CONSTANT_ATTENUATION, 1); Gdx.gl10.glLightf(GL10.GL_LIGHT0, GL10.GL_LINEAR_ATTENUATION, 0); Gdx.gl10.glLightf(GL10.GL_LIGHT0, GL10.GL_QUADRATIC_ATTENUATION, 0); Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, new float[] { -10, -10, 10, 1 }, 0); Gdx.gl10.glEnable(GL10.GL_LIGHT0); PerspectiveCamera camera = getPerspectiveCamera(); camera.position.set(-25, 0, 20); camera.lookAt(0, 0, 0); camera.up.set(0, 0, 1); camera.fieldOfView = 60; camera.update(); // Load meshes cubeMesh = ObjLoader.loadObj(Gdx.app.getFiles().classpath("models/cube.obj").read(), false); icosphereMesh = ObjLoader.loadObj(Gdx.app.getFiles().classpath("models/icosphere.obj").read(), false); terrainMesh = ObjLoader.loadObj(Gdx.app.getFiles().classpath("models/terrain.obj").read(), false); // Load textures cubeTexture = new Texture(Gdx.files.classpath("textures/weird.png"), true); cubeTexture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest); icosphereTexture = new Texture(Gdx.files.classpath("textures/blue.png"), true); icosphereTexture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest); terrainTexture = new Texture(Gdx.files.classpath("textures/grass.png"), true); terrainTexture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest); terrainTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); }
From source file:com.bladecoder.engine.model.Sprite3DRenderer.java
License:Apache License
private PerspectiveCamera getCamera(ModelInstance modelInstance) { PerspectiveCamera camera3d = new PerspectiveCamera(cameraFOV, width, height); if (cameraPos == null) { Node n = null;/* ww w . j av a2 s .co m*/ // SET CAMERA POS FROM MODEL IF EXISTS n = modelInstance.getNode(cameraName); if (n != null) { cameraPos = n.translation; } else { cameraPos = new Vector3(0, 0, 5); } } if (cameraRot == null) { Node n = null; // SET CAMERA POS FROM MODEL IF EXISTS n = modelInstance.getNode(cameraName); if (n != null) { float rx = (float) (MathUtils.radiansToDegrees * Math.asin(2 * n.rotation.x * n.rotation.y + 2 * n.rotation.z * n.rotation.w)); float ry = (float) (MathUtils.radiansToDegrees * Math.atan2(2 * n.rotation.x * n.rotation.w - 2 * n.rotation.y * n.rotation.z, 1 - 2 * n.rotation.x * n.rotation.x - 2 * n.rotation.z * n.rotation.z)); float rz = (float) (Math.atan2(2 * n.rotation.y * n.rotation.w - 2 * n.rotation.x * n.rotation.z, 1 - 2 * n.rotation.y * n.rotation.y - 2 * n.rotation.z * n.rotation.z)); setCameraRot(rx, ry, rz); } else { cameraRot = new Vector3(); } } camera3d.position.set(cameraPos); camera3d.rotate(cameraRot.x, 1, 0, 0); camera3d.rotate(cameraRot.y, 0, 1, 0); camera3d.rotate(cameraRot.z, 0, 0, 1); camera3d.near = 0.1f; camera3d.far = 30; camera3d.update(); return camera3d; }
From source file:com.nsoft.boxuniverse.world.Controls.java
License:Open Source License
/** * Aplica translaciones a la camara// w w w . j a v a 2 s . com * @param pc * @param delta */ public static void CamTest(PerspectiveCamera pc, float delta) { //No se usa else if para asi poder hacer movimientos en diagonal delta *= pc.position.z / 2; if (Gdx.input.isKeyPressed(Keys.W)) { pc.translate(0, delta, 0); } if (Gdx.input.isKeyPressed(Keys.S)) { pc.translate(0, -delta, 0); } if (Gdx.input.isKeyPressed(Keys.A)) { pc.translate(-delta, 0, 0); } if (Gdx.input.isKeyPressed(Keys.D)) { pc.translate(delta, 0, 0); } pc.update(); }
From source file:org.interreg.docexplore.reader.gfx.CameraKeyFrame.java
License:Open Source License
/** * Attracts a camera to this key frame./*from w w w.j a v a 2 s .c o m*/ * @param camera * @param amount 0 will not affect the camera, 1 will set it to this key frame. */ public void attract(PerspectiveCamera camera, float amount) { attract(camera.position, pos, amount); attract(camera.direction, dir, amount); attract(camera.up, up, amount); camera.fieldOfView += amount * (180 * fov / Math.PI - camera.fieldOfView); camera.normalizeUp(); camera.update(); }