rootNode.attachChild(g); PointLight light = new PointLight(); light.setColor(ColorRGBA.White); light.setPosition(new Vector3f(5, 5, 5)); light.setRadius(20); rootNode.addLight(light); light = new PointLight(); light.setColor(ColorRGBA.White); light.setPosition(new Vector3f(-5, -5, -5)); light.setRadius(20); rootNode.addLight(light);
@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()); }
switch (type) { case 0:// Lamp light = new PointLight(); float distance = ((Number) structure.getFieldValue("dist")).floatValue(); ((PointLight) light).setRadius(distance); break; case 1:// Sun LOGGER.log(Level.WARNING, "'Sun' lamp is not supported in jMonkeyEngine. Using PointLight with radius = Float.MAX_VALUE."); light = new PointLight(); ((PointLight) light).setRadius(Float.MAX_VALUE); break; case 2:// Spot
PointLight pl = new PointLight(); pl.setColor(colors[i % colors.length]); pl.setRadius(5); display.addLight(pl); pls[i] = pl;
@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); }
@Test public void testPointFiltering() { PointLight pl = new PointLight(Vector3f.ZERO); geom.addLight(pl); checkFilteredLights(1); // Infinite point lights must never be filtered pl.setRadius(1); checkFilteredLights(0); pl.setPosition(new Vector3f(0, 0, 8f)); checkFilteredLights(0); pl.setPosition(new Vector3f(0, 0, 8f + FastMath.ZERO_TOLERANCE)); checkFilteredLights(1); pl.setPosition(new Vector3f(2, 2, 8)); pl.setRadius(sqrt3); checkFilteredLights(0); pl.setRadius(sqrt3 + FastMath.ZERO_TOLERANCE); checkFilteredLights(1); pl.setPosition(new Vector3f(0, 0, 2f)); pl.setRadius(0); checkFilteredLights(1); pl.setRadius(1f); pl.setPosition(new Vector3f(0, 0, 0));
/** * 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, with the given radius * @param position the position in world space * @param radius the light radius */ public PointLight(Vector3f position, float radius) { this(position); setRadius(radius); }
pl = new PointLight(); pl.setColor(new ColorRGBA(0.88f, 0.92f, 0.95f, 1.0f)); rootNode.addLight(pl);
private Light createLight() { PointLight result = new PointLight(); result.setName("torch"); float intensity = kwdFile.getVariables().get(MiscType.DEFAULT_TORCH_LIGHT_INTENSITY).getValue(); result.setColor(new ColorRGBA(kwdFile.getVariables().get(MiscType.DEFAULT_TORCH_LIGHT_RED).getValue() * intensity / 255, kwdFile.getVariables().get(MiscType.DEFAULT_TORCH_LIGHT_GREEN).getValue() * intensity / 255, kwdFile.getVariables().get(MiscType.DEFAULT_TORCH_LIGHT_BLUE).getValue() * intensity / 255, 0)); result.setEnabled(true); result.setRadius(kwdFile.getVariables().get(MiscType.DEFAULT_TORCH_LIGHT_RADIUS_TILES).getValue()); // float height = kwdFile.getVariables().get(MiscType.DEFAULT_TORCH_LIGHT_HEIGHT_TILES).getValue(); return result; }
private void parseLight(Attributes attribs) throws SAXException { if (node == null || node.getParent() == null) { throw new SAXException("dotScene parse error: light can only appear under a node"); } checkTopNode("node"); String lightType = parseString(attribs.getValue("type"), "point"); if (lightType.equals("point")) { light = new PointLight(); } else if (lightType.equals("directional") || lightType.equals("sun")) { light = new DirectionalLight(); // Assuming "normal" property is not provided ((DirectionalLight) light).setDirection(Vector3f.UNIT_Z); } else if (lightType.equals("spotLight") || lightType.equals("spot")) { light = new SpotLight(); } else if (lightType.equals("omni")) { // XXX: It doesn't seem any exporters actually emit this type? light = new AmbientLight(); } else { logger.log(Level.WARNING, "No matching jME3 LightType found for OGRE LightType: {0}", lightType); } logger.log(Level.FINEST, "{0} created.", light); if (!parseBool(attribs.getValue("visible"), true)) { // set to disabled } // "attach" it to the parent of this node if (light != null) { node.getParent().addLight(light); } }
case Point: PointLight pl = (PointLight) l; Vector3f pos = pl.getPosition(); float invRadius = pl.getInvRadius(); tmpVec.set(pos.getX(), pos.getY(), pos.getZ(), 1.0f);
ColorRGBA color = light.getColor(); tempPosition.set(light.getPosition()); float invRadius = light.getInvRadius(); transformPosition(viewMatrix, tempPosition); lightData.setVector4InArray(color.r, color.g, color.b, 1f, index++);
@Override protected void setMaterialParameters(Material material) { material.setVector3("LightPos", light == null ? new Vector3f() : light.getPosition()); }
@Override protected void updateShadowCams(Camera viewCam) { if (light == null) { logger.warning("The light can't be null for a " + getClass().getName()); return; } //bottom shadowCams[0].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Z.mult(-1f), Vector3f.UNIT_Y.mult(-1f)); //top shadowCams[1].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Z, Vector3f.UNIT_Y); //forward shadowCams[2].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Y, Vector3f.UNIT_Z.mult(-1f)); //backward shadowCams[3].setAxes(Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z); //left shadowCams[4].setAxes(Vector3f.UNIT_Z, Vector3f.UNIT_Y, Vector3f.UNIT_X.mult(-1f)); //right shadowCams[5].setAxes(Vector3f.UNIT_Z.mult(-1f), Vector3f.UNIT_Y, Vector3f.UNIT_X); for (int i = 0; i < CAM_NUMBER; i++) { shadowCams[i].setFrustumPerspective(90f, 1f, 0.1f, light.getRadius()); shadowCams[i].setLocation(light.getPosition()); shadowCams[i].update(); shadowCams[i].updateViewProjection(); } }
box.setLocalTranslation(-1f, 0.5f, -2); ((PointLight) scene.getLocalLightList().get(0)).setColor(ColorRGBA.Red);
rootNode.attachChild(lightMdl); pl = new PointLight(); pl.setColor(ColorRGBA.Green); pl.setRadius(4f); rootNode.addLight(pl);
@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); } }
/** * Creates a PointLight at the given position * @param position the position in world space */ public PointLight(Vector3f position) { setPosition(position); }
/** * Creates a PointLight at the given position, with the given color and the * given radius * @param position the position in world space * @param color the light color * @param radius the light radius */ public PointLight(Vector3f position, ColorRGBA color, float radius) { this(position, color); setRadius(radius); }