com.jme3.light.PointLight Java Examples
The following examples show how to use
com.jme3.light.PointLight.
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: LightPropertyBuilder.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@FxThread private void buildForPointLight(@NotNull final PointLight light, @NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer) { final Vector3f position = light.getPosition().clone(); final float radius = light.getRadius(); final Vector3fPropertyControl<ModelChangeConsumer, PointLight> positionControl = new Vector3fPropertyControl<>(position, Messages.MODEL_PROPERTY_LOCATION, changeConsumer); positionControl.setApplyHandler(PointLight::setPosition); positionControl.setSyncHandler(PointLight::getPosition); positionControl.setEditObject(light); final FloatPropertyControl<ModelChangeConsumer, PointLight> radiusControl = new FloatPropertyControl<>(radius, Messages.MODEL_PROPERTY_RADIUS, changeConsumer); radiusControl.setApplyHandler(PointLight::setRadius); radiusControl.setSyncHandler(PointLight::getRadius); radiusControl.setMinMax(0, Integer.MAX_VALUE); radiusControl.setEditObject(light); FXUtils.addToPane(positionControl, container); buildSplitLine(container); FXUtils.addToPane(radiusControl, container); }
Example #2
Source File: LightControl.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
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(); }
Example #3
Source File: ShadowCamera.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
/** * Updates the camera view direction and position based on the light */ public void updateLightCamera(Camera lightCam) { if (target.getType() == Light.Type.Directional) { DirectionalLight dl = (DirectionalLight) target; lightCam.setParallelProjection(true); lightCam.setLocation(Vector3f.ZERO); lightCam.lookAtDirection(dl.getDirection(), Vector3f.UNIT_Y); lightCam.setFrustum(-1, 1, -1, 1, 1, -1); } else { PointLight pl = (PointLight) target; lightCam.setParallelProjection(false); lightCam.setLocation(pl.getPosition()); // direction will have to be calculated automatically lightCam.setFrustumPerspective(45, 1, 1, 300); } }
Example #4
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 #5
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 #6
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 #7
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 #8
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 #9
Source File: TestBumpModel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { Spatial signpost = (Spatial) assetManager.loadAsset(new OgreMeshKey("Models/Sign Post/Sign Post.mesh.xml")); signpost.setMaterial( (Material) assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m")); TangentBinormalGenerator.generate(signpost); rootNode.attachChild(signpost); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial( (Material) assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); // flourescent main light pl = new PointLight(); pl.setColor(new ColorRGBA(0.88f, 0.92f, 0.95f, 1.0f)); 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 #10
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 #11
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 #12
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 #13
Source File: LightControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void spatialTolight(Light light) { if (light instanceof PointLight) { ((PointLight) light).setPosition(spatial.getWorldTranslation()); } TempVars vars = TempVars.get(); if (light instanceof DirectionalLight) { ((DirectionalLight) light).setDirection(vars.vect1.set(spatial.getWorldTranslation()).multLocal(-1.0f)); } if (light instanceof SpotLight) { ((SpotLight) light).setPosition(spatial.getWorldTranslation()); ((SpotLight) light).setDirection(spatial.getWorldRotation().multLocal(vars.vect1.set(Vector3f.UNIT_Y).multLocal(-1))); } vars.release(); }
Example #14
Source File: JmePointLight.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override protected Sheet createSheet() { //TODO: multithreading.. Sheet sheet = super.createSheet(); Sheet.Set set = Sheet.createPropertiesSet(); set.setDisplayName("PointLight"); set.setName(PointLight.class.getName()); PointLight obj = pointLight;//getLookup().lookup(Spatial.class); if (obj == null) { return sheet; } set.put(makeProperty(obj, Vector3f.class, "getPosition", "setPosition", "Position")); set.put(makeProperty(obj, float.class, "getRadius", "setRadius", "Radius")); sheet.put(set); return sheet; }
Example #15
Source File: LightPropertyBuilder.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, @NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer) { if (object instanceof DirectionalLight) { buildForDirectionLight((DirectionalLight) object, container, changeConsumer); } else if (object instanceof SpotLight) { buildForSpotLight((SpotLight) object, container, changeConsumer); } else if (object instanceof PointLight) { buildForPointLight((PointLight) object, container, changeConsumer); } if (object instanceof Light) { buildForLight((Light) object, container, changeConsumer); } }
Example #16
Source File: SceneLoader.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void parseLightAttenuation(Attributes attribs) throws SAXException { // NOTE: Derives range based on "linear" if it is used solely // for the attenuation. Otherwise derives it from "range" checkTopNode("light"); if (light instanceof PointLight || light instanceof SpotLight) { float range = parseFloat(attribs.getValue("range")); float constant = parseFloat(attribs.getValue("constant")); float linear = parseFloat(attribs.getValue("linear")); String quadraticStr = attribs.getValue("quadratic"); if (quadraticStr == null) { quadraticStr = attribs.getValue("quadric"); } float quadratic = parseFloat(quadraticStr); if (constant == 1 && quadratic == 0 && linear > 0) { range = 1f / linear; } if (light instanceof PointLight) { ((PointLight) light).setRadius(range); } else { ((SpotLight) light).setSpotRange(range); } } }
Example #17
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 #18
Source File: TestLightRadius.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void simpleInitApp() { Torus torus = new Torus(10, 6, 1, 3); // Torus torus = new Torus(50, 30, 1, 3); Geometry g = new Geometry("Torus Geom", torus); g.rotate(-FastMath.HALF_PI, 0, 0); g.center(); // g.move(0, 1, 0); Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); mat.setFloat("Shininess", 32f); mat.setBoolean("UseMaterialColors", true); mat.setColor("Ambient", ColorRGBA.Black); mat.setColor("Diffuse", ColorRGBA.White); mat.setColor("Specular", ColorRGBA.White); // mat.setBoolean("VertexLighting", true); // mat.setBoolean("LowQuality", true); g.setMaterial(mat); rootNode.attachChild(g); 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.Green); pl.setRadius(4f); rootNode.addLight(pl); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.Red); dl.setDirection(new Vector3f(0, 1, 0)); rootNode.addLight(dl); }
Example #19
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 #20
Source File: SceneComposerToolController.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Adds a marker for the light to the scene if it does not exist yet */ public void addLightMarker(Light light) { if (!(light instanceof PointLight) && !(light instanceof SpotLight)) return; // only handle point and spot lights Spatial s = nonSpatialMarkersNode.getChild(light.getName()); if (s != null) { // update location maybe? Remove old and replace with new? return; } LightMarker lm = new LightMarker(light); nonSpatialMarkersNode.attachChild(lm); }
Example #21
Source File: SceneComposerToolController.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void setLocalTranslation(Vector3f location) { super.setLocalTranslation(location); if (light instanceof PointLight) ((PointLight)light).setPosition(location); else if (light instanceof SpotLight) ((SpotLight)light).setPosition(location); }
Example #22
Source File: SceneComposerToolController.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void setLocalTranslation(float x, float y, float z) { super.setLocalTranslation(x, y, z); if (light instanceof PointLight) ((PointLight)light).setPosition(new Vector3f(x,y,z)); else if (light instanceof SpotLight) ((SpotLight)light).setPosition(new Vector3f(x,y,z)); }
Example #23
Source File: SceneComposerToolController.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void controlUpdate(float f) { super.controlUpdate(f); LightMarker marker = (LightMarker) getSpatial(); if (marker != null) { if (marker.getLight() instanceof PointLight) { marker.setLocalTranslation(((PointLight)marker.getLight()).getPosition()); } else if (marker.getLight() instanceof SpotLight) { marker.setLocalTranslation(((SpotLight)marker.getLight()).getPosition()); } } }
Example #24
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 #25
Source File: NewLightPopup.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void actionPerformed(ActionEvent e) { SceneApplication.getApplication().enqueue(new Callable<Void>() { public Void call() throws Exception { PointLight light = new PointLight(); light.setColor(ColorRGBA.White); node.addLight(light); addLightUndo(node, light); setModified(); return null; } }); }
Example #26
Source File: PointLightShadowRenderer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); light = (PointLight) ic.readSavable("light", null); init((int) shadowMapSize); }
Example #27
Source File: StaticPassLightingLogic.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Shader makeCurrent(AssetManager assetManager, RenderManager renderManager, EnumSet<Caps> rendererCaps, LightList lights, DefineList defines) { // TODO: if it ever changes that render isn't called // right away with the same geometry after makeCurrent, it would be // a problem. // Do a radix sort. tempDirLights.clear(); tempPointLights.clear(); tempSpotLights.clear(); for (Light light : lights) { switch (light.getType()) { case Directional: tempDirLights.add((DirectionalLight) light); break; case Point: tempPointLights.add((PointLight) light); break; case Spot: tempSpotLights.add((SpotLight) light); break; } } defines.set(numDirLightsDefineId, tempDirLights.size()); defines.set(numPointLightsDefineId, tempPointLights.size()); defines.set(numSpotLightsDefineId, tempSpotLights.size()); return techniqueDef.getShader(assetManager, rendererCaps, defines); }
Example #28
Source File: PointLightTreeNode.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override @FromAnyThread public @NotNull String getName() { final PointLight element = getElement(); final String name = element.getName(); return StringUtils.isEmpty(name) ? Messages.MODEL_FILE_EDITOR_NODE_POINT_LIGHT : name; }
Example #29
Source File: TestLightRadius.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { Torus torus = new Torus(10, 6, 1, 3); // Torus torus = new Torus(50, 30, 1, 3); Geometry g = new Geometry("Torus Geom", torus); g.rotate(-FastMath.HALF_PI, 0, 0); g.center(); // g.move(0, 1, 0); Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); mat.setFloat("Shininess", 32f); mat.setBoolean("UseMaterialColors", true); mat.setColor("Ambient", ColorRGBA.Black); mat.setColor("Diffuse", ColorRGBA.White); mat.setColor("Specular", ColorRGBA.White); // mat.setBoolean("VertexLighting", true); // mat.setBoolean("LowQuality", true); g.setMaterial(mat); rootNode.attachChild(g); 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.Green); pl.setRadius(4f); rootNode.addLight(pl); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.Red); dl.setDirection(new Vector3f(0, 1, 0)); rootNode.addLight(dl); }
Example #30
Source File: SceneLoader.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void parseLightAttenuation(Attributes attribs) throws SAXException { // NOTE: Derives range based on "linear" if it is used solely // for the attenuation. Otherwise derives it from "range" checkTopNode("light"); if (light instanceof PointLight || light instanceof SpotLight) { float range = parseFloat(attribs.getValue("range")); float constant = parseFloat(attribs.getValue("constant")); float linear = parseFloat(attribs.getValue("linear")); String quadraticStr = attribs.getValue("quadratic"); if (quadraticStr == null) { quadraticStr = attribs.getValue("quadric"); } float quadratic = parseFloat(quadraticStr); if (constant == 1 && quadratic == 0 && linear > 0) { range = 1f / linear; } if (light instanceof PointLight) { ((PointLight) light).setRadius(range); } else { ((SpotLight) light).setSpotRange(range); } } }