我目前正在试验libgdx中的不同相机(使用ShapeRenderer)。但是我发现在某些旋转时它会停止渲染形状的片段。
例如带相机的正常形状 职位:(8.999996,7.699995,5.599995) 方向:(0.04838332,-0.60004705,-0.7576189):
但是用相机 职位:(8.999996,7.699995,5.0999956) 方向:(0.6789076,-0.57323986,-0.38322547):
据我所知,在PerspectiveCamera上没有发生这种情况(我没有对它进行过广泛的测试,但我可能错了)。
代码段
AUX。的信息:
VIEWPORT_WIDTH = 20;
VIEWPORT_HEIGHT = 13;
gridDist = 1.2f;
每个图块的x和y是一个整数(就像一个网格)。
设置相机(我正在使用Scene2D.Stage):
public MainStage(){
super(new ScalingViewport(Scaling.stretch, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())));
camera = (OrthographicCamera) this.getCamera();
camera.direction.set(0f, 0.3f,-0.92f);
camera.position.set(10f,0f,10f);
camera.update();
}
绘制图块(X / Y坐标):
renderer.setProjectionMatrix(camera.combined);
renderer.begin(ShapeType.Line);
renderer.setColor(1, 1, 0, 1);
for(GridTile[] trow: room.tiles){
for(GridTile tile: trow){
if(tile.status != EMPTY){
if(tile.status == FULL){
renderer.rect(tile.x*gridDist, tile.y*gridDist, gridDist, gridDist);
}
else if(tile.status == UP_RIGHT){
renderer.triangle((tile.x+1)*gridDist, tile.y*gridDist, (tile.x+1)*gridDist, (tile.y+1)*gridDist, (tile.x)*gridDist, (tile.y+1)*gridDist);
}
else if(tile.status == DOWN_RIGHT){
renderer.triangle((tile.x)*gridDist, tile.y*gridDist, (tile.x+1)*gridDist, (tile.y)*gridDist, (tile.x+1)*gridDist, (tile.y+1)*gridDist);
}
else if(tile.status == DOWN_LEFT){
renderer.triangle((tile.x)*gridDist, tile.y*gridDist, (tile.x+1)*gridDist, (tile.y)*gridDist, (tile.x)*gridDist, (tile.y+1)*gridDist);
}
else if(tile.status == UP_LEFT){
renderer.triangle((tile.x)*gridDist, tile.y*gridDist, (tile.x+1)*gridDist, (tile.y+1)*gridDist, (tile.x)*gridDist, (tile.y+1)*gridDist);
}
}
}
}
renderer.end();
有谁知道为什么会发生这种情况以及是否可以预防?
提前致谢。
答案 0 :(得分:0)
在正交摄影机中,默认值为0(近)和100(远),这些值对应于飞机与照相机之间的距离,根据文档,它们必须为正https://libgdx.badlogicgames.com/ci/nightlies/docs/api/com/badlogic/gdx/graphics/Camera.html#near,但我有尝试了负值而没有问题(平面位于相机后面)
远近值可以轻松修改
Contact