public PointLight(PointLight pointLight) { this(new Vector3f(pointLight.getColor()), new Vector3f(pointLight.getPosition()), pointLight.getIntensity(), pointLight.getAttenuation()); }
for (int i = 0; i < numLights; i++) { PointLight currPointLight = new PointLight(pointLightList[i]); Vector3f lightPos = currPointLight.getPosition(); Vector4f aux = new Vector4f(lightPos, 1); aux.mul(viewMatrix); dir.mul(viewMatrix); currSpotLight.setConeDirection(new Vector3f(dir.x, dir.y, dir.z)); Vector3f lightPos = currSpotLight.getPointLight().getPosition();
pointLight = new PointLight(new Vector3f(1, 1, 1), lightPosition, lightIntensity); PointLight.Attenuation att = new PointLight.Attenuation(0.0f, 0.0f, 1.0f); pointLight.setAttenuation(att); pointLight = new PointLight(new Vector3f(1, 1, 1), lightPosition, lightIntensity); att = new PointLight.Attenuation(0.0f, 0.0f, 0.02f); pointLight.setAttenuation(att); Vector3f coneDir = new Vector3f(0, 0, -1); float cutoff = (float) Math.cos(Math.toRadians(140));
public SpotLight(SpotLight spotLight) { this(new PointLight(spotLight.getPointLight()), new Vector3f(spotLight.getConeDirection()), 0); setCutOff(spotLight.getCutOff()); }
@Override public void input(Window window, MouseInput mouseInput) { cameraInc.set(0, 0, 0); if (window.isKeyPressed(GLFW_KEY_W)) { cameraInc.z = -1; } else if (window.isKeyPressed(GLFW_KEY_S)) { cameraInc.z = 1; } if (window.isKeyPressed(GLFW_KEY_A)) { cameraInc.x = -1; } else if (window.isKeyPressed(GLFW_KEY_D)) { cameraInc.x = 1; } if (window.isKeyPressed(GLFW_KEY_Z)) { cameraInc.y = -1; } else if (window.isKeyPressed(GLFW_KEY_X)) { cameraInc.y = 1; } float lightPos = pointLight.getPosition().z; if (window.isKeyPressed(GLFW_KEY_N)) { this.pointLight.getPosition().z = lightPos + 0.1f; } else if (window.isKeyPressed(GLFW_KEY_M)) { this.pointLight.getPosition().z = lightPos - 0.1f; } }
for (int i = 0; i < numLights; i++) { PointLight currPointLight = new PointLight(pointLightList[i]); Vector3f lightPos = currPointLight.getPosition(); Vector4f aux = new Vector4f(lightPos, 1); aux.mul(viewMatrix); currSpotLight.setConeDirection(new Vector3f(dir.x, dir.y, dir.z)); Vector3f lightPos = currSpotLight.getPointLight().getPosition(); Vector4f aux = new Vector4f(lightPos, 1); aux.mul(viewMatrix);
PointLight pointLight = new PointLight(new Vector3f(1, 1, 1), lightPosition, lightIntensity); PointLight.Attenuation att = new PointLight.Attenuation(0.0f, 0.0f, 1.0f); pointLight.setAttenuation(att); pointLightList = new PointLight[]{pointLight}; pointLight = new PointLight(new Vector3f(1, 1, 1), lightPosition, lightIntensity); att = new PointLight.Attenuation(0.0f, 0.0f, 0.02f); pointLight.setAttenuation(att); Vector3f coneDir = new Vector3f(0, 0, -1); float cutoff = (float) Math.cos(Math.toRadians(140));
public SpotLight(SpotLight spotLight) { this(new PointLight(spotLight.getPointLight()), new Vector3f(spotLight.getConeDirection()), 0); setCutOff(spotLight.getCutOff()); }
@Override public void input(Window window, MouseInput mouseInput) { cameraInc.set(0, 0, 0); if (window.isKeyPressed(GLFW_KEY_W)) { cameraInc.z = -1; } else if (window.isKeyPressed(GLFW_KEY_S)) { cameraInc.z = 1; } if (window.isKeyPressed(GLFW_KEY_A)) { cameraInc.x = -1; } else if (window.isKeyPressed(GLFW_KEY_D)) { cameraInc.x = 1; } if (window.isKeyPressed(GLFW_KEY_Z)) { cameraInc.y = -1; } else if (window.isKeyPressed(GLFW_KEY_X)) { cameraInc.y = 1; } float lightPos = pointLight.getPosition().z; if (window.isKeyPressed(GLFW_KEY_N)) { this.pointLight.getPosition().z = lightPos + 0.1f; } else if (window.isKeyPressed(GLFW_KEY_M)) { this.pointLight.getPosition().z = lightPos - 0.1f; } }
public PointLight(PointLight pointLight) { this(new Vector3f(pointLight.getColor()), new Vector3f(pointLight.getPosition()), pointLight.getIntensity(), pointLight.getAttenuation()); }
for (int i = 0; i < numLights; i++) { PointLight currPointLight = new PointLight(pointLightList[i]); Vector3f lightPos = currPointLight.getPosition(); Vector4f aux = new Vector4f(lightPos, 1); aux.mul(viewMatrix); currSpotLight.setConeDirection(new Vector3f(dir.x, dir.y, dir.z)); Vector3f lightPos = currSpotLight.getPointLight().getPosition(); Vector4f aux = new Vector4f(lightPos, 1); aux.mul(viewMatrix);
@Override public void init(Window window) throws Exception { renderer.init(window); float reflectance = 1f; //Mesh mesh = OBJLoader.loadMesh("/models/bunny.obj"); //Material material = new Material(new Vector3f(0.2f, 0.5f, 0.5f), reflectance); Mesh mesh = OBJLoader.loadMesh("/models/cube.obj"); Texture texture = new Texture("/textures/grassblock.png"); Material material = new Material(texture, reflectance); mesh.setMaterial(material); GameItem gameItem = new GameItem(mesh); gameItem.setScale(0.5f); gameItem.setPosition(0, 0, -2); gameItems = new GameItem[]{gameItem}; ambientLight = new Vector3f(0.3f, 0.3f, 0.3f); Vector3f lightColour = new Vector3f(1, 1, 1); Vector3f lightPosition = new Vector3f(0, 0, 1); float lightIntensity = 1.0f; pointLight = new PointLight(lightColour, lightPosition, lightIntensity); PointLight.Attenuation att = new PointLight.Attenuation(0.0f, 0.0f, 1.0f); pointLight.setAttenuation(att); }
public SpotLight(SpotLight spotLight) { this(new PointLight(spotLight.getPointLight()), new Vector3f(spotLight.getConeDirection()), 0); setCutOff(spotLight.getCutOff()); }
@Override public void input(Window window, MouseInput mouseInput) { cameraInc.set(0, 0, 0); if (window.isKeyPressed(GLFW_KEY_W)) { cameraInc.z = -1; } else if (window.isKeyPressed(GLFW_KEY_S)) { cameraInc.z = 1; } if (window.isKeyPressed(GLFW_KEY_A)) { cameraInc.x = -1; } else if (window.isKeyPressed(GLFW_KEY_D)) { cameraInc.x = 1; } if (window.isKeyPressed(GLFW_KEY_Z)) { cameraInc.y = -1; } else if (window.isKeyPressed(GLFW_KEY_X)) { cameraInc.y = 1; } float lightPos = spotLightList[0].getPointLight().getPosition().z; if (window.isKeyPressed(GLFW_KEY_N)) { this.spotLightList[0].getPointLight().getPosition().z = lightPos + 0.1f; } else if (window.isKeyPressed(GLFW_KEY_M)) { this.spotLightList[0].getPointLight().getPosition().z = lightPos - 0.1f; } }
public PointLight(PointLight pointLight) { this(new Vector3f(pointLight.getColor()), new Vector3f(pointLight.getPosition()), pointLight.getIntensity(), pointLight.getAttenuation()); }
for (int i = 0; i < numLights; i++) { PointLight currPointLight = new PointLight(pointLightList[i]); Vector3f lightPos = currPointLight.getPosition(); Vector4f aux = new Vector4f(lightPos, 1); aux.mul(viewMatrix); currSpotLight.setConeDirection(new Vector3f(dir.x, dir.y, dir.z)); Vector3f lightPos = currSpotLight.getPointLight().getPosition(); Vector4f aux = new Vector4f(lightPos, 1); aux.mul(viewMatrix);
PointLight pointLight = new PointLight(new Vector3f(1, 1, 1), lightPosition, lightIntensity); PointLight.Attenuation att = new PointLight.Attenuation(0.0f, 0.0f, 1.0f); pointLight.setAttenuation(att); sceneLight.setPointLightList(new PointLight[]{pointLight}); pointLight = new PointLight(new Vector3f(1, 1, 1), lightPosition, lightIntensity); att = new PointLight.Attenuation(0.0f, 0.0f, 0.02f); pointLight.setAttenuation(att); Vector3f coneDir = new Vector3f(0, 0, -1); float cutoff = (float) Math.cos(Math.toRadians(140));
public SpotLight(SpotLight spotLight) { this(new PointLight(spotLight.getPointLight()), new Vector3f(spotLight.getConeDirection()), 0); setCutOff(spotLight.getCutOff()); }
@Override public void input(Window window, MouseInput mouseInput) { cameraInc.set(0, 0, 0); if (window.isKeyPressed(GLFW_KEY_W)) { cameraInc.z = -1; } else if (window.isKeyPressed(GLFW_KEY_S)) { cameraInc.z = 1; } if (window.isKeyPressed(GLFW_KEY_A)) { cameraInc.x = -1; } else if (window.isKeyPressed(GLFW_KEY_D)) { cameraInc.x = 1; } if (window.isKeyPressed(GLFW_KEY_Z)) { cameraInc.y = -1; } else if (window.isKeyPressed(GLFW_KEY_X)) { cameraInc.y = 1; } float lightPos = spotLight.getPointLight().getPosition().z; if (window.isKeyPressed(GLFW_KEY_N)) { this.spotLight.getPointLight().getPosition().z = lightPos + 0.1f; } else if (window.isKeyPressed(GLFW_KEY_M)) { this.spotLight.getPointLight().getPosition().z = lightPos - 0.1f; } }
public PointLight(PointLight pointLight) { this(new Vector3f(pointLight.getColor()), new Vector3f(pointLight.getPosition()), pointLight.getIntensity(), pointLight.getAttenuation()); }