Hello everyone !
I’m a newbie here and so far - despite some minor difficulties - I like JMonkey a lot! I’ve been playing with tutorials and got the basic concepts (or so I think…) but I have got stuck recently
In short words: shadows from PointLight are not visible in my app. I haven’t tried others, as I believe I’m missing something (and don’t really believe they would work anyway).
This example works just fine: Point light shadows at last
In my case, I’d expect a shadow below the sphere, but as you can see, it doesn’t appear.
And here is my code:
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;
import com.jme3.shadow.EdgeFilteringMode;
import com.jme3.shadow.PointLightShadowFilter;
import com.jme3.shadow.PointLightShadowRenderer;
public class NoShadowsExample extends SimpleApplication {
public static void main(String[] args) {
new NoShadowsExample().start();
}
@Override
public void simpleInitApp() {
final Material material;
final Geometry floor;
final Geometry sphere;
final PointLight light;
final PointLightShadowRenderer plsr;
//Setting up cam and its controls
{
flyCam.setEnabled(false);
flyCam.setMoveSpeed(30);
cam.setFrame(new Vector3f(0f,1f,6f), new Vector3f(-1f,0f,0f), new Vector3f(0f,1f,0f), new Vector3f(0f, 0f, -1f));
}
//LightGray material for floor and sphere
{
material=new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
material.setColor("Ambient", ColorRGBA.LightGray);
}
//Floor, 20x20 at 0,0,0
{
floor=new Geometry("Floor",new Box(10, 0.001f, 10));
floor.setMaterial(material);
floor.setShadowMode(RenderQueue.ShadowMode.Receive);
rootNode.attachChild(floor);
}
//Sphere
{
sphere=new Geometry("Sphere", new Sphere(50, 50, 0.5f));
sphere.move(0f, 1f, 0f);
sphere.setMaterial(material);
sphere.setShadowMode(RenderQueue.ShadowMode.Cast);
rootNode.attachChild(sphere);
}
//White PointLight at (0,5,0)
{
light=new PointLight();
light.setColor(ColorRGBA.White);
light.setPosition(new Vector3f(0f, 5f, 0f));
rootNode.addLight(light);
}
//PointLightShadowRenderer
{
plsr = new PointLightShadowRenderer(assetManager, 1024);
plsr.setLight(light);
viewPort.addProcessor(plsr);
}
//PointLightShadowFilter (commented out, but doesn't work either)
{/*
PointLightShadowFilter plsf = new PointLightShadowFilter(assetManager, 1024);
plsf.setLight(light);
plsf.setEnabled(true);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(plsf);
viewPort.addProcessor(fpp);
*/}
}
}
Can you see anything I don’t? Any help would be greatly appreciated, thanks!