/** 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 boolean zoom (float amount) { if (!alwaysScroll && activateKey != 0 && !activatePressed) return false; camera.translate(tmpV1.set(camera.direction).scl(amount)); if (scrollTarget) target.add(tmpV1); if (autoUpdate) camera.update(); return true; }
public boolean zoom (float amount) { if (!alwaysScroll && activateKey != 0 && !activatePressed) return false; camera.translate(tmpV1.set(camera.direction).scl(amount)); if (scrollTarget) target.add(tmpV1); if (autoUpdate) camera.update(); return true; }
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(); } }
protected boolean process (float deltaX, float deltaY, int button) { if (button == rotateButton) { tmpV1.set(camera.direction).crs(camera.up).y = 0f; camera.rotateAround(target, tmpV1.nor(), deltaY * rotateAngle); camera.rotateAround(target, Vector3.Y, deltaX * -rotateAngle); } else if (button == translateButton) { camera.translate(tmpV1.set(camera.direction).crs(camera.up).nor().scl(-deltaX * translateUnits)); camera.translate(tmpV2.set(camera.up).scl(-deltaY * translateUnits)); if (translateTarget) target.add(tmpV1).add(tmpV2); } else if (button == forwardButton) { camera.translate(tmpV1.set(camera.direction).scl(deltaY * translateUnits)); if (forwardTarget) target.add(tmpV1); } if (autoUpdate) camera.update(); return true; }
protected boolean process (float deltaX, float deltaY, int button) { if (button == rotateButton) { tmpV1.set(camera.direction).crs(camera.up).y = 0f; camera.rotateAround(target, tmpV1.nor(), deltaY * rotateAngle); camera.rotateAround(target, Vector3.Y, deltaX * -rotateAngle); } else if (button == translateButton) { camera.translate(tmpV1.set(camera.direction).crs(camera.up).nor().scl(-deltaX * translateUnits)); camera.translate(tmpV2.set(camera.up).scl(-deltaY * translateUnits)); if (translateTarget) target.add(tmpV1).add(tmpV2); } else if (button == forwardButton) { camera.translate(tmpV1.set(camera.direction).scl(deltaY * translateUnits)); if (forwardTarget) target.add(tmpV1); } if (autoUpdate) camera.update(); return true; }
mCamera.translate(0, 0, radius - translateZ); mCamera.rotateX((float) degree); // remove this line.. if (distanceY < 0) {
Camera mCamera = new Camera(); mCamera.translate(0.0f, 0.0f, -295.0f);
/** 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); }
mCam.translate(x -startX, startY - y, 0.f); startX = event.getX(); startY = event.getY();
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX; final float centerY = mCenterY; final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); camera.save(); if (mReverse) { camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); } else { camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); } camera.rotateY(degrees); `camera.rotateX(degrees); //i want to do this it works for negative but not` //positive angles camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY);
public boolean zoom (float amount) { if (!alwaysScroll && activateKey != 0 && !activatePressed) return false; camera.translate(tmpV1.set(camera.direction).scl(amount)); if (scrollTarget) target.add(tmpV1); if (autoUpdate) camera.update(); return true; }
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(); } }
protected boolean process (float deltaX, float deltaY, int button) { if (button == rotateButton) { tmpV1.set(camera.direction).crs(camera.up).y = 0f; camera.rotateAround(target, tmpV1.nor(), deltaY * rotateAngle); camera.rotateAround(target, Vector3.Y, deltaX * -rotateAngle); } else if (button == translateButton) { camera.translate(tmpV1.set(camera.direction).crs(camera.up).nor().scl(-deltaX * translateUnits)); camera.translate(tmpV2.set(camera.up).scl(-deltaY * translateUnits)); if (translateTarget) target.add(tmpV1).add(tmpV2); } else if (button == forwardButton) { camera.translate(tmpV1.set(camera.direction).scl(deltaY * translateUnits)); if (forwardTarget) target.add(tmpV1); } if (autoUpdate) camera.update(); return true; }
camera.translate(0, 0, Math.abs(degrees)*2); camera.getMatrix(matrix); camera.rotateY(degrees);
camera.translate(0, 0, Math.abs(degrees) * 2); camera.getMatrix(matrix); camera.rotateY(degrees);
@Test public void testFromParallax() { camera.translate(1, 1, 0); float scale = 2f; Vector2 world = new Vector2(1, 1); Vector2 to = GDXRenderer.toParallax(scale, world, camera); assertEquals(to.x, 1.5, .01); assertEquals(to.y, 1.5, .01); Vector2 from = GDXRenderer.fromParallax(scale, to, camera); assertEquals(world.x, from.x, .01); assertEquals(world.y, from.y, .01); } }