Java Code Examples for com.badlogic.gdx.graphics.glutils.ShapeRenderer#rect()

The following examples show how to use com.badlogic.gdx.graphics.glutils.ShapeRenderer#rect() . 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: IBLBuilder.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
private void render(CubemapSide side, ShapeRenderer shapes, ShaderProgram shader, float strength, float exponent){
	shader.begin();
	shader.setUniformf("u_exponent", exponent);
	shader.setUniformf("u_ambient", color.r, color.g, color.b, 0f);
	shader.setUniformf("u_diffuse", color.r, color.g, color.b, strength);

	localDir.set(side.direction);
	localUp.set(side.up);
	
	// XXX patch
	if(side == CubemapSide.NegativeX || side == CubemapSide.PositiveX){
		localDir.x = -localDir.x;
	}
		
	matrix.setToLookAt(localDir, localUp).tra();
	localSunDir.set(direction).scl(-1, -1, 1).mul(matrix); // XXX patch again
	
	shader.setUniformf("u_direction", localSunDir);
	
	shapes.begin(ShapeType.Filled);
	shapes.rect(0, 0, 1, 1);
	shapes.end();
}
 
Example 2
Source File: Cursor.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public void render(PaletteIndexedBatch batch) {
  if (dc != null) {
    BBox box = dc.getBox();
    coords.set(Gdx.input.getX(), Gdx.input.getY());
    Riiablo.extendViewport.unproject(coords);
    coords.sub(box.width / 2f, box.height / 2f);

    batch.begin();
    batch.setColormap(transform, transformColor);
    if (item.isEthereal()) batch.setAlpha(Item.ETHEREAL_ALPHA);
    batch.draw(dc.getTexture(), coords.x, coords.y);
    if (item.isEthereal()) batch.resetColor();
    batch.resetColormap();
    batch.end();

    if (DEBUG_ITEM_BOUNDS) {
      ShapeRenderer shapes = Riiablo.shapes;
      shapes.setProjectionMatrix(Riiablo.extendViewport.getCamera().combined);
      shapes.begin(ShapeRenderer.ShapeType.Line);
      shapes.setColor(Color.GREEN);
      shapes.rect(coords.x, coords.y, box.width, box.height);
      shapes.end();
    }
  }
}
 
Example 3
Source File: Animation.java    From riiablo with Apache License 2.0 6 votes vote down vote up
protected void drawDebug(ShapeRenderer shapeRenderer, int d, int f, float x, float y) {
  boolean reset = !shapeRenderer.isDrawing();
  if (reset) {
    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
  } else {
    shapeRenderer.set(ShapeRenderer.ShapeType.Line);
  }

  shapeRenderer.setColor(Color.RED);
  shapeRenderer.line(x, y, x + 40, y);
  shapeRenderer.setColor(Color.GREEN);
  shapeRenderer.line(x, y, x, y + 20);
  shapeRenderer.setColor(Color.BLUE);
  shapeRenderer.line(x, y, x + 20, y - 10);

  BBox box = dc.getBox(d, f);
  shapeRenderer.setColor(DEBUG_COLOR);
  shapeRenderer.rect(x + box.xMin, y - box.yMax, box.width, box.height);
  if (reset) shapeRenderer.end();
}
 
Example 4
Source File: OrthographicProjection.java    From ud405 with MIT License 6 votes vote down vote up
/**
 * This method renders a few shapes for us to try our camera on. Note that we're using a Bezier
 * curve, which is a way to draw smooth curves. For more information on Bezier curves, check
 * out: https://en.wikipedia.org/wiki/B%C3%A9zier_curve
 *
 * Also note that a line is a line is a line. No matter how much we zoom in, a line is always
 * just one pixel wide.
 */
private void renderTestScene(ShapeRenderer renderer) {
    renderer.begin(ShapeType.Filled);
    renderer.setColor(Color.GREEN);
    renderer.circle(100, 100, 90);
    renderer.setColor(Color.RED);
    renderer.rect(200, 10, 200, 200);
    renderer.setColor(Color.YELLOW);
    renderer.triangle(10, 200, 200, 200, 100, 400);
    renderer.end();
    renderer.begin(ShapeType.Line);

    renderer.setColor(Color.CYAN);

    // Here's another shape ShapeRenderer
    renderer.curve(
            210, 210,
            400, 210,
            210, 400,
            400, 300,
            20);
    renderer.end();
}
 
Example 5
Source File: Box2dSteeringTest.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected void renderBox (ShapeRenderer shapeRenderer, Body body, float halfWidth, float halfHeight) {
	// get the bodies center and angle in world coordinates
	Vector2 pos = body.getWorldCenter();
	float angle = body.getAngle();

	// set the translation and rotation matrix
	transform.setToTranslation(Box2dSteeringTest.metersToPixels(pos.x), Box2dSteeringTest.metersToPixels(pos.y), 0);
	transform.rotate(0, 0, 1, angle * MathUtils.radiansToDegrees);

	// render the box
	shapeRenderer.begin(ShapeType.Line);
	shapeRenderer.setTransformMatrix(transform);
	shapeRenderer.setColor(1, 1, 1, 1);
	shapeRenderer.rect(-halfWidth, -halfHeight, halfWidth * 2, halfHeight * 2);
	shapeRenderer.end();
}
 
Example 6
Source File: Scene2dRaycastObstacleAvoidanceTest.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
private void renderBox (ShapeRenderer shapeRenderer, Body body, float halfWidth, float halfHeight) {
	// get the bodies center and angle in world coordinates
	Vector2 pos = body.getWorldCenter();
	float angle = body.getAngle();

	// set the translation and rotation matrix
	transform.setToTranslation(pos.x, pos.y, 0);
	transform.rotate(0, 0, 1, (float)Math.toDegrees(angle));

	// render the box
	shapeRenderer.begin(ShapeType.Line);
	shapeRenderer.setTransformMatrix(transform);
	shapeRenderer.setColor(1, 1, 1, 1);
	shapeRenderer.rect(-halfWidth, -halfHeight, halfWidth * 2, halfHeight * 2);
	shapeRenderer.end();
}
 
Example 7
Source File: TransformScalableWrapper.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
@Override
protected void drawDebugBounds(ShapeRenderer shapes) {
    if (!getDebug()) return;
    shapes.set(ShapeRenderer.ShapeType.Line);
    shapes.setColor(getStage().getDebugColor());
    shapes.rect(getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), 1f, 1f, getRotation());
}
 
Example 8
Source File: TransformScalableWrapper.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
protected void drawDebugBounds(ShapeRenderer shapes) {
    if (!getDebug()) return;
    shapes.set(ShapeRenderer.ShapeType.Line);
    shapes.setColor(getStage().getDebugColor());
    shapes.rect(getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), 1f, 1f, getRotation());
}
 
Example 9
Source File: RenderSystem.java    From riiablo with Apache License 2.0 5 votes vote down vote up
private void drawDebugCamera(ShapeRenderer shapes) {
  Vector2 tmp = tmpVec2.set(this.currentPos);
  iso.toScreen(tmp);
  float viewportWidth  = width;
  float viewportHeight = height;
  shapes.setColor(Color.GREEN);
  shapes.rect(
      tmp.x - MathUtils.ceil(viewportWidth  / 2) - 1,
      tmp.y - MathUtils.ceil(viewportHeight / 2) - 1,
      viewportWidth + 2, viewportHeight + 2);
}
 
Example 10
Source File: Animation.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public void drawDebug(ShapeRenderer shapes, float x, float y) {
  if (DEBUG_MODE == 0) {
    return;
  } else if (DEBUG_MODE == 1 || cof == null) {
    boolean reset = !shapes.isDrawing();
    if (reset) {
      shapes.begin(ShapeRenderer.ShapeType.Line);
    } else {
      shapes.set(ShapeRenderer.ShapeType.Line);
    }

    shapes.setColor(Color.RED);
    shapes.line(x, y, x + 50, y);
    shapes.setColor(Color.GREEN);
    shapes.line(x, y, x, y + 50);
    shapes.setColor(Color.BLUE);
    shapes.line(x, y, x + 15, y - 20);
    shapes.setColor(Color.GREEN);
    shapes.rect(x + box.xMin, y - box.yMax, box.width, box.height);
    if (reset) shapes.end();
  } else if (DEBUG_MODE == 2 && frame < numFrames) {
    int d = DC.Direction.toReadDir(direction, cof.getNumDirections());
    int f = frame;
    for (int l = 0; l < cof.getNumLayers(); l++) {
      int component = cof.getLayerOrder(d, f, l);
      Layer layer = layers[component];
      if (layer != null) layer.drawDebug(shapes, d, f, x, y);
    }
  }
}
 
Example 11
Source File: CheckerBoard.java    From ud405 with MIT License 5 votes vote down vote up
public static void render(ShapeRenderer renderer, Vector2 bottomLeft, Vector2 topRight, float squareSize){
    int yIndex = 0;
    for (float yStart = bottomLeft.y; yStart < topRight.y; yStart += squareSize){
        yIndex++;
        int xIndex = 0;
        for (float xStart = bottomLeft.x; xStart < topRight.x; xStart += squareSize){
            xIndex++;
            if ((xIndex + yIndex) % 2 == 0){
                renderer.rect(xStart, yStart, squareSize, squareSize);

            }
        }
    }
}
 
Example 12
Source File: Platform.java    From ud406 with MIT License 3 votes vote down vote up
public void render(ShapeRenderer renderer) {

        // TODO: Draw a box representing the platform
        float width = right - left;
        float height = top - bottom;

        renderer.setColor(Color.BLUE);
        renderer.rect(left, bottom, width, height);

    }