Lighting and shadows error

I’m on to chapter 4 of “Panda3d 1.7 Game Developer;s Cookbook”.

I have followed the recipe exactly, which is supposed to show the walking panda lit by four lights and a bit of shadow. The script runs, opening a panda window but then I get a Windows message saying Python has stopped working. The cmd window shows the following messages:

I’m not sure where to look for the solution. I’ve got three options:

  1. an error in my code (below)
  2. a bug in Panda3D
  3. the fact that I’m using a netbook with only an on-board graphics chip and no graphics card.

Any ideas?

from direct.showbase.ShowBase import ShowBase
from direct.actor.Actor import Actor
from panda3d.core import *

class Application(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        self.panda = Actor("panda", {"walk": "panda-walk"})
        self.panda.reparentTo(render)
        self.panda.loop("walk")

        cm = CardMaker("plane")
        cm.setFrame(-10, 10, -10, 10)
        plane = render.attachNewNode(cm.generate())
        plane.setP(270)

        self.cam.setPos(0, -40, 6)

        ambLight = AmbientLight("ambient")
        ambLight.setColor(Vec4(0.2, 0.1, 0.1, 1.0))
        ambNode = render.attachNewNode(ambLight)
        render.setLight(ambNode)

        dirLight = DirectionalLight("directional")
        dirLight.setColor(Vec4(0.1, 0.4, 0.1, 1.0))
        dirNode = render.attachNewNode(dirLight)
        dirNode.setHpr(60, 0, 90)
        render.setLight(dirNode)

        pntLight = PointLight("point")
        pntLight.setColor(Vec4(0.8, 0.8, 0.8, 1.0))
        pntNode = render.attachNewNode(pntLight)
        pntNode.setPos(0, 0, 15)
        self.panda.setLight(pntNode)

        sptLight = Spotlight("spot")
        sptLens = PerspectiveLens()
        sptLight.setLens(sptLens)
        sptLight.setColor(Vec4(1.0, 0., 0.0, 1.0))
        sptLight.setShadowCaster(True)
        sptNode = render.attachNewNode(sptLight)
        sptNode.setPos(-10, -10, 20)
        sptNode.lookAt(self.panda)
        render.setLight(sptNode)

        render.setShaderAuto()
                        

The code works well for me as is. I would suspect it’s just that your hardware doesn’t support the needed set of functions.

I checked on Panda 1.7.2, Ubuntu 10.10, GTX460 GPU.

Thanks for checking - looks like I’ll have to find another computer :unamused:

I ran a test on another machine, with a graphics card this time and the script ran perfectly. It was a simple hardware limitation.

:blush: