public void setupLighting() { dl = new DirectionalLight(); dl.setDirection(lightDir); dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1)); rootNode.addLight(dl); } Material mat;
@Override public void simpleUpdate(float tpf) { if (up) { Vector3f v = l.getDirection(); v.y += tpf / s; setDir(v); Vector3f v = l.getDirection(); v.y -= tpf / s; setDir(v); Vector3f v = l.getDirection(); v.x += tpf / s; setDir(v); Vector3f v = l.getDirection(); v.x -= tpf / s; setDir(v); Vector3f v = l.getDirection(); v.z += tpf / s; setDir(v); Vector3f v = l.getDirection(); v.z -= tpf / s; setDir(v);
protected Spatial makeCharacter() { // load a character from jme3test-test-data Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); golem.scale(0.5f); golem.setLocalTranslation(-1.0f, -1.5f, -0.6f); // We must add a light to make the model visible DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f)); golem.addLight(sun); return golem; } }
DirectionalLight sun = new DirectionalLight(); sun.setDirection((new Vector3f(-0.7f, -0.3f, -0.5f)).normalizeLocal()); System.out.println("Here We Go: " + sun.getDirection()); sun.setColor(ColorRGBA.White); rootNode.addLight(sun);
DirectionalLight dl = (DirectionalLight) light; Quaternion q = node.getWorldRotation(); Vector3f dir = dl.getDirection(); q.multLocal(dir); dl.setDirection(dir); } else if (light instanceof PointLight) { PointLight pl = (PointLight) light;
/** * Creates a DirectionalLight with the given direction * @param direction the light's direction */ public DirectionalLight(Vector3f direction) { setDirection(direction); }
@Test public void testDirectionalFiltering() { geom.addLight(new DirectionalLight(Vector3f.UNIT_Y)); checkFilteredLights(1); // Directional lights must never be filtered // Test for bounding Sphere geom.setModelBound(new BoundingSphere(0.5f, Vector3f.ZERO)); checkFilteredLights(1); // Directional lights must never be filtered }
ColorRGBA color = light.getColor(); tempDirection.set(light.getDirection()); transformDirection(viewMatrix, tempDirection); lightData.setVector4InArray(color.r, color.g, color.b, 1f, index++);
protected Spatial makeCharacter() { // load a character from jme3test-test-data Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); golem.scale(0.5f); golem.setLocalTranslation(-1.0f, -1.5f, -0.6f); // We must add a light to make the model visible DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal()); golem.addLight(sun); return golem; } }
DirectionalLight dl = (DirectionalLight) light; Quaternion q = node.getWorldRotation(); Vector3f dir = dl.getDirection(); q.multLocal(dir); dl.setDirection(dir); } else if (light instanceof PointLight) { PointLight pl = (PointLight) light;
/** * Creates a DirectionalLight with the given direction and the given color * @param direction the light's direction * @param color the light's color */ public DirectionalLight(Vector3f direction, ColorRGBA color) { super(color); setDirection(direction); }
@Override protected void initialize(Application app) { vp = app.getRenderManager().createMainView("debug", app.getCamera()); vp.attachScene(debugNode); vp.setClearDepth(true); this.app = app; for (ArmatureDebugger armatureDebugger : armatures.values()) { armatureDebugger.initialize(app.getAssetManager(), app.getCamera()); } app.getInputManager().addListener(actionListener, "shoot", "toggleJoints"); app.getInputManager().addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT), new MouseButtonTrigger(MouseInput.BUTTON_RIGHT)); app.getInputManager().addMapping("toggleJoints", new KeyTrigger(KeyInput.KEY_F10)); debugNode.addLight(new DirectionalLight(new Vector3f(-1f, -1f, -1f).normalizeLocal())); debugNode.addLight(new DirectionalLight(new Vector3f(1f, 1f, 1f).normalizeLocal(), new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f))); vp.setEnabled(false); }
ColorRGBA color = light.getColor(); tempDirection.set(light.getDirection()); transformDirection(viewMatrix, tempDirection); lightData.setVector4InArray(color.r, color.g, color.b, 1f, index++);
public void setupLighting() { dl = new DirectionalLight(); dl.setDirection(lightDir); dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1)); rootNode.addLight(dl); } Material mat;
private void makeScene() { // load sky rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", SkyFactory.EnvMapType.CubeMap)); //assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", HttpZipLocator.class); Spatial scene = assetManager.loadModel("Models/Test/CornellBox.j3o"); DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.4790551f, -0.39247334f, -0.7851566f)); scene.addLight(sun); rootNode.attachChild(scene); } }
@Override protected void setMaterialParameters(Material material) { material.setColor("Splits", splits); material.setVector3("LightDir", light.getDirection()); if (fadeInfo != null) { material.setVector2("FadeInfo", fadeInfo); } }
DirectionalLight dl = (DirectionalLight) light; Quaternion q = node.getWorldRotation(); Vector3f dir = dl.getDirection(); q.multLocal(dir); dl.setDirection(dir); } else if (light instanceof PointLight) { PointLight pl = (PointLight) light;
private void setDir(Vector3f v) { l.setDirection(v); } }
@Test public void testSimpleSort() { Geometry g = new Geometry("test", new Mesh()); LightList list = new LightList(g); list.add(new SpotLight(Vector3f.ZERO, Vector3f.UNIT_X)); list.add(new PointLight(Vector3f.UNIT_X)); list.add(new DirectionalLight(Vector3f.UNIT_X)); list.add(new AmbientLight()); list.sort(true); assert list.get(0) instanceof AmbientLight; // Ambients always first assert list.get(1) instanceof DirectionalLight; // .. then directionals assert list.get(2) instanceof SpotLight; // Spot is 0 units away from geom assert list.get(3) instanceof PointLight; // .. and point is 1 unit away. }
public void setupLighting() { DirectionalLight dl = new DirectionalLight(); dl.setDirection(lightDir); dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1)); rootNode.addLight(dl); dl = new DirectionalLight(); dl.setDirection(new Vector3f(1, 0, -1).normalizeLocal()); dl.setColor(new ColorRGBA(.4f, .4f, .4f, 1)); // rootNode.addLight(dl); }