com.badlogic.gdx.math.Matrix4.setToProjection()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(74)

本文整理了Java中com.badlogic.gdx.math.Matrix4.setToProjection()方法的一些代码示例,展示了Matrix4.setToProjection()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix4.setToProjection()方法的具体详情如下:
包路径:com.badlogic.gdx.math.Matrix4
类名称:Matrix4
方法名:setToProjection

Matrix4.setToProjection介绍

[英]Sets the matrix to a projection matrix with a near- and far plane, a field of view in degrees and an aspect ratio. Note that the field of view specified is the angle in degrees for the height, the field of view for the width will be calculated according to the aspect ratio.
[中]将矩阵设置为具有近平面和远平面、以度为单位的视野和纵横比的投影矩阵。请注意,指定的视野是高度的角度(以度为单位),宽度的视野将根据纵横比计算。

代码示例

代码示例来源:origin: libgdx/libgdx

@Override
  public void update (boolean updateFrustum) {
    float aspect = viewportWidth / viewportHeight;
    projection.setToProjection(Math.abs(near), Math.abs(far), fieldOfView, aspect);
    view.setToLookAt(position, tmp.set(position).add(direction), up);
    combined.set(projection);
    Matrix4.mul(combined.val, view.val);

    if (updateFrustum) {
      invProjectionView.set(combined);
      Matrix4.inv(invProjectionView.val);
      frustum.update(invProjectionView);
    }
  }
}

代码示例来源:origin: libgdx/libgdx

@Override
  public void update (boolean updateFrustum) {
    float aspect = viewportWidth / viewportHeight;
    projection.setToProjection(Math.abs(near), Math.abs(far), fieldOfView, aspect);
    view.setToLookAt(position, tmp.set(position).add(direction), up);
    combined.set(projection);
    Matrix4.mul(combined.val, view.val);

    if (updateFrustum) {
      invProjectionView.set(combined);
      Matrix4.inv(invProjectionView.val);
      frustum.update(invProjectionView);
    }
  }
}

代码示例来源:origin: libgdx/libgdx

@Override
  public void render () {
    angle += Gdx.graphics.getDeltaTime() * 40.0f;
    float aspect = Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight();
    projection.setToProjection(1.0f, 20.0f, 60.0f, aspect);
    view.idt().trn(0, 0, -2.0f);
    model.setToRotation(axis, angle);
    combined.set(projection).mul(view).mul(model);

    Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
    Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
    shader.begin();
    shader.setUniformMatrix("u_mvpMatrix", combined);
    mesh.render(shader, GL20.GL_TRIANGLES);
    shader.end();

    Gdx.app.log("angle", "" + angle);
  }
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

@Override
  public void update (boolean updateFrustum) {
    float aspect = viewportWidth / viewportHeight;
    projection.setToProjection(Math.abs(near), Math.abs(far), fieldOfView, aspect);
    view.setToLookAt(position, tmp.set(position).add(direction), up);
    combined.set(projection);
    Matrix4.mul(combined.val, view.val);

    if (updateFrustum) {
      invProjectionView.set(combined);
      Matrix4.inv(invProjectionView.val);
      frustum.update(invProjectionView);
    }
  }
}

相关文章