/** * Creates a PointLight at the given position and with the given color * @param position the position in world space * @param color the light color */ public PointLight(Vector3f position, ColorRGBA color) { super(color); setPosition(position); }
/** * Creates a PointLight at the given position * @param position the position in world space */ public PointLight(Vector3f position) { setPosition(position); }
@Override public void simpleUpdate(float tpf){ // cam.setLocation(new Vector3f(5.0347548f, 6.6481347f, 3.74853f)); // cam.setRotation(new Quaternion(-0.19183293f, 0.80776674f, -0.37974006f, -0.40805697f)); pos += tpf * vel * 5f; if (pos > 15){ vel *= -1; }else if (pos < -15){ vel *= -1; } pl.setPosition(new Vector3f(pos, 2, 0)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf) { offset += tpf; System.err.println(offset); box.setLocalTranslation(new Vector3f(offset, 0, 0)); pointLight.setPosition(new Vector3f(offset - 3f, 0, 0)); cam.setLocation(new Vector3f(offset - 5f, 0, 0)); cam.lookAtDirection(Vector3f.UNIT_X, Vector3f.UNIT_Y); } }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 6f, 3f, FastMath.sin(angle) * 6f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 3f, 0.5f, FastMath.sin(angle) * 3f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 6f, 3f, FastMath.sin(angle) * 6f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 6f, 3f, FastMath.sin(angle) * 6f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 2f, 0.5f, FastMath.sin(angle) * 2f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf) { angle1 += tpf * 0.25f; angle1 %= FastMath.TWO_PI; angle2 += tpf * 0.50f; angle2 %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle1) * 4f, 0.5f, FastMath.sin(angle1) * 4f)); p2.setPosition(new Vector3f(FastMath.cos(angle2) * 4f, 0.5f, FastMath.sin(angle2) * 4f)); lightMdl.setLocalTranslation(pl.getPosition()); lightMd2.setLocalTranslation(p2.getPosition()); } }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 4f, 0.5f, FastMath.sin(angle) * 4f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf) { super.simpleUpdate(tpf);//To change body of generated methods, choose Tools | Templates. for (int i = 0; i < 3; i++){ PointLight pl = pls[i]; float angle = (float)Math.PI * (i + (timer.getTimeInSeconds() % 6)/3); // 3s for full loop pl.setPosition( new Vector3f(FastMath.cos(angle)*3f, 0, FastMath.sin(angle)*3f)); } } public void initialize(RenderManager rm, ViewPort vp) {
@Override public void simpleUpdate(float tpf){ // cam.setLocation(new Vector3f(2.0632997f, 1.9493936f, 2.6885238f)); // cam.setRotation(new Quaternion(-0.053555284f, 0.9407851f, -0.17754152f, -0.28378546f)); angle += tpf; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 2f, 0.5f, FastMath.sin(angle) * 2f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 2f, 2f, FastMath.sin(angle) * 2f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 4f, 0.5f, FastMath.sin(angle) * 4f)); lightMdl.setLocalTranslation(pl.getPosition()); }
private void spatialToLight(Light light) { final Vector3f worldTranslation = spatial.getWorldTranslation(); if (light instanceof PointLight) { ((PointLight) light).setPosition(worldTranslation); return; } final TempVars vars = TempVars.get(); final Vector3f vec = vars.vect1; if (light instanceof DirectionalLight) { ((DirectionalLight) light).setDirection(vec.set(worldTranslation).multLocal(-1.0f)); } if (light instanceof SpotLight) { final SpotLight spotLight = (SpotLight) light; spotLight.setPosition(worldTranslation); spotLight.setDirection(spatial.getWorldRotation().multLocal(vec.set(Vector3f.UNIT_Y).multLocal(-1))); } vars.release(); }
@Override public void simpleInitApp() { Quad quadMesh = new Quad(1, 1); Geometry sphere = new Geometry("Rock Ball", quadMesh); Material mat = assetManager.loadMaterial("Textures/BumpMapTest/SimpleBump.j3m"); sphere.setMaterial(mat); TangentBinormalGenerator.generate(sphere); rootNode.attachChild(sphere); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); // DirectionalLight dl = new DirectionalLight(); // dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal()); // dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f)); // rootNode.addLight(dl); }
@Override public void simpleInitApp() { Sphere sphMesh = new Sphere(32, 32, 1); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 1, false, false); TangentBinormalGenerator.generate(sphMesh); Geometry sphere = new Geometry("Rock Ball", sphMesh); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); mat.setColor("Ambient", ColorRGBA.DarkGray); mat.setColor("Diffuse", ColorRGBA.White); mat.setBoolean("UseMaterialColors", true); sphere.setMaterial(mat); rootNode.attachChild(sphere); PointLight pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(4f, 0f, 0f)); rootNode.addLight(pl); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White); rootNode.addLight(al); } }
@Override public void simpleInitApp() { Sphere sphMesh = new Sphere(32, 32, 1); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 1, false, false); TangentBinormalGenerator.generate(sphMesh); Geometry sphere = new Geometry("Rock Ball", sphMesh); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); sphere.setMaterial(mat); rootNode.attachChild(sphere); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); // DirectionalLight dl = new DirectionalLight(); // dl.setDirection(new Vector3f(1,-1,1).normalizeLocal()); // dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f)); // rootNode.addLight(dl); }
@Override public void simpleInitApp() { InstancedNode instancedNode = new InstancedNode("testInstancedNode"); rootNode.attachChild(instancedNode); box = new Geometry("Box", new Box(0.5f, 0.5f, 0.5f)); Material material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); material.setBoolean("UseInstancing", true); material.setColor("Diffuse", ColorRGBA.Red); material.setBoolean("UseMaterialColors", true); box.setMaterial(material); instancedNode.attachChild(box); instancedNode.instance(); pointLight = new PointLight(); pointLight.setColor(ColorRGBA.White); pointLight.setRadius(10f); rootNode.addLight(pointLight); box.setLocalTranslation(new Vector3f(offset, 0, 0)); pointLight.setPosition(new Vector3f(offset - 3f, 0, 0)); cam.setLocation(new Vector3f(offset - 5f, 0, 0)); cam.lookAtDirection(Vector3f.UNIT_X, Vector3f.UNIT_Y); }