This import statement allows you to use lightsources:
from pandac.PandaModules import *
1.1 Creating light sources
AmbientLight(name) DirectionalLight(name) PointLight(name) setAttenuation(Point3(A, B, C)) # try A=0, B=0, C between 0 and 1 Spotlight(name) setLens(lens) # e.g PerspectiveLens()
To create colored lights:
myLight.setColor(VBase4(r, g, b, a))
1.2 Attach a light to the scenegraph
node = render.attachNewNode(myLight) # attach to root
We get a node back and get then apply node methods to it (don’t apply node methods to the light objects directly).
1.3 Light node methods
setPos(x,y,z) lookAt(myObject) # nice with spots setHpr(x,y,z) # direction vector; useful for directional lights
1.4 Select objects illuminated by a light source
render.setLight(node) # will apply light everywhere render.clearLight(node) # disable
See Panda3D lighting basics (from their website) for more details.
Yet another episode in my Panda3D crash tutorial. If you followed through I’m sure you got the hang of it.
Damn. By the way, I haven’t tested any of this. Sure, there must be some caveats, right?
0 Responses to “Panda3D: Illuminations”