Book Image

Panda3D 1.6 Game Engine Beginner's Guide

Book Image

Panda3D 1.6 Game Engine Beginner's Guide

Overview of this book

Panda3D is a game engine, a framework for 3D rendering and game development for Python and C++ programs. It includes graphics, audio, I/O, collision detection, and other abilities relevant to the creation of 3D games. Also, Panda3D is Open Source and free for any purpose, including commercial ventures. This book will enable you to create finished, marketable computer games using Panda3D and other entirely open-source tools and then sell those games without paying a cent for licensing. Panda3D 1.6 Game Engine Beginner's Guide follows a logical progression from a zero start through the game development process all the way to a finished, packaged installer. Packed with examples and detailed tutorials in every section, it teaches the reader through first-hand experience. These tutorials are followed by explanations that describe what happened in the tutorial and why. You will start by setting up a workspace, and then move on to the basics of starting up Panda3D. From there, you will begin adding objects like a level and a character to the world inside Panda3D. Then the book will teach you to put the game's player in control by adding change over time and response to user input. Then you will learn how to make it possible for objects in the world to interact with each other by using collision detection and beautify your game with Panda3D's built-in filters, shaders, and texturing. Finally, you will add an interface, audio, and package it all up for the customer.
Table of Contents (22 chapters)
Panda3D 1.6 Game Engine
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Panda3D is a game engine, a framework for 3D rendering and game development for Python and C++ programs. It includes graphics, audio, I/O, collision detection, and other abilities relevant to the creation of 3D games. Also, Panda3D is Open Source and free for any purpose, including commercial ventures. This book will enable you to create finished, marketable computer games using Panda3D and other entirely open source tools, and then sell those games without paying a cent for licensing.

Panda3D 1.6 Game Engine Beginner's Guide follows a logical progression from a zero start through the game development process all the way to a finished, packaged installer. Packed with examples and detailed tutorials in every section, it teaches the reader through first-hand experience. These tutorials are followed by explanations that describe what happened in the tutorial and why.

You will start by setting up a workspace, and then move on to the basics of starting up Panda3D. From there, you will begin adding objects such as a level and a character to the world inside Panda3D. Then, the book will teach you to put the game's player in control by adding changes over time and responses to user input. Then, you will learn how to make it possible for objects in the world to interact with each other by using collision detection and beautify your game with Panda3D's built-in filters, shaders, and texturing. Finally, you will add an interface, audio, and package it all up for the customer.

This is a simple but detailed guide to using Panda3D, which will take you from a blank text file all the way through the Python programming process to a finished game with a single level, including such topics as handling tasks over time, event handling and response, collision set up and detection, audio, and more.

Who this book is for

This book is targeted at independent developers who are interested in creating their own video games or other 3D applications for personal or commercial distribution at minimal expense. A basic understanding of general programming, such as knowing what a variable is, is necessary. Some familiarity with object-oriented programming and the Python language is expected, but not required.

Development teams who are interested in using Panda3D for production of 3D applications or video games would also find this book useful for training team members in the use of Panda3D.

This book does not cover the creation of three-dimensional models or similar art assets, nor does it cover the creation of two-dimensional art assets or audio assets.

What this book covers

Chapter 1, Installing Panda3D and Preparing a Workspace guides the reader through downloading and installing Panda3D and Notepad++ (an open source text editor) as well as acquiring assets provided with the book (from CD or website) and setting up the file structure for that content using Windows Explorer.

Chapter 2, Creating the Universe: Loading Terrain is the reader's first opportunity to get their hands dirty with some coding. It will take them from a blank file to a simple program that will load up a terrain model and introduce related basic concepts.

Chapter 3, Managing Tasks Over Time introduces the reader with tasks, the task manager, and controlling processes that need to occur over time or in an ongoing manner.

Chapter 4, Taking Control: Events and User Input focuses on creating user controls for the game. Keyboard, mouse click, and mouse movement response will be covered. Camera control will be integrated with handling mouse input.

Chapter 5, Handling Large Programs with Custom Classes; as the game has grown larger, the time has come to show the reader how to break it apart into custom classes.

Chapter 6, The World in Action: Handling Collisions will focus on making the reader comfortable with collision detection and the different collision event handlers. Collisions are vital to a working game and their use is one of the hottest topics on the Panda3D forums.

Chapter 7, Making it Fancy: Lighting, Textures, Filters, and Shaders will explain textures and the built-in shaders available in Panda3D while allowing the reader to apply lighting, textures, filters, and shaders to the world and the characters in it.

Chapter 8, GUI Goodness: All About the Graphic User Interface takes the reader through the production of the game's GUI, including the HUD that displays during game play, the start menu, and other bits and pieces.

Chapter 9, Animating in Panda3D; here the reader will replace the static models of hover cycles with actors and learn all about actor animation and joint manipulation.

Chapter 10, Creating Weaponry: Mouse Picking and Intervals focuses on using intervals to create weapons and their controls and describes how sequences and parallels can be used to create interval scripts.

Chapter 11, What's that Noise? Using Sound; here with the game nearly complete, it's time to introduce some sound effects and background music to bring the game to life. This chapter also introduces editing the config.prc file to change the audio library Panda3D uses.

Chapter 12, Finishing Touches: Getting the Game Ready for the Customer is the final chapter of the guide and focuses on some important functions for Panda3D-based games, including saving and loading files, garbage collection, and packing the game into a standalone package ready for shipping.

Appendix A, Creating a Sky Sphere with Spacescape teaches the reader how to use the freely available software Spacescape to create engaging backdrops for Panda3D applications.

Appendix B, Using Egg-Texture-Cards and ExploTexGen; here the reader learns how to create explosion animations with the freely available software ExploTexGen and learns to turn them into Panda3D assets with the Egg-Texture-Cards command-line utility.

What you need for this book

Panda3D 1.6, Notepad++, and Python.

Conventions

In this book, you will find several headings appearing frequently.

To give clear instructions of how to complete a procedure or task, we use:

Time for action – heading

  1. Action 1

  2. Action 2

  3. Action 3

Instructions often need some extra explanation so that they make sense, so they are followed with:

What just happened?

This heading explains the working of tasks or instructions that you have just completed.

You will also find some other learning aids in the book, including:

Pop quiz – heading

These are short multiple choice questions intended to help you test your own understanding.

Have a go hero – heading

These set practical challenges and give you ideas for experimenting with what you have learned.

You will also find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and explanations of their meanings.

Code words in text are shown as follows: "The event name we give to the accept() method is a string that serves as an identifier for the unique event we want to respond to."

A block of code is set as follows:

if(self.keyMap["d"] == True):
      self.turn("r", dt)
    elif(self.keyMap["a"] == True):
      self.turn("l", dt)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

self.menuGraphics = loader.loadModel(
      "../Models/MenuGraphics.egg")
    self.fonts = {
      "silver" : loader.loadFont("../Fonts/LuconSilver.egg"),
      "blue" : loader.loadFont("../Fonts/LuconBlue.egg"),
      "orange" : loader.loadFont("../Fonts/LuconOrange.egg")}

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Now we see an entry for the Cycle Move task in the sleep column".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Tip

Downloading the example code for this book

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/2725_images.pdf

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt Publishing, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.