Java Code Examples for com.badlogic.gdx.graphics.Camera#update()
The following examples show how to use
com.badlogic.gdx.graphics.Camera#update() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Scene.java From gdx-gltf with Apache License 2.0 | 5 votes |
private void syncCameras(){ for(Entry<Node, Camera> e : cameras){ Node node = e.key; Camera camera = e.value; transform.set(node.globalTransform).mul(modelInstance.transform); camera.position.setZero().mul(transform); camera.direction.set(0,0,-1).rot(transform); camera.up.set(Vector3.Y).rot(transform); camera.update(); } }
Example 2
Source File: VirtualScreenViewport.java From libgdx-snippets with MIT License | 5 votes |
/** * Does not call {@link com.badlogic.gdx.graphics.glutils.HdpiUtils#glViewport(int, int, int, int)}. */ @Override public void apply(boolean centerCamera) { Camera camera = getCamera(); camera.viewportWidth = getWorldWidth(); camera.viewportHeight = getWorldHeight(); if (centerCamera) { camera.position.set(getWorldWidth() / 2, getWorldHeight() / 2, 0); } camera.update(); }
Example 3
Source File: VirtualRealityRenderer.java From gdx-vr with Apache License 2.0 | 5 votes |
private void renderEye(Viewport eye, Vector3 eyeOffset) { Camera camera = eye.getCamera(); Vector3 eyePosition = camera.position; eyePosition.set(VirtualReality.body.position); Vector3 headOffset = new Vector3(0, VirtualReality.head.getEyeHeight() / 2f, 0); headOffset.mul(VirtualReality.body.orientation); eyePosition.add(headOffset); Quaternion eyeOrientation = new Quaternion(); eyeOrientation.set(VirtualReality.head.getOrientation()); eyeOrientation.mul(VirtualReality.body.orientation); eyeOffset.mul(eyeOrientation); eyePosition.add(eyeOffset); Vector3 eyeDirection = new Vector3(0, 0, -1); eyeDirection.mul(eyeOrientation); Vector3 eyeUp = new Vector3(0, 1, 0); eyeUp.mul(eyeOrientation); camera.position.set(eyePosition); camera.direction.set(eyeDirection); camera.up.set(eyeUp); camera.update(true); for (VirtualRealityRenderListener listener : listeners) { listener.render(camera); } }
Example 4
Source File: Client.java From riiablo with Apache License 2.0 | 4 votes |
@Override public void render() { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); audio.update(); Camera camera = viewport.getCamera(); camera.update(); batch.setProjectionMatrix(camera.combined); shapes.setProjectionMatrix(camera.combined); if (DEBUG_VIEWPORTS) { shapes.begin(ShapeRenderer.ShapeType.Filled); shapes.setColor(Color.DARK_GRAY); shapes.rect(0, 0, 854, 480); shapes.setColor(Color.GRAY); shapes.rect(0, 0, 640, 480); shapes.setColor(Color.BLUE); shapes.rect(0, 0, 840, 360); shapes.setColor(Color.RED); shapes.rect(0, 0, 720, 360); shapes.setColor(Color.LIGHT_GRAY); shapes.rect(0, 0, 640, 360); shapes.setColor(Color.WHITE); shapes.rect(0, 0, 100, 100); shapes.setColor(Color.GREEN); shapes.rect(0, 0, 2, viewport.getWorldHeight()); shapes.rect(0, viewport.getWorldHeight() - 2, viewport.getWorldWidth(), viewport.getWorldHeight()); shapes.rect(viewport.getWorldWidth() - 2, 0, 2, viewport.getWorldHeight()); shapes.rect(0, 0, viewport.getWorldWidth(), 2); shapes.end(); } super.render(); cursor.act(Gdx.graphics.getDeltaTime()); cursor.render(batch); Batch b = batch; b.setProjectionMatrix(BATCH_RESET); b.begin(); { batch.setShader(null); if (!Riiablo.assets.update(8)) { // TODO: (1 / 60f) - delta -- remainder of frame time drawLoading(b); } if (drawFpsMethod > 0 || forceDrawFps) { drawFps(b); } console.render(b); } b.end(); }
Example 5
Source File: CameraController.java From Cubes with MIT License | 4 votes |
public CameraController(Camera camera) { this.camera = camera; camera.position.set(0, 6.5f, 0); camera.direction.set(1, 0, 0); camera.update(); }