/** Transforms the specified world coordinate to screen coordinates. * @return The vector that was passed in, transformed to screen coordinates. * @see Camera#project(Vector3) */ public Vector3 project (Vector3 worldCoords) { camera.project(worldCoords, screenX, screenY, screenWidth, screenHeight); return worldCoords; }
/** Transforms the specified world coordinate to screen coordinates. * @return The vector that was passed in, transformed to screen coordinates. * @see Camera#project(Vector3) */ public Vector3 project (Vector3 worldCoords) { camera.project(worldCoords, screenX, screenY, screenWidth, screenHeight); return worldCoords; }
/** Projects the {@link Vector3} given in world space to screen coordinates. It's the same as GLU gluProject with one small * deviation: The viewport is assumed to span the whole screen. The screen coordinate system has its origin in the * <b>bottom</b> left, with the y-axis pointing <b>upwards</b> and the x-axis pointing to the right. This makes it easily * useable in conjunction with {@link Batch} and similar classes. * @return the mutated and projected worldCoords {@link Vector3} */ public Vector3 project (Vector3 worldCoords) { project(worldCoords, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); return worldCoords; }
/** Projects the {@link Vector3} given in world space to screen coordinates. It's the same as GLU gluProject with one small * deviation: The viewport is assumed to span the whole screen. The screen coordinate system has its origin in the * <b>bottom</b> left, with the y-axis pointing <b>upwards</b> and the x-axis pointing to the right. This makes it easily * useable in conjunction with {@link Batch} and similar classes. * @return the mutated and projected worldCoords {@link Vector3} */ public Vector3 project (Vector3 worldCoords) { project(worldCoords, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); return worldCoords; }
/** Transforms the specified world coordinate to screen coordinates. * @return The vector that was passed in, transformed to screen coordinates. * @see Camera#project(Vector3) */ public Vector2 project (Vector2 worldCoords) { tmp.set(worldCoords.x, worldCoords.y, 1); camera.project(tmp, screenX, screenY, screenWidth, screenHeight); worldCoords.set(tmp.x, tmp.y); return worldCoords; }
/** Transforms the specified world coordinate to screen coordinates. * @return The vector that was passed in, transformed to screen coordinates. * @see Camera#project(Vector3) */ public Vector2 project (Vector2 worldCoords) { tmp.set(worldCoords.x, worldCoords.y, 1); camera.project(tmp, screenX, screenY, screenWidth, screenHeight); worldCoords.set(tmp.x, tmp.y); return worldCoords; }
/** Calculates a scissor rectangle in OpenGL ES window coordinates from a {@link Camera}, a transformation {@link Matrix4} and * an axis aligned {@link Rectangle}. The rectangle will get transformed by the camera and transform matrices and is then * projected to screen coordinates. Note that only axis aligned rectangles will work with this method. If either the Camera or * the Matrix4 have rotational components, the output of this method will not be suitable for * {@link GL20#glScissor(int, int, int, int)}. * @param camera the {@link Camera} * @param batchTransform the transformation {@link Matrix4} * @param area the {@link Rectangle} to transform to window coordinates * @param scissor the Rectangle to store the result in */ public static void calculateScissors (Camera camera, float viewportX, float viewportY, float viewportWidth, float viewportHeight, Matrix4 batchTransform, Rectangle area, Rectangle scissor) { tmp.set(area.x, area.y, 0); tmp.mul(batchTransform); camera.project(tmp, viewportX, viewportY, viewportWidth, viewportHeight); scissor.x = tmp.x; scissor.y = tmp.y; tmp.set(area.x + area.width, area.y + area.height, 0); tmp.mul(batchTransform); camera.project(tmp, viewportX, viewportY, viewportWidth, viewportHeight); scissor.width = tmp.x - scissor.x; scissor.height = tmp.y - scissor.y; }
/** Calculates a scissor rectangle in OpenGL ES window coordinates from a {@link Camera}, a transformation {@link Matrix4} and * an axis aligned {@link Rectangle}. The rectangle will get transformed by the camera and transform matrices and is then * projected to screen coordinates. Note that only axis aligned rectangles will work with this method. If either the Camera or * the Matrix4 have rotational components, the output of this method will not be suitable for * {@link GL20#glScissor(int, int, int, int)}. * @param camera the {@link Camera} * @param batchTransform the transformation {@link Matrix4} * @param area the {@link Rectangle} to transform to window coordinates * @param scissor the Rectangle to store the result in */ public static void calculateScissors (Camera camera, float viewportX, float viewportY, float viewportWidth, float viewportHeight, Matrix4 batchTransform, Rectangle area, Rectangle scissor) { tmp.set(area.x, area.y, 0); tmp.mul(batchTransform); camera.project(tmp, viewportX, viewportY, viewportWidth, viewportHeight); scissor.x = tmp.x; scissor.y = tmp.y; tmp.set(area.x + area.width, area.y + area.height, 0); tmp.mul(batchTransform); camera.project(tmp, viewportX, viewportY, viewportWidth, viewportHeight); scissor.width = tmp.x - scissor.x; scissor.height = tmp.y - scissor.y; }
/** Transforms a point to real screen coordinates (as opposed to OpenGL ES window coordinates), where the origin is in the top * left and the the y-axis is pointing downwards. */ public Vector2 toScreenCoordinates (Vector2 worldCoords, Matrix4 transformMatrix) { tmp.set(worldCoords.x, worldCoords.y, 0); tmp.mul(transformMatrix); camera.project(tmp); tmp.y = Gdx.graphics.getHeight() - tmp.y; worldCoords.x = tmp.x; worldCoords.y = tmp.y; return worldCoords; }
/** Transforms a point to real screen coordinates (as opposed to OpenGL ES window coordinates), where the origin is in the top * left and the the y-axis is pointing downwards. */ public Vector2 toScreenCoordinates (Vector2 worldCoords, Matrix4 transformMatrix) { tmp.set(worldCoords.x, worldCoords.y, 0); tmp.mul(transformMatrix); camera.project(tmp); tmp.y = Gdx.graphics.getHeight() - tmp.y; worldCoords.x = tmp.x; worldCoords.y = tmp.y; return worldCoords; }
@Override public void draw3dText (Vector3 location, String textString) { if (spriteBatch == null) { spriteBatch = new SpriteBatch(); } if (font == null) { font = new BitmapFont(); } // this check is necessary to avoid "mirrored" instances of the text if (camera.frustum.pointInFrustum(location)) { if (viewport != null) { camera.project(location, viewport.getScreenX(), viewport.getScreenY(), viewport.getScreenWidth(), viewport.getScreenHeight()); } else { camera.project(location); } shapeRenderer.end(); spriteBatch.begin(); // the text will be centered on the position font.draw(spriteBatch, textString, location.x, location.y, 0, textString.length(), 0, Align.center, false); spriteBatch.end(); shapeRenderer.begin(ShapeType.Line); } }
@Override public void draw3dText (Vector3 location, String textString) { if (spriteBatch == null) { spriteBatch = new SpriteBatch(); } if (font == null) { font = new BitmapFont(); } // this check is necessary to avoid "mirrored" instances of the text if (camera.frustum.pointInFrustum(location)) { if (viewport != null) { camera.project(location, viewport.getScreenX(), viewport.getScreenY(), viewport.getScreenWidth(), viewport.getScreenHeight()); } else { camera.project(location); } shapeRenderer.end(); spriteBatch.begin(); // the text will be centered on the position font.draw(spriteBatch, textString, location.x, location.y, 0, textString.length(), 0, Align.center, false); spriteBatch.end(); shapeRenderer.begin(ShapeType.Line); } }
for (int i = 0; i < instances.length; i++) { instances[i].transform.getTranslation(tmp); cam.project(tmp); if (tmp.z < 0) continue; batch.draw(logo, tmp.x, tmp.y);
/** Transforms the specified world coordinate to screen coordinates. * @return The vector that was passed in, transformed to screen coordinates. * @see Camera#project(Vector3) */ public Vector3 project (Vector3 worldCoords) { camera.project(worldCoords, screenX, screenY, screenWidth, screenHeight); return worldCoords; }
/** Projects the {@link Vector3} given in world space to screen coordinates. It's the same as GLU gluProject with one small * deviation: The viewport is assumed to span the whole screen. The screen coordinate system has its origin in the * <b>bottom</b> left, with the y-axis pointing <b>upwards</b> and the x-axis pointing to the right. This makes it easily * useable in conjunction with {@link Batch} and similar classes. * @return the mutated and projected worldCoords {@link Vector3} */ public Vector3 project (Vector3 worldCoords) { project(worldCoords, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); return worldCoords; }
/** Transforms the specified world coordinate to screen coordinates. * @return The vector that was passed in, transformed to screen coordinates. * @see Camera#project(Vector3) */ public Vector2 project (Vector2 worldCoords) { tmp.set(worldCoords.x, worldCoords.y, 1); camera.project(tmp, screenX, screenY, screenWidth, screenHeight); worldCoords.set(tmp.x, tmp.y); return worldCoords; }
public static Vector2 toScreenCoordinates(Camera cam, Vector2 world){ Vector3 coords = new Vector3(world.x, world.y, 0); cam.project(coords); return new Vector2(coords.x, coords.y); } }
/** Transforms a point to real screen coordinates (as opposed to OpenGL ES window coordinates), where the origin is in the top * left and the the y-axis is pointing downwards. */ public Vector2 toScreenCoordinates (Vector2 worldCoords, Matrix4 transformMatrix) { tmp.set(worldCoords.x, worldCoords.y, 0); tmp.mul(transformMatrix); camera.project(tmp); tmp.y = Gdx.graphics.getHeight() - tmp.y; worldCoords.x = tmp.x; worldCoords.y = tmp.y; return worldCoords; }
private void initializeText() { I18NBundle b = lm.getCurrentBundle(); title = b.get("bookTitle"); introduction = b.format("introduction", 81); body = b.get("body"); viewport.getCamera().project(point.set(SCENE_WIDTH * .70f, 0, 0)); textWidth = point.x; viewport.getCamera().project(point.set(SCENE_WIDTH * .15f, 0, 0)); textXOrigin = point.x; }
@Override public void render () { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); world.step(1/60f, 6, 2); if(title != null) { batch.begin(); viewport.getCamera().project(point.set(SCENE_WIDTH*0.5f, 6.8f, 0)); font.draw(batch, title, point.x - titleWidth, point.y); batch.end(); } debugRenderer.render(world, viewport.getCamera().combined); } }