org.lwjglb.engine.graph.Transformation.getViewMatrix()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(18.3k)|赞(0)|评价(0)|浏览(107)

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

Transformation.getViewMatrix介绍

暂无

代码示例

代码示例来源:origin: lwjglgamedev/lwjglbook

public void renderScene(Window window, Camera camera, Scene scene) {
  sceneShaderProgram.bind();
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  Matrix4f viewMatrix = transformation.getViewMatrix();
  SceneLight sceneLight = scene.getSceneLight();
  renderLights(viewMatrix, sceneLight);
  sceneShaderProgram.setUniform("texture_sampler", 0);
  // Render each mesh with the associated game Items
  Map<Mesh, List<GameItem>> mapMeshes = scene.getGameMeshes();
  for (Mesh mesh : mapMeshes.keySet()) {
    sceneShaderProgram.setUniform("material", mesh.getMaterial());
    mesh.renderList(mapMeshes.get(mesh), (GameItem gameItem) -> {
      Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(gameItem, viewMatrix);
      sceneShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    }
    );
  }
  sceneShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void renderScene(Window window, Camera camera, Scene scene) {
  sceneShaderProgram.bind();
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  Matrix4f viewMatrix = transformation.getViewMatrix();
  SceneLight sceneLight = scene.getSceneLight();
  renderLights(viewMatrix, sceneLight);
  sceneShaderProgram.setUniform("texture_sampler", 0);
  // Render each mesh with the associated game Items
  Map<Mesh, List<GameItem>> mapMeshes = scene.getGameMeshes();
  for (Mesh mesh : mapMeshes.keySet()) {
    sceneShaderProgram.setUniform("material", mesh.getMaterial());
    mesh.renderList(mapMeshes.get(mesh), (GameItem gameItem) -> {
      Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(gameItem, viewMatrix);
      sceneShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    }
    );
  }
  sceneShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void renderScene(Window window, Camera camera, Scene scene) {
  sceneShaderProgram.bind();
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  Matrix4f viewMatrix = transformation.getViewMatrix();
  SceneLight sceneLight = scene.getSceneLight();
  renderLights(viewMatrix, sceneLight);
  sceneShaderProgram.setUniform("texture_sampler", 0);
  sceneShaderProgram.setUniform("fog", scene.getFog());
  // Render each mesh with the associated game Items
  Map<Mesh, List<GameItem>> mapMeshes = scene.getGameMeshes();
  for (Mesh mesh : mapMeshes.keySet()) {
    sceneShaderProgram.setUniform("material", mesh.getMaterial());
    mesh.renderList(mapMeshes.get(mesh), (GameItem gameItem) -> {
      Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(gameItem, viewMatrix);
      sceneShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    }
    );
  }
  sceneShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void renderScene(Window window, Camera camera, GameItem[] gameItems,
    SceneLight sceneLight) {
  sceneShaderProgram.bind();
  // Update projection Matrix
  Matrix4f projectionMatrix = transformation.getProjectionMatrix(FOV, window.getWidth(), window.getHeight(), Z_NEAR, Z_FAR);
  sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  // Update view Matrix
  Matrix4f viewMatrix = transformation.getViewMatrix(camera);
  renderLights(viewMatrix, sceneLight);
  sceneShaderProgram.setUniform("texture_sampler", 0);
  // Render each gameItem
  for (GameItem gameItem : gameItems) {
    Mesh mesh = gameItem.getMesh();
    // Set model view matrix for this item
    Matrix4f modelViewMatrix = transformation.getModelViewMatrix(gameItem, viewMatrix);
    sceneShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    // Render the mesh for this game item
    sceneShaderProgram.setUniform("material", mesh.getMaterial());
    mesh.render();
  }
  sceneShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  skyBoxShaderProgram.bind();
  skyBoxShaderProgram.setUniform("texture_sampler", 0);
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  SkyBox skyBox = scene.getSkyBox();
  Matrix4f viewMatrix = transformation.getViewMatrix();
  viewMatrix.m30(0);
  viewMatrix.m31(0);
  viewMatrix.m32(0);
  Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
  skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
  skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
  scene.getSkyBox().getMesh().render();
  skyBoxShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  skyBoxShaderProgram.bind();
  skyBoxShaderProgram.setUniform("texture_sampler", 0);
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  SkyBox skyBox = scene.getSkyBox();
  Matrix4f viewMatrix = transformation.getViewMatrix();
  viewMatrix.m30(0);
  viewMatrix.m31(0);
  viewMatrix.m32(0);
  Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
  skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
  skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getAmbientLight());
  scene.getSkyBox().getMesh().render();
  skyBoxShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  skyBoxShaderProgram.bind();
  skyBoxShaderProgram.setUniform("texture_sampler", 0);
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  SkyBox skyBox = scene.getSkyBox();
  Matrix4f viewMatrix = transformation.getViewMatrix();
  viewMatrix.m30(0);
  viewMatrix.m31(0);
  viewMatrix.m32(0);
  Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
  skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
  skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
  scene.getSkyBox().getMesh().render();
  skyBoxShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  skyBoxShaderProgram.bind();
  skyBoxShaderProgram.setUniform("texture_sampler", 0);
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  SkyBox skyBox = scene.getSkyBox();
  Matrix4f viewMatrix = transformation.getViewMatrix();
  viewMatrix.m30(0);
  viewMatrix.m31(0);
  viewMatrix.m32(0);
  Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
  skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
  skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
  scene.getSkyBox().getMesh().render();
  skyBoxShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  SkyBox skyBox = scene.getSkyBox();
  if (skyBox != null) {
    skyBoxShaderProgram.bind();
    skyBoxShaderProgram.setUniform("texture_sampler", 0);
    Matrix4f projectionMatrix = transformation.getProjectionMatrix();
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    Matrix4f viewMatrix = transformation.getViewMatrix();
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
    scene.getSkyBox().getMesh().render();
    skyBoxShaderProgram.unbind();
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  SkyBox skyBox = scene.getSkyBox();
  if (skyBox != null) {
    skyBoxShaderProgram.bind();
    skyBoxShaderProgram.setUniform("texture_sampler", 0);
    Matrix4f projectionMatrix = transformation.getProjectionMatrix();
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    Matrix4f viewMatrix = transformation.getViewMatrix();
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
    scene.getSkyBox().getMesh().render();
    skyBoxShaderProgram.unbind();
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  SkyBox skyBox = scene.getSkyBox();
  if (skyBox != null) {
    skyBoxShaderProgram.bind();
    skyBoxShaderProgram.setUniform("texture_sampler", 0);
    Matrix4f projectionMatrix = transformation.getProjectionMatrix();
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    Matrix4f viewMatrix = transformation.getViewMatrix();
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
    scene.getSkyBox().getMesh().render();
    skyBoxShaderProgram.unbind();
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  SkyBox skyBox = scene.getSkyBox();
  if (skyBox != null) {
    skyBoxShaderProgram.bind();
    skyBoxShaderProgram.setUniform("texture_sampler", 0);
    Matrix4f projectionMatrix = transformation.getProjectionMatrix();
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    Matrix4f viewMatrix = transformation.getViewMatrix();
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
    scene.getSkyBox().getMesh().render();
    skyBoxShaderProgram.unbind();
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  SkyBox skyBox = scene.getSkyBox();
  if (skyBox != null) {
    skyBoxShaderProgram.bind();
    skyBoxShaderProgram.setUniform("texture_sampler", 0);
    Matrix4f projectionMatrix = transformation.getProjectionMatrix();
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    Matrix4f viewMatrix = transformation.getViewMatrix();
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
    scene.getSkyBox().getMesh().render();
    skyBoxShaderProgram.unbind();
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  SkyBox skyBox = scene.getSkyBox();
  if (skyBox != null) {
    skyBoxShaderProgram.bind();
    skyBoxShaderProgram.setUniform("texture_sampler", 0);
    Matrix4f projectionMatrix = transformation.getProjectionMatrix();
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    Matrix4f viewMatrix = transformation.getViewMatrix();
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
    scene.getSkyBox().getMesh().render();
    skyBoxShaderProgram.unbind();
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void renderScene(Window window, Camera camera, Scene scene) {
  sceneShaderProgram.bind();
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  Matrix4f orthoProjMatrix = transformation.getOrthoProjectionMatrix();
  sceneShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix);
  Matrix4f lightViewMatrix = transformation.getLightViewMatrix();
  Matrix4f viewMatrix = transformation.getViewMatrix();
  SceneLight sceneLight = scene.getSceneLight();
  renderLights(viewMatrix, sceneLight);
  sceneShaderProgram.setUniform("fog", scene.getFog());
  sceneShaderProgram.setUniform("texture_sampler", 0);
  sceneShaderProgram.setUniform("normalMap", 1);
  sceneShaderProgram.setUniform("shadowMap", 2);
  sceneShaderProgram.setUniform("renderShadow", scene.isRenderShadows() ? 1 : 0);
  renderNonInstancedMeshes(scene, sceneShaderProgram, viewMatrix, lightViewMatrix);
  renderInstancedMeshes(scene, sceneShaderProgram, viewMatrix, lightViewMatrix);
  sceneShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void renderScene(Window window, Camera camera, Scene scene) {
  sceneShaderProgram.bind();
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  Matrix4f orthoProjMatrix = transformation.getOrthoProjectionMatrix();
  sceneShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix);
  Matrix4f lightViewMatrix = transformation.getLightViewMatrix();
  Matrix4f viewMatrix = transformation.getViewMatrix();
  SceneLight sceneLight = scene.getSceneLight();
  renderLights(viewMatrix, sceneLight);
  sceneShaderProgram.setUniform("fog", scene.getFog());
  sceneShaderProgram.setUniform("texture_sampler", 0);
  sceneShaderProgram.setUniform("normalMap", 1);
  sceneShaderProgram.setUniform("shadowMap", 2);
  sceneShaderProgram.setUniform("renderShadow", scene.isRenderShadows() ? 1 : 0);
  renderNonInstancedMeshes(scene, sceneShaderProgram, viewMatrix, lightViewMatrix);
  renderInstancedMeshes(scene, sceneShaderProgram, viewMatrix, lightViewMatrix);
  sceneShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void renderScene(Window window, Camera camera, Scene scene) {
  sceneShaderProgram.bind();
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  Matrix4f orthoProjMatrix = transformation.getOrthoProjectionMatrix();
  sceneShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix);
  Matrix4f lightViewMatrix = transformation.getLightViewMatrix();
  Matrix4f viewMatrix = transformation.getViewMatrix();
  SceneLight sceneLight = scene.getSceneLight();
  renderLights(viewMatrix, sceneLight);
  sceneShaderProgram.setUniform("fog", scene.getFog());
  sceneShaderProgram.setUniform("texture_sampler", 0);
  sceneShaderProgram.setUniform("normalMap", 1);
  sceneShaderProgram.setUniform("shadowMap", 2);
  sceneShaderProgram.setUniform("renderShadow", scene.isRenderShadows() ? 1 : 0);
  renderNonInstancedMeshes(scene, false, sceneShaderProgram, viewMatrix, lightViewMatrix);
  renderInstancedMeshes(scene, false, sceneShaderProgram, viewMatrix, lightViewMatrix);
  sceneShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void renderScene(Window window, Camera camera, Scene scene) {
  sceneShaderProgram.bind();
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  Matrix4f orthoProjMatrix = transformation.getOrthoProjectionMatrix();
  sceneShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix);
  Matrix4f lightViewMatrix = transformation.getLightViewMatrix();
  Matrix4f viewMatrix = transformation.getViewMatrix();
  SceneLight sceneLight = scene.getSceneLight();
  renderLights(viewMatrix, sceneLight);
  sceneShaderProgram.setUniform("fog", scene.getFog());
  sceneShaderProgram.setUniform("texture_sampler", 0);
  sceneShaderProgram.setUniform("normalMap", 1);
  sceneShaderProgram.setUniform("shadowMap", 2);
  sceneShaderProgram.setUniform("renderShadow", scene.isRenderShadows() ? 1 : 0);
  renderNonInstancedMeshes(scene, sceneShaderProgram, viewMatrix, lightViewMatrix);
  renderInstancedMeshes(scene, sceneShaderProgram, viewMatrix, lightViewMatrix);
  sceneShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderSkyBox(Window window, Camera camera, Scene scene) {
  skyBoxShaderProgram.bind();
  skyBoxShaderProgram.setUniform("texture_sampler", 0);
  // Update projection Matrix
  Matrix4f projectionMatrix = transformation.getProjectionMatrix(FOV, window.getWidth(), window.getHeight(), Z_NEAR, Z_FAR);
  skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  SkyBox skyBox = scene.getSkyBox();
  Matrix4f viewMatrix = transformation.getViewMatrix(camera);
  viewMatrix.m30(0);
  viewMatrix.m31(0);
  viewMatrix.m32(0);
  Matrix4f modelViewMatrix = transformation.getModelViewMatrix(skyBox, viewMatrix);
  skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
  skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getAmbientLight());
      
  scene.getSkyBox().getMesh().render();
  skyBoxShaderProgram.unbind();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private void renderParticles(Window window, Camera camera, Scene scene) {
  particlesShaderProgram.bind();
  particlesShaderProgram.setUniform("texture_sampler", 0);
  Matrix4f projectionMatrix = transformation.getProjectionMatrix();
  particlesShaderProgram.setUniform("projectionMatrix", projectionMatrix);
  Matrix4f viewMatrix = transformation.getViewMatrix();
  IParticleEmitter[] emitters = scene.getParticleEmitters();
  int numEmitters = emitters != null ? emitters.length : 0;
  glDepthMask(false);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE);
  for (int i = 0; i < numEmitters; i++) {
    IParticleEmitter emitter = emitters[i];
    InstancedMesh mesh = (InstancedMesh)emitter.getBaseParticle().getMesh();
    Texture text = mesh.getMaterial().getTexture();
    particlesShaderProgram.setUniform("numCols", text.getNumCols());
    particlesShaderProgram.setUniform("numRows", text.getNumRows());
    mesh.renderListInstanced(emitter.getParticles(), true, transformation, viewMatrix, null);
  }
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glDepthMask(true);
  particlesShaderProgram.unbind();
}

相关文章