/** Transform the position, direction and up vector by the given matrix * * @param transform The transform matrix */ public void transform (final Matrix4 transform) { position.mul(transform); rotate(transform); }
/** Transform the position, direction and up vector by the given matrix * * @param transform The transform matrix */ public void transform (final Matrix4 transform) { position.mul(transform); rotate(transform); }
/** Rotates the direction and up vector of this camera by the given angle around the given axis, with the axis attached to given * point. The direction and up vector will not be orthogonalized. * * @param point the point to attach the axis to * @param axis the axis to rotate around * @param angle the angle, in degrees */ public void rotateAround (Vector3 point, Vector3 axis, float angle) { tmpVec.set(point); tmpVec.sub(position); translate(tmpVec); rotate(axis, angle); tmpVec.rotate(axis, angle); translate(-tmpVec.x, -tmpVec.y, -tmpVec.z); }
/** Rotates the direction and up vector of this camera by the given angle around the given axis, with the axis attached to given * point. The direction and up vector will not be orthogonalized. * * @param point the point to attach the axis to * @param axis the axis to rotate around * @param angle the angle, in degrees */ public void rotateAround (Vector3 point, Vector3 axis, float angle) { tmpVec.set(point); tmpVec.sub(position); translate(tmpVec); rotate(axis, angle); tmpVec.rotate(axis, angle); translate(-tmpVec.x, -tmpVec.y, -tmpVec.z); }
public void update () { if (rotateRightPressed || rotateLeftPressed || forwardPressed || backwardPressed) { final float delta = Gdx.graphics.getDeltaTime(); if (rotateRightPressed) camera.rotate(camera.up, -delta * rotateAngle); if (rotateLeftPressed) camera.rotate(camera.up, delta * rotateAngle); if (forwardPressed) { camera.translate(tmpV1.set(camera.direction).scl(delta * translateUnits)); if (forwardTarget) target.add(tmpV1); } if (backwardPressed) { camera.translate(tmpV1.set(camera.direction).scl(-delta * translateUnits)); if (forwardTarget) target.add(tmpV1); } if (autoUpdate) camera.update(); } }
public void update () { if (rotateRightPressed || rotateLeftPressed || forwardPressed || backwardPressed) { final float delta = Gdx.graphics.getDeltaTime(); if (rotateRightPressed) camera.rotate(camera.up, -delta * rotateAngle); if (rotateLeftPressed) camera.rotate(camera.up, delta * rotateAngle); if (forwardPressed) { camera.translate(tmpV1.set(camera.direction).scl(delta * translateUnits)); if (forwardTarget) target.add(tmpV1); } if (backwardPressed) { camera.translate(tmpV1.set(camera.direction).scl(-delta * translateUnits)); if (forwardTarget) target.add(tmpV1); } if (autoUpdate) camera.update(); } }
@Override public void render () { GL20 gl = Gdx.gl20; gl.glClearColor(0, 0, 0, 0); gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); gl.glEnable(GL20.GL_DEPTH_TEST); cam.update(); modelBatch.begin(cam); int visible = 0; for (int i = 0; i < instances.length; i++) { instances[i].transform.getTranslation(pos); if (cam.frustum.sphereInFrustum(pos, 1)) { ((ColorAttribute)instances[i].materials.get(0).get(ColorAttribute.Diffuse)).color.set(Color.WHITE); visible++; } else { ((ColorAttribute)instances[i].materials.get(0).get(ColorAttribute.Diffuse)).color.set(Color.RED); } modelBatch.render(instances[i]); } modelBatch.end(); if (Gdx.input.isKeyPressed(Keys.A)) cam.rotate(20 * Gdx.graphics.getDeltaTime(), 0, 1, 0); if (Gdx.input.isKeyPressed(Keys.D)) cam.rotate(-20 * Gdx.graphics.getDeltaTime(), 0, 1, 0); gl.glDisable(GL20.GL_DEPTH_TEST); batch.begin(); font.draw(batch, "visible: " + visible + "/100" + ", fps: " + Gdx.graphics.getFramesPerSecond(), 0, 20); batch.end(); }
/** Transform the position, direction and up vector by the given matrix * * @param transform The transform matrix */ public void transform (final Matrix4 transform) { position.mul(transform); rotate(transform); }
/** Rotates the direction and up vector of this camera by the given angle around the given axis, with the axis attached to given * point. The direction and up vector will not be orthogonalized. * * @param point the point to attach the axis to * @param axis the axis to rotate around * @param angle the angle, in degrees */ public void rotateAround (Vector3 point, Vector3 axis, float angle) { tmpVec.set(point); tmpVec.sub(position); translate(tmpVec); rotate(axis, angle); tmpVec.rotate(axis, angle); translate(-tmpVec.x, -tmpVec.y, -tmpVec.z); }
public void update () { if (rotateRightPressed || rotateLeftPressed || forwardPressed || backwardPressed) { final float delta = Gdx.graphics.getDeltaTime(); if (rotateRightPressed) camera.rotate(camera.up, -delta * rotateAngle); if (rotateLeftPressed) camera.rotate(camera.up, delta * rotateAngle); if (forwardPressed) { camera.translate(tmpV1.set(camera.direction).scl(delta * translateUnits)); if (forwardTarget) target.add(tmpV1); } if (backwardPressed) { camera.translate(tmpV1.set(camera.direction).scl(-delta * translateUnits)); if (forwardTarget) target.add(tmpV1); } if (autoUpdate) camera.update(); } }