【发布时间】:2016-06-14 23:05:32
【问题描述】:
我正在尝试创建一个四向对称程序,它有 1 个摄像头查看特定场景,但只是翻转 4 个面板中每个面板的摄像头视图。
例如:symmetry
象限 1 将是世界的常规方向,正 x 向右,正 y 向上。 象限 2 将是左侧的正 x 和向上的正 y,依此类推。
我想出了一种方法,通过多次启动和结束我的 spritebatch(不确定这是否是一件坏事,但这是我让它工作的方式)并更改 glViewport 来在多个面板中绘制相同的相机视图每个面板。
batch.setProjectionMatrix(cam.combined);
batch.begin();
Gdx.gl.glViewport(0,Gdx.graphics.getHeight()/2,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);
batch.draw(img, 0, 0);
batch.end();
batch.begin();
Gdx.gl.glViewport(0,0,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);
batch.draw(img, 0, 0);
batch.end();
batch.begin();
Gdx.gl.glViewport(Gdx.graphics.getWidth()/2,0,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);
batch.draw(img, 0, 0);
batch.end();
batch.begin();
Gdx.gl.glViewport(Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);
batch.draw(img, 0, 0);
batch.end();
我认为线性变换可以做到这一点,但我对 libgdx 或线性代数的使用还不足以立即看到明确的答案。
任何帮助将不胜感激。谢谢。
【问题讨论】: