O'Reilly logo

Panda3D 1.6 Game Engine by Dave Mathews

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - adding lights to the game

To get a feel for lights, let's go ahead and throw some into our game!

  1. Open up the TrackClass_00.py file in the Chapter07 folder.
  2. We'll start with a new method that will create two lights for us and assign them to illuminate the entire scene. Add this method to the bottom of the Track class:
    def setupLight(self):
    primeL = DirectionalLight("prime")
    primeL.setColor(VBase4(.6,.6,.6,1))
    self.light = render.attachNewNode(primeL)
    self.light.setHpr(45,-60,0)
    render.setLight(self.light)
    ambL = AmbientLight("amb")
    ambL.setColor(VBase4(.2,.2,.2,1))
    self.ambLight = render.attachNewNode(ambL)
    render.setLight(self.ambLight)
    return
    
  3. Of course, we need to call that new method in order for it to do anything. Add this line ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required