Panda3D: Illuminations

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”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s





Follow

Get every new post delivered to your Inbox.