本文整理了Java中org.lwjglb.engine.Window.getProjectionMatrix()
方法的一些代码示例,展示了Window.getProjectionMatrix()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getProjectionMatrix()
方法的具体详情如下:
包路径:org.lwjglb.engine.Window
类名称:Window
方法名:getProjectionMatrix
暂无
代码示例来源:origin: lwjglgamedev/lwjglbook
public void selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
// Transform mouse coordinates into normalized spaze [-1, 1]
int wdwWitdh = window.getWidth();
int wdwHeight = window.getHeight();
float x = (float)(2 * mousePos.x) / (float)wdwWitdh - 1.0f;
float y = 1.0f - (float)(2 * mousePos.y) / (float)wdwHeight;
float z = -1.0f;
invProjectionMatrix.set(window.getProjectionMatrix());
invProjectionMatrix.invert();
tmpVec.set(x, y, z, 1.0f);
tmpVec.mul(invProjectionMatrix);
tmpVec.z = -1.0f;
tmpVec.w = 0.0f;
Matrix4f viewMatrix = camera.getViewMatrix();
invViewMatrix.set(viewMatrix);
invViewMatrix.invert();
tmpVec.mul(invViewMatrix);
mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);
selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public boolean selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
// Transform mouse coordinates into normalized spaze [-1, 1]
int wdwWitdh = window.getWidth();
int wdwHeight = window.getHeight();
float x = (float)(2 * mousePos.x) / (float)wdwWitdh - 1.0f;
float y = 1.0f - (float)(2 * mousePos.y) / (float)wdwHeight;
float z = -1.0f;
invProjectionMatrix.set(window.getProjectionMatrix());
invProjectionMatrix.invert();
tmpVec.set(x, y, z, 1.0f);
tmpVec.mul(invProjectionMatrix);
tmpVec.z = -1.0f;
tmpVec.w = 0.0f;
Matrix4f viewMatrix = camera.getViewMatrix();
invViewMatrix.set(viewMatrix);
invViewMatrix.invert();
tmpVec.mul(invViewMatrix);
mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);
return selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public boolean selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
// Transform mouse coordinates into normalized spaze [-1, 1]
int wdwWitdh = window.getWidth();
int wdwHeight = window.getHeight();
float x = (float)(2 * mousePos.x) / (float)wdwWitdh - 1.0f;
float y = 1.0f - (float)(2 * mousePos.y) / (float)wdwHeight;
float z = -1.0f;
invProjectionMatrix.set(window.getProjectionMatrix());
invProjectionMatrix.invert();
tmpVec.set(x, y, z, 1.0f);
tmpVec.mul(invProjectionMatrix);
tmpVec.z = -1.0f;
tmpVec.w = 0.0f;
Matrix4f viewMatrix = camera.getViewMatrix();
invViewMatrix.set(viewMatrix);
invViewMatrix.invert();
tmpVec.mul(invViewMatrix);
mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);
return selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public boolean selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
// Transform mouse coordinates into normalized spaze [-1, 1]
int wdwWitdh = window.getWidth();
int wdwHeight = window.getHeight();
float x = (float)(2 * mousePos.x) / (float)wdwWitdh - 1.0f;
float y = 1.0f - (float)(2 * mousePos.y) / (float)wdwHeight;
float z = -1.0f;
invProjectionMatrix.set(window.getProjectionMatrix());
invProjectionMatrix.invert();
tmpVec.set(x, y, z, 1.0f);
tmpVec.mul(invProjectionMatrix);
tmpVec.z = -1.0f;
tmpVec.w = 0.0f;
Matrix4f viewMatrix = camera.getViewMatrix();
invViewMatrix.set(viewMatrix);
invViewMatrix.invert();
tmpVec.mul(invViewMatrix);
mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);
return selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public boolean selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
// Transform mouse coordinates into normalized spaze [-1, 1]
int wdwWitdh = window.getWidth();
int wdwHeight = window.getHeight();
float x = (float)(2 * mousePos.x) / (float)wdwWitdh - 1.0f;
float y = 1.0f - (float)(2 * mousePos.y) / (float)wdwHeight;
float z = -1.0f;
invProjectionMatrix.set(window.getProjectionMatrix());
invProjectionMatrix.invert();
tmpVec.set(x, y, z, 1.0f);
tmpVec.mul(invProjectionMatrix);
tmpVec.z = -1.0f;
tmpVec.w = 0.0f;
Matrix4f viewMatrix = camera.getViewMatrix();
invViewMatrix.set(viewMatrix);
invViewMatrix.invert();
tmpVec.mul(invViewMatrix);
mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);
return selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public boolean selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
// Transform mouse coordinates into normalized spaze [-1, 1]
int wdwWitdh = window.getWidth();
int wdwHeight = window.getHeight();
float x = (float)(2 * mousePos.x) / (float)wdwWitdh - 1.0f;
float y = 1.0f - (float)(2 * mousePos.y) / (float)wdwHeight;
float z = -1.0f;
invProjectionMatrix.set(window.getProjectionMatrix());
invProjectionMatrix.invert();
tmpVec.set(x, y, z, 1.0f);
tmpVec.mul(invProjectionMatrix);
tmpVec.z = -1.0f;
tmpVec.w = 0.0f;
Matrix4f viewMatrix = camera.getViewMatrix();
invViewMatrix.set(viewMatrix);
invViewMatrix.invert();
tmpVec.mul(invViewMatrix);
mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);
return selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public boolean selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
// Transform mouse coordinates into normalized spaze [-1, 1]
int wdwWitdh = window.getWidth();
int wdwHeight = window.getHeight();
float x = (float)(2 * mousePos.x) / (float)wdwWitdh - 1.0f;
float y = 1.0f - (float)(2 * mousePos.y) / (float)wdwHeight;
float z = -1.0f;
invProjectionMatrix.set(window.getProjectionMatrix());
invProjectionMatrix.invert();
tmpVec.set(x, y, z, 1.0f);
tmpVec.mul(invProjectionMatrix);
tmpVec.z = -1.0f;
tmpVec.w = 0.0f;
Matrix4f viewMatrix = camera.getViewMatrix();
invViewMatrix.set(viewMatrix);
invViewMatrix.invert();
tmpVec.mul(invViewMatrix);
mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);
return selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public boolean selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
// Transform mouse coordinates into normalized spaze [-1, 1]
int wdwWitdh = window.getWidth();
int wdwHeight = window.getHeight();
float x = (float)(2 * mousePos.x) / (float)wdwWitdh - 1.0f;
float y = 1.0f - (float)(2 * mousePos.y) / (float)wdwHeight;
float z = -1.0f;
invProjectionMatrix.set(window.getProjectionMatrix());
invProjectionMatrix.invert();
tmpVec.set(x, y, z, 1.0f);
tmpVec.mul(invProjectionMatrix);
tmpVec.z = -1.0f;
tmpVec.w = 0.0f;
Matrix4f viewMatrix = camera.getViewMatrix();
invViewMatrix.set(viewMatrix);
invViewMatrix.invert();
tmpVec.mul(invViewMatrix);
mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);
return selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void render(Window window, Camera camera, Scene scene) {
clear();
frustumFilter.updateFrustum(window.getProjectionMatrix(), camera.getViewMatrix());
frustumFilter.filter(scene.getGameMeshes());
frustumFilter.filter(scene.getGameInstancedMeshes());
// Render depth map before view ports has been set up
renderDepthMap(window, camera, scene);
glViewport(0, 0, window.getWidth(), window.getHeight());
// Update projection matrix once per render cycle
window.updateProjectionMatrix();
renderScene(window, camera, scene);
renderSkyBox(window, camera, scene);
renderParticles(window, camera, scene);
//renderAxes(camera);
renderCrossHair(window);
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void render(Window window, Camera camera, Scene scene, boolean sceneChanged) {
clear();
if (window.getOptions().frustumCulling) {
frustumFilter.updateFrustum(window.getProjectionMatrix(), camera.getViewMatrix());
frustumFilter.filter(scene.getGameMeshes());
frustumFilter.filter(scene.getGameInstancedMeshes());
}
// Render depth map before view ports has been set up
if (scene.isRenderShadows() && sceneChanged) {
shadowRenderer.render(window, scene, camera, transformation, this);
}
glViewport(0, 0, window.getWidth(), window.getHeight());
// Update projection matrix once per render cycle
window.updateProjectionMatrix();
renderScene(window, camera, scene);
renderSkyBox(window, camera, scene);
renderParticles(window, camera, scene);
//renderAxes(camera);
//renderCrossHair(window);
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void render(Window window, Camera camera, Scene scene) {
clear();
if (window.getOptions().frustumCulling) {
frustumFilter.updateFrustum(window.getProjectionMatrix(), camera.getViewMatrix());
frustumFilter.filter(scene.getGameMeshes());
frustumFilter.filter(scene.getGameInstancedMeshes());
}
// Render depth map before view ports has been set up
renderDepthMap(window, camera, scene);
glViewport(0, 0, window.getWidth(), window.getHeight());
// Update projection matrix once per render cycle
window.updateProjectionMatrix();
renderScene(window, camera, scene);
renderSkyBox(window, camera, scene);
renderParticles(window, camera, scene);
//renderAxes(camera);
renderCrossHair(window);
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void renderScene(Window window, Camera camera, Scene scene) {
sceneShaderProgram.bind();
Matrix4f projectionMatrix = window.getProjectionMatrix();
sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
Matrix4f orthoProjMatrix = transformation.getOrthoProjectionMatrix();
sceneShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix);
Matrix4f lightViewMatrix = transformation.getLightViewMatrix();
Matrix4f viewMatrix = camera.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 render(Window window, Camera camera, Scene scene, boolean sceneChanged) {
clear();
if (window.getOptions().frustumCulling) {
frustumFilter.updateFrustum(window.getProjectionMatrix(), camera.getViewMatrix());
frustumFilter.filter(scene.getGameMeshes());
frustumFilter.filter(scene.getGameInstancedMeshes());
}
// Render depth map before view ports has been set up
if (scene.isRenderShadows() && sceneChanged) {
shadowRenderer.render(window, scene, camera, transformation, this);
}
glViewport(0, 0, window.getWidth(), window.getHeight());
// Update projection matrix once per render cycle
window.updateProjectionMatrix();
renderScene(window, camera, scene);
renderSkyBox(window, camera, scene);
renderParticles(window, camera, scene);
//renderAxes(camera);
renderCrossHair(window);
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void renderScene(Window window, Camera camera, Scene scene) {
sceneShaderProgram.bind();
Matrix4f projectionMatrix = window.getProjectionMatrix();
sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
Matrix4f orthoProjMatrix = transformation.getOrthoProjectionMatrix();
sceneShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix);
Matrix4f lightViewMatrix = transformation.getLightViewMatrix();
Matrix4f viewMatrix = camera.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 = window.getProjectionMatrix();
sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
Matrix4f orthoProjMatrix = transformation.getOrthoProjectionMatrix();
sceneShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix);
Matrix4f lightViewMatrix = transformation.getLightViewMatrix();
Matrix4f viewMatrix = camera.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 = window.getProjectionMatrix();
sceneShaderProgram.setUniform("projectionMatrix", projectionMatrix);
Matrix4f orthoProjMatrix = transformation.getOrthoProjectionMatrix();
sceneShaderProgram.setUniform("orthoProjectionMatrix", orthoProjMatrix);
Matrix4f lightViewMatrix = transformation.getLightViewMatrix();
Matrix4f viewMatrix = camera.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 render(Window window, Camera camera, Scene scene, boolean sceneChanged) {
clear();
if (window.getOptions().frustumCulling) {
frustumFilter.updateFrustum(window.getProjectionMatrix(), camera.getViewMatrix());
frustumFilter.filter(scene.getGameMeshes());
frustumFilter.filter(scene.getGameInstancedMeshes());
}
// Render depth map before view ports has been set up
if (scene.isRenderShadows() && sceneChanged) {
shadowRenderer.render(window, scene, camera, transformation, this);
}
glViewport(0, 0, window.getWidth(), window.getHeight());
// Update projection matrix once per render cycle
window.updateProjectionMatrix();
renderScene(window, camera, scene);
renderSkyBox(window, camera, scene);
renderParticles(window, camera, scene);
//renderAxes(camera);
renderCrossHair(window);
}
代码示例来源:origin: lwjglgamedev/lwjglbook
private void renderParticles(Window window, Camera camera, Scene scene) {
particlesShaderProgram.bind();
particlesShaderProgram.setUniform("texture_sampler", 0);
Matrix4f projectionMatrix = window.getProjectionMatrix();
particlesShaderProgram.setUniform("projectionMatrix", projectionMatrix);
Matrix4f viewMatrix = camera.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();
}
代码示例来源:origin: lwjglgamedev/lwjglbook
private void renderParticles(Window window, Camera camera, Scene scene) {
particlesShaderProgram.bind();
particlesShaderProgram.setUniform("texture_sampler", 0);
Matrix4f projectionMatrix = window.getProjectionMatrix();
particlesShaderProgram.setUniform("projectionMatrix", projectionMatrix);
Matrix4f viewMatrix = camera.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();
}
代码示例来源:origin: lwjglgamedev/lwjglbook
private void renderParticles(Window window, Camera camera, Scene scene) {
particlesShaderProgram.bind();
particlesShaderProgram.setUniform("texture_sampler", 0);
Matrix4f projectionMatrix = window.getProjectionMatrix();
particlesShaderProgram.setUniform("projectionMatrix", projectionMatrix);
Matrix4f viewMatrix = camera.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();
}
内容来源于网络,如有侵权,请联系作者删除!