SpotLight?

I’m trying to make a flashlight in my game.

To accomplish this, I wanted to use the Spotlight class, as shown here:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:light_and_shadow?s[]=spotlight



However, there is no such class in my library, even updating it to the latest svn.



Was it changed since the tutorial was written? If so, what’ do I use as substitute?

Thanks in advance

Uh, the tutorial is lying, there is no spot lights in jME3.

damnit D=



Is there anyway I can make a light cone?

You mean like a spotlight? xD Well, for the actual cone in the air you could try doing things with a half-transparent mesh, the projected circle on the surface is the main problem, you will have to create/modify a shader for it.

Ok, now I’m trying to use a point light instead. I’m creating it with the following code:

[java] private void makeLight(){



pl = new PointLight();

PointLight ppl = new PointLight();

Vector3f pos = character.getPhysicsLocation();

pos.setZ(4f);

pos.setY(-1f);

ppl.setPosition(pos);

ppl.setColor(ColorRGBA.White);

ppl.setRadius(10f);

rootNode.addLight(ppl);

}[/java]



There are no compiling errors, I get the window to choose resolution and fullscreen/windowed normally.

When the game is actually loading, it closes with the following error:



[java]08/03/2011 03:23:26 com.jme3.app.Application handleError

GRAVE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NullPointerException

at mygame.Main.makeLight(Main.java:234)

at mygame.Main.simpleInitApp(Main.java:179)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:218)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:138)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:206)

at java.lang.Thread.run(Thread.java:662)[/java]

Apparently the error appears when I add the light to the rootnode.

Google has failed me, has this happened before?

Once again, thanks in advance.

What is at:

mygame.Main.makeLight(Main.java:234)



All will be revealed from that line.

[java] Vector3f pos = character.getPhysicsLocation();[/java]

character is null.

normen said:
You mean like a spotlight? xD Well, for the actual cone in the air you could try doing things with a half-transparent mesh, the projected circle on the surface is the main problem, you will have to create/modify a shader for it.


Honest question. I know we don't currently have a projected texture, or projection anything ability at the moment, but every time it is brought up it seems like I hear the answer is shaders. The question that immediately comes to mind, is what is this shader being applied to? I mean, if everything the projection is cast onto needs this shader, wouldn't that severely limit your possibilities? Or is this some reference to a shader that you would apply to the spotlight itself that does some fancy stuff with the fragment shader to deform the projection to what it is cast upon?

Rock on
~FlaH

For spot lights what we need is to implement it in the lighting shader, so it would be applied to any materials using the lighting definition.



For projected textures, we would need a processor, that’s actually what’s used for shadows. A projection matrix would be computed for the projection, and every geometries in the scene would be rendered once again (over the classic render) with a shader that apply a given texture with the projection matrix.



This still needs to be done heh :stuck_out_tongue:

Yeah, I’ve been looking at some tutorials and such online for direct GLSL implementations of spotlights and projection. It’s mostly way over my head, and looks fairly difficult, so I haven’t made any progress either :stuck_out_tongue: No biggy.



~FlaH

1 Like

Hi tehflah.

I have tried GLSL projection in JME3, but can’t (http://hub.jmonkeyengine.org/groups/graphics/forum/topic/projected-texture-question/) . Could you tell me if you can implement.



Thanks.