Book Image

Panda3D 1.7 Game Developer's Cookbook

Book Image

Panda3D 1.7 Game Developer's Cookbook

Overview of this book

Table of Contents (20 chapters)
Panda3D 1.7 Game Developer's Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding lights and shadows


Lights and shadows are very important techniques for producing a great presentation. Proper scene lighting sets the mood and also adds depth to an otherwise flat-looking scene, while shadows add more realism, and more importantly, root the shadow-casting objects to the ground, destroying the impression of models floating in mid-air.

This recipe will show you how to add lights to your game scenes and make objects cast shadows to boost your visuals.

Getting ready

You need to create the setup presented in Setting up the game structure found in Chapter 1, Setting Up Panda3D and Configuring Development Tools before proceeding, as this recipe continues and builds upon this base code.

How to do it...

This recipe consists of these tasks:

  1. Add the following code to Application.py:

    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)
    
       ...