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

Controlling the rendering order


To be able to render with good performance and display effects like transparency correctly, Panda3D automatically sorts the scene geometry and puts it into "cull bins", so vertices that share the same texture, for example, are sent to the graphics card in one batch.

Panda3D allows you to change the rendering order manually, to achieve custom scene sorting, which is what you will learn in this recipe.

Getting ready

This recipe requires the base code created in Setting up the game structure found in Chapter 1, to which the following sample code will be added.

How to do it...

Let's get started with this recipe's tasks:

  1. Add the following code to Application.py:

    from direct.showbase.ShowBase import ShowBase
    from direct.actor.Actor import Actor
    
    class Application(ShowBase):
        def __init__(self):
            ShowBase.__init__(self)
            self.panda = Actor("panda", {"walk": "panda-walk"})
            self.panda.reparentTo(render)
            self.panda.loop("walk")
            self...