JAVA移动摄像头_java libgdx移动透视摄像头

我正在创建一个3D游戏,但我不知道如何根据我的手指翻译相机.我正在创建一个地图(x = -30到30; y = -30到30; z = -1到1),其中每个坐标用于使用我的资产中的.g3db文件的模型,并使用模型转换到位.这项工作到目前为止,地图看起来很好,并以67%的角度观看.地图太大,无法立即在相机中查看(不,我不想缩小).每当我触摸我的

Android手机屏幕时,它只是围绕中心旋转,而是我希望游戏地图从我的视角保持不变,而是改变透视摄像机在x和y轴上的位置.没有可用于位置跟踪的游戏对象,一切都应该取决于我的手指动作.这样我想要移动到每个x和y方向的可见屏幕(想象它看起来像2D摄像机向上,向下和向前移动到图片前面).你能帮助我吗?

到目前为止这是我的代码:

public class MyGdxGame extends ApplicationAdapter implements ApplicationListener{

//define variables

...

@Override

public void create() {

environment = new Environment();

environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));

environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));

modelBatch = new ModelBatch();

cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

cam.position.set(10f, 10f, 10f);

cam.lookAt(0,0,0);

cam.near = 1f;

cam.far = 300f;

cam.update();

assets = new AssetManager();

//load assets

...

loading = true;

camController = new CameraInputController(cam);

camController.forwardTarget = true;

Gdx.input.setInputProcessor(camController);

}

private void doneLoading() {

//load models and add them to instances

loading = false

}

@Override

public void render() {

if (loading && assets.update())

doneLoading();

camController.update();

Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

modelBatch.begin(cam);

modelBatch.render(instances, environment);

modelBatch.end();

}

我使用Spring工具套件3.5.1作为IDE和libgdx 1.0.1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值