Java Code Examples for com.jme3.light.PointLight#setPosition()
The following examples show how to use
com.jme3.light.PointLight#setPosition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestNormalMapping.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@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); }
Example 2
Source File: TestSimpleBumps.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@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); }
Example 3
Source File: TestInstanceNodeWithLight.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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); }
Example 4
Source File: TestUnshadedModel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@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); }
Example 5
Source File: TestUnshadedModel.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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); }
Example 6
Source File: TestSimpleBumps.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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); }
Example 7
Source File: TestNormalMapping.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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); }
Example 8
Source File: TestUnshadedModel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@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); }
Example 9
Source File: OffScenePanel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void setupScene() { //setup framebuffer's cam camera.setFrustumPerspective(45f, 1f, 1f, 1000f); camera.setLocation(new Vector3f(5f, 5f, 5f)); camera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y); // setup framebuffer's scene light = new PointLight(); light.setPosition(camera.getLocation()); light.setColor(ColorRGBA.White); rootNode.addLight(light); // attach the scene to the viewport to be rendered viewPort.attachScene(rootNode); }
Example 10
Source File: TestJaime.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupLights() { AmbientLight al = new AmbientLight(); al.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1)); rootNode.addLight(al); SpotLight sl = new SpotLight(); sl.setColor(ColorRGBA.White.mult(1.0f)); sl.setPosition(new Vector3f(1.2074411f, 10.6868908f, 4.1489987f)); sl.setDirection(sl.getPosition().mult(-1)); sl.setSpotOuterAngle(0.1f); sl.setSpotInnerAngle(0.004f); rootNode.addLight(sl); //pointlight to fake indirect light coming from the ground PointLight pl = new PointLight(); pl.setColor(ColorRGBA.White.mult(1.5f)); pl.setPosition(new Vector3f(0, 0, 1)); pl.setRadius(2); rootNode.addLight(pl); SpotLightShadowRenderer shadows = new SpotLightShadowRenderer(assetManager, 1024); shadows.setLight(sl); shadows.setShadowIntensity(0.3f); shadows.setEdgeFilteringMode(EdgeFilteringMode.PCF8); viewPort.addProcessor(shadows); FilterPostProcessor fpp = new FilterPostProcessor(assetManager); SSAOFilter filter = new SSAOFilter(0.10997847f,0.440001f,0.39999998f,-0.008000026f);; fpp.addFilter(filter); fpp.addFilter(new FXAAFilter()); fpp.addFilter(new FXAAFilter()); viewPort.addProcessor(fpp); }
Example 11
Source File: TestOgreLoading.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void simpleInitApp() { // PointLight pl = new PointLight(); // pl.setPosition(new Vector3f(10, 10, -10)); // rootNode.addLight(pl); flyCam.setMoveSpeed(10f); // sunset light DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal()); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); lightMd2 = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMd2.setMaterial(assetManager.loadMaterial("Common/Materials/WhiteColor.j3m")); rootNode.attachChild(lightMd2); pl = new PointLight(); pl.setColor(new ColorRGBA(1, 0.9f, 0.9f, 0)); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); p2 = new PointLight(); p2.setColor(new ColorRGBA(0.9f, 1, 0.9f, 0)); p2.setPosition(new Vector3f(0f, 0f, 3f)); rootNode.addLight(p2); // create the geometry and attach it Spatial elephant = (Spatial) assetManager.loadModel("Models/Elephant/Elephant.mesh.xml"); float scale = 0.05f; elephant.scale(scale, scale, scale); rootNode.attachChild(elephant); }
Example 12
Source File: TestNormalMapping.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@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); AmbientLight al = new AmbientLight(); al.setColor(new ColorRGBA(0.44f, 0.40f, 0.20f, 1.0f)); rootNode.addLight(al); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(1,-1,-1).normalizeLocal()); dl.setColor(new ColorRGBA(0.92f, 0.85f, 0.8f, 1.0f)); rootNode.addLight(dl); }
Example 13
Source File: TestOgreLoading.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { // PointLight pl = new PointLight(); // pl.setPosition(new Vector3f(10, 10, -10)); // rootNode.addLight(pl); flyCam.setMoveSpeed(10f); // sunset light DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal()); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); lightMd2 = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMd2.setMaterial(assetManager.loadMaterial("Common/Materials/WhiteColor.j3m")); rootNode.attachChild(lightMd2); pl = new PointLight(); pl.setColor(new ColorRGBA(1, 0.9f, 0.9f, 0)); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); p2 = new PointLight(); p2.setColor(new ColorRGBA(0.9f, 1, 0.9f, 0)); p2.setPosition(new Vector3f(0f, 0f, 3f)); rootNode.addLight(p2); // create the geometry and attach it Spatial elephant = assetManager.loadModel("Models/Elephant/Elephant.mesh.xml"); float scale = 0.05f; elephant.scale(scale, scale, scale); rootNode.attachChild(elephant); }
Example 14
Source File: TestTangentCube.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { Box aBox = new Box(1, 1, 1); Geometry aGeometry = new Geometry("Box", aBox); TangentBinormalGenerator.generate(aBox); Material aMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); aMaterial.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg")); aMaterial.setTexture("NormalMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_normal.jpg")); aMaterial.setBoolean("UseMaterialColors", false); aMaterial.setColor("Diffuse", ColorRGBA.White); aMaterial.setColor("Specular", ColorRGBA.White); aMaterial.setFloat("Shininess", 64f); aGeometry.setMaterial(aMaterial); // Rotate 45 degrees to see multiple faces aGeometry.rotate(FastMath.QUARTER_PI, FastMath.QUARTER_PI, 0.0f); rootNode.attachChild(aGeometry); /** * Must add a light to make the lit object visible! */ PointLight aLight = new PointLight(); aLight.setPosition(new Vector3f(0, 3, 3)); aLight.setColor(ColorRGBA.Red); rootNode.addLight(aLight); // // AmbientLight bLight = new AmbientLight(); // bLight.setColor(ColorRGBA.Gray); // rootNode.addLight(bLight); ChaseCameraAppState chaser = new ChaseCameraAppState(); chaser.setTarget(aGeometry); getStateManager().attach(chaser); }
Example 15
Source File: TestMultiRenderTarget.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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)); } }
Example 16
Source File: TestMultiRenderTarget.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void simpleInitApp() { viewPort.addProcessor(this); renderManager.setForcedTechnique("GBuf"); // flyCam.setEnabled(false); cam.setLocation(new Vector3f(4.8037705f, 4.851632f, 10.789033f)); cam.setRotation(new Quaternion(-0.05143692f, 0.9483723f, -0.21131563f, -0.230846f)); Node tank = (Node) assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml"); //tankMesh.getMaterial().setColor("Specular", ColorRGBA.Black); rootNode.attachChild(tank); display1 = new Picture("Picture"); display1.move(0, 0, -1); // make it appear behind stats view display2 = (Picture) display1.clone(); display3 = (Picture) display1.clone(); display4 = (Picture) display1.clone(); display = (Picture) display1.clone(); ColorRGBA[] colors = new ColorRGBA[]{ ColorRGBA.White, ColorRGBA.Blue, ColorRGBA.Cyan, ColorRGBA.DarkGray, ColorRGBA.Green, ColorRGBA.Magenta, ColorRGBA.Orange, ColorRGBA.Pink, ColorRGBA.Red, ColorRGBA.Yellow }; for (int i = 0; i < 3; i++){ PointLight pl = new PointLight(); float angle = 0.314159265f * i; pl.setPosition( new Vector3f(FastMath.cos(angle)*2f, 0, FastMath.sin(angle)*2f)); pl.setColor(colors[i]); pl.setRadius(5); rootNode.addLight(pl); display.addLight(pl); } }
Example 17
Source File: TestShadowBug.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { flyCam.setMoveSpeed(100f); rootNode.attachChild(makeFloor()); Node characters = new Node("Characters"); characters.setShadowMode(ShadowMode.Cast); rootNode.attachChild(characters); Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); golem.scale(0.5f); golem.setLocalTranslation(200.0f, -6f, 200f); golem.setShadowMode(ShadowMode.CastAndReceive); characters.attachChild(golem); DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-1f, -1f, 1f)); sun.setColor(ColorRGBA.White.mult(1.3f)); rootNode.addLight(sun); characters.addLight(sun); SpotLight spot = new SpotLight(); spot.setSpotRange(13f); // distance spot.setSpotInnerAngle(15f * FastMath.DEG_TO_RAD); // inner light cone (central beam) spot.setSpotOuterAngle(20f * FastMath.DEG_TO_RAD); // outer light cone (edge of the light) spot.setColor(ColorRGBA.White.mult(1.3f)); // light color spot.setPosition(new Vector3f(192.0f, -1f, 192f)); spot.setDirection(new Vector3f(1, -0.5f, 1)); rootNode.addLight(spot); PointLight lamp_light = new PointLight(); lamp_light.setColor(ColorRGBA.Yellow); lamp_light.setRadius(20f); lamp_light.setPosition(new Vector3f(210.0f, 0f, 210f)); rootNode.addLight(lamp_light); SpotLightShadowRenderer slsr = new SpotLightShadowRenderer(assetManager, 512); slsr.setLight(spot); slsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest); slsr.setShadowIntensity(0.6f); viewPort.addProcessor(slsr); PointLightShadowRenderer plsr = new PointLightShadowRenderer(assetManager, 512); plsr.setLight(lamp_light); plsr.setShadowIntensity(0.6f); plsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest); viewPort.addProcessor(plsr); viewPort.getCamera().setLocation(new Vector3f(192.0f, 10f, 192f)); float[] angles = new float[]{3.14f/2, 3.14f/2, 0}; viewPort.getCamera().setRotation(new Quaternion(angles)); }