Cannot get Lighting to work.

Ok so I’m pretty new to Panda3d and Python, I’ve been using them for about 3-4 days now and I have hit (another) wall blocking my progress.

This wall is that I cannot get any lighting to work. At all. I’m stuck with the default flat lighting and my project needs light and shadows and such to make it look good.

This is the code I am using to attempt to light my stuff at the moment:

I realize I might need to import something or… dunno. I don’t know enough about Panda3d and Python to know if there is something I have missed. If you have any suspicions at all please say so I can try them. Or I might have missed something really basic. Either way, I need some help please.


It seems you called your function PointLight, I would strongly suggest against this because if it would not cause Python to get confused about whether to call your function or the Panda PointLight class you will at some point in the future be confused about it and mess up.

Other option that I suggest is you try with and without the shader autogeneration.

Look at the last section on this page closely :

Ok I’ve tried both these things and I’m still getting nothing.

Here is my current code:

Do I need to import anything to get lighting/shadows to work perhaps?

Seems you have are already being confused by your duplicate usage of the name PointLight. The assignment of plight should be PointLight not APointLight.

The PointLight itself will be defined when you imported it like so:

from panda3d.core import PointLight

Furthermore you then pasted code from the page I linked without properly adjusting it and thus the variable “light” will never be defined.

Are you not getting plenty of runtime errors ? Usually those can help us a long way to help you with the exact problem you’re having.

To me it seems your lack of knowledge in python and general programming is the first hurdle you’re already having trouble with.

I’m not saying you should stop asking questions but reading some more python examples and more experimenting with panda samples would prevent you from getting confused.

Well I’ve got the import code in, and I have had for a while, without success.

If I have understood what you said correctly, you said that the PointLight is already defined by the said code, so I removed it and the indents so it fits into the “def init”.

I get a runtime error now that looks like this:

The VBase4 is from the lights lines of code, but I do not have a clue what to do. Assuming I’ve got this all right that is.

I have done programming in the past, I did JavaScript for a year procedural, and I’m now doing Java in Netbeans and have been since September. Python is new to me and quite a large jump.

from panda3d.core import VBase4

I tried that in the following format earlier without success:

Either way by itself it works.

Now I get this error:

Not a clue what libpanda is.

It’s plight.setAttenuation, not plight.node.setAttenuation.

I would suggest familiarising yourself with Python programming before you get into Panda3D programming.