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

The following examples show how to use com.badlogic.gdx.graphics.glutils.ShapeRenderer#setTransformMatrix() . 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: 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 2
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 3
Source File: Rain.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public void draw(Batch batch, float parentAlpha) {
    validate();
    batch.end();
    Gdx.gl.glClearColor(0, 0, 0, 0);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    ShapeRenderer renderer = Config.shapeRenderer;
    renderer.setProjectionMatrix(batch.getProjectionMatrix());
    renderer.setTransformMatrix(batch.getTransformMatrix());

    renderer.begin(ShapeRenderer.ShapeType.Filled);
    renderer.setColor(style.color.r, style.color.g, style.color.b, style.color.a * parentAlpha);
    float usedWidth = getWidth() - style.pad;
    int count = (int) (usedWidth / (style.dropWidth + style.pad));
    if (count == 0)
        return;
    float step = usedWidth / ((float) count);
    float x = style.pad;
    for (int i = 0, n = rows.size; i < n; i++) {
        Row row = rows.get(i);
        drawRow(x, row);
        x += step;
    }
    renderer.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
}