LibGdx不能在浮动空间中正确绘制圆圈

时间:2013-01-22 08:41:14

标签: android math libgdx

我的相机设置为标准化空间(高度为1个单位,宽度为1.5个单位)。但似乎ShapeRenderer的圆形算法仅适用于整数空间。有解决方法吗?

public void create() {
    camera = new OrthographicCamera();
    camera.setToOrtho(false, 1.5f, 1f);
    shapes = new ShapeRenderer();
}

public void drawScene() {
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    shapes.setProjectionMatrix(camera.combined);
    shapes.begin(ShapeType.Circle);
    shapes.setColor(1, 0, 0, 1);
    shapes.circle(0.75f, 0.5f,0.5f);
    shapes.end();
}

It should be a circle

1 个答案:

答案 0 :(得分:3)

ShapeRenderer使用6 times the cube root of the radius来估算绘制圆圈所需的细分数。

在你的情况下你最终有4个段(6 * 0.793大约是4.76)。这就是你所看到的。

ShapeRenderer假设单位是the documentation的屏幕像素,因此这些是合理的估算值。