LibGDX 3DSphere在使用鼠标

时间:2017-10-20 07:42:19

标签: java 3d libgdx game-development perspectivecamera

我通过使用libGDX在modelBuilder上调用createSphere()方法,使用Texture创建了一个球体。因为它是3D,我使用了Perspective Camera。我试图用鼠标在屏幕上移动球体。它的工作正常,但球体在屏幕上移动时一直在改变它的形状。

我试过改变透视相机的位置和外观。形状仍在变化。任何人都可以提出解决方案。

以下是我的代码部分:

    modelBatch = new ModelBatch();
    ModelBuilder modelBuilder = new ModelBuilder();
    Texture texture = new Texture(Gdx.files.internal("ball.png"));
    Material material = new 
    Material(TextureAttribute.createDiffuse(texture));
    final long attributes = VertexAttributes.Usage.Position | 
    VertexAttributes.Usage.TextureCoordinates;
    sphere = modelBuilder.createSphere(0.5f, 0.5f, 0.5f, 24, 24, material, attributes);
    sphereInstance = new ModelInstance(sphere);

    perCamera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), 
    Gdx.graphics.getHeight());
    perCamera.position.set(0f, 0f, 3f);
    perCamera.lookAt(0f,0f,0f);
    perCamera.near = 1f;
    perCamera.far = 300f;
    perCamera.update();
    [Here I have attached screenshot for the reference, in which the regular sphere changes its shape to ellipse as it is moving away from the camera.][1]

0 个答案:

没有答案