Panda3D 1.6 Game Engine Beginner's Guide

5 (1 reviews total)
By David Brian Mathews
    Advance your knowledge in tech with a Packt subscription

  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Installing Panda3D and Preparing a Workspace

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

Publication date:
February 2011
Publisher
Packt
Pages
356
ISBN
9781849512725

 

Chapter 1. Installing Panda3D and Preparing a Workspace

It's time to take the first big step. In this chapter we're going to acquire Panda3D and get our work environment set up. Once we have all that done, we're going to take a look at the game we'll be creating over the course of this book.

In this chapter we shall:

  • Download and install Panda3D

  • Download and install Notepad++

  • Install all of the content necessary for the game

  • Demo the game we'll be creating

  • Install any optional tools desired

    • Blender and Chicken

    • Spacescape

    • Explosion Texture Generator

There's no time to waste, so let's get cracking!

 

Getting started with Panda3D installation packages


The kind folks who produce Panda3D have made it very easy to get Panda3D up and working. You don't need to worry about any compiling, library linking, or other difficult, multi-step processes. The Panda3D website provides executable files that take care of all the work for you. These files even install the version of Python they need to operate correctly, so you don't need to go elsewhere for it.

 

Time for action – downloading and installing Panda3D


I know what you're thinking: "Less talk, more action!" Here are the step-by-step instructions for installing Panda3D:

  1. Navigate your web browser to www.Panda3D.org.

  2. Under the Downloads option, you'll see a link labeled SDK. Click it.

  3. If you are using Windows, scroll down this page you'll find a section titled Download other versions. This book is written for Panda3D version 1.6.2, which is the most current stable version at the time of writing. Find the link to Panda3D SDK 1.6.2 and click it. If you aren't using Windows, click on the platform you are using (Mac, Linux, or any other OS.). That will take you to a page that has the downloads for that platform. Scroll down to the Download other versions section and find the link to Panda3D SDK 1.6.2, as before.

  4. When the download is complete, run the file and this screen will pop up:

  5. Click Next to continue and then accept the terms. After that, you'll be prompted about where you want to install Panda3D.

  6. The default location is just fine. Click the Install button to continue. Wait for the progress bar to fill up. When it's done, you'll see another prompt.

  7. This step really isn't necessary. Just click No and move on.

  8. When you have finished the installation, you can verify that it's working by going to Start Menu | All Programs | Panda3D 1.6.2 | Sample Programs | Ball in Maze | Run Ball in Maze. A window will open, showing the Ball in Maze sample game, where you tilt a maze to make a ball roll around while trying to avoid the holes.

What just happened?

You may be wondering why we skipped a part of the installation during step 7. That step of the process caches some of the assets, like 3D models and such that come with Panda3D. Essentially, by spending a few minutes caching these files now, the sample programs that come with Panda3d will load a few seconds faster the first time we run them, that's all.

Now that we've got Panda3D up and running let's get ourselves an advanced text editor to do our coding in.

 

Switching to an advanced text editor


The next thing we need is Notepad++. Why, you ask? Well, to code with Python all you really need is a text editor, like the notepad that comes with Windows XP. After typing your code you just have to save the file with .py extension. Notepad itself is kind of dull, though, and it doesn't have many features to make coding easier.

Notepad++ is a text editor very similar to Notepad. It can open pretty much any text file and it comes with a pile of features to make coding easier. To highlight some fan favorites, it provides language mark-up, a Find and Replace feature, and file tabs to organize multiple open files. The language mark-up will change the color and fonts of specific parts of your code to help you visually understand and organize it. With Find and Replace you can easily change a large number of variable names and also quickly and easily update code. File tabbing keeps all of your open code files in one window and makes it easy to switch back and forth between them.

 

Time for action – downloading and installing Notepad++


Now that you're convinced, let's get Notepad++ up and running. If you aren't convinced or want to use some other software to code with, that's fine. Just skip to the next section.

  1. Navigate your web browser to http://notepad-plus-plus.org. Click on the Download tab on the page.

  2. Click the link to Download Current Version.

  3. Click the link that ends with Installer.exe.

  4. When your download is finished run the file and you'll see this screen pop up:

  5. Click Next to get the installation started and accept the terms. You'll be prompted again about where you want to install.

  6. Again, the default directory is just fine. Click Next and you'll find yourself prompted once more, this time about the components you want to install.

  7. The default configuration contains everything you'll need, so just click Install. When it's done go ahead and open Notepad++ so it can update itself if necessary.

What just happened?

That does it for Notepad++. Next we need to install all the game content we'll be using as we go through the tutorials in this book.

 

Installing the game content


To get all the content for the game that will be used over the course of the book, head to the Packt website and download the code file . Unzip the file, and place the folder BGP3D in an easy-to-get-to place on the system. For Windows users, the C: drive is recommended.

 

Time for action – demoing Suicide Jockeys


The last thing we'll cover in this chapter is how to load a Panda3D game from the command prompt. Until the game is packaged and ready for shipping, this is how we'll run it. Don't worry, it's easy.

  1. Open a command prompt by going to the Start menu | All Programs| Accessories and choosing Command Prompt.

  2. Open Windows Explorer the same way.

  3. In Windows Explorer click on the View menu at the top, highlight toolbars, and if Address Bar does not have a check before it, click on it. This will show your current directory in the window.

  4. Navigate Windows Explorer to BGP3D/Demo and copy the entire address bar with Ctrl+C or by right-clicking and selecting Copy.

  5. Return to the Command Prompt window and type in cd followed by a space. Then right-click on the Command Prompt window and select Paste. This will insert the directory address you copied from Windows Explorer.

  6. Hit Enter and you'll see the directory in the Command Prompt change. Next, type in python main.py and hit Enter. The game will launch.

What just happened?

Not bad, right? We just learned how to run a Python file from the command prompt, something we'll be doing quite a bit. The python command we used tells the system to use the Python interpreter to run the file we supply.

main.py is the name of the file that starts Panda3D and the game components. We'll go into more depth about how that works in the next chapter, so get ready!

 

Installing optional tools


There are a couple of optional tools that you can get for free and are worth pointing out. These tools are great for specific things, but none of them are strictly necessary for this book since all of the content they create is provided with the book. Nevertheless, we'll mention them here and provide tutorials on using some of them in the appendices for later projects when you've finished this book and need to create your own content for your own games. Since these tools are optional we won't go step-by-step through their installations, but we will tell you where you can find them.

Blender and Chicken

Blender is an open source, free to use, 3D modeling and animation package based in Python. It's a full service package that's quite powerful and even used in some professional studios. Furthermore, it has an active community and lots of tutorials available on the web to help get new users up to speed with the program. A significant portion of the Panda3D community uses Blender to create their 3D content as well.

Another feather in Blender's cap isn't part of the core package but bears mentioning. That is Chicken, a plug-in for Blender that exports models and animations in .egg files, one of the formats that Panda3D uses. Chicken let's you directly export from Blender to Panda3D without any intermediate conversions, and if you have experience with game development you know how nice that sort of simple pipeline from content creation to implementation really is. If you don't have that experience, then take our word for it. It's really nice.

You can find Blender, and some Blender tutorials, at www.blender.org. Blender v2.5 introduces some major changes that Chicken is not currently compatible with, so it may be wise to get an older version. Blender is available in executable installers, and all the default options work just fine. Do note that Blender doesn't come with Python like Panda3D does. To get the most out of Blender, install the version of Python it requires. For example, Blender v2.49 requires Python v2.6. The version of Python that comes with Panda3D is v2.5, so that won't work. Also, the latest version of Python at the time of this writing, v2.7, also won't work. Python does offer older versions on their website, and version 2.6.6 will work with Blender v2.49. Python also comes in executable installers, and again the default options are fine. Having both versions of Python on one computer won't cause any conflicts either. The Blender installer will direct us to the Python website when it fails to detect a Python version that it can use, but that website is at www.python.org if needed. Python documentation can also be found there.

You can find Chicken at http://chicken-export.sourceforge.net/. Chicken doesn't provide an executable installer, but the zip file that it does come in has a text file with installation instructions for various platforms in it. Note that in order for Chicken to work with Blender, the appropriate version of Python must be installed as noted in the previous paragraph.

Spacescape

The next optional tool was created by Alex Peterson and is used for creating sky boxes. If that's a new term to you, a sky box is basically a very large cube placed around an outdoor environment in a game that provides a backdrop. Spacescape in particular is designed for creating space environments, full of stars and nebulas. The nice thing about spacescape is that it exports all six of the images you need for a sky box, one for each face, and they are all seamless and virtually ready to use. For Panda3D, all you need to do is rename the files. Here are a few example of images you can make in Spacescape:

You can find Spacescape by searching for it on sourceforge.net or by going to Alex Peterson's blog at http://alexcpeterson.com/spacescape. Spacescape doesn't require any sort of installation, per se. All that's needed is to extract the zip file it comes in and place the folder that is contained in it somewhere on the computer. Once that's done, the program will run.

Explosion Texture Generator

This is another tool created by a single author, a gentleman by the name of Sascha Willems. Explosions are pretty common in video games but creating a series of images to turn into an animated "movie" of an explosion can be a real pain. This tool makes it much easier. All that's needed is to input a couple of values for the explosions before and the tool will produce a palette image with every frame of the animation you need. There's a good deal of customization available so you can create gobs of different explosion types. Also, the tool outputs .png files with the alpha already embedded in them, so you don't have to worry about what parts of the image need to be transparent. It's handled for you. Explosion Texture Generator can be found on Sascha Willems's web page at http://www.saschawillems.de/?page_id=253. Here's an example of the output this tool creates:

Like Spacescape, ExploTexGen doesn't require an installation. Just unzip the file and put the contents in a folder, then it will run as intended.

 

Summary


We spent most of the chapter installing the tools we need to use Panda3D.

We talked about and installed:

  • Panda3D 1.6.2

  • Notepad++

We also talked about some helpful optional tools that can be useful for creating game content. Oh, and let's not forget that we took a look at the demo for the game we'll be making over the course of this book!

We've got everything prepared now; it's time to move on to the real deal.

About the Author

  • David Brian Mathews

    David Brian Mathews is a graduate in Electronic Visualization program from the University of Illinois at Chicago. He began programming in the fifth grade with QBASIC and has been designing games of various kinds, from table-top board games to computer games, since childhood. Prior to entering higher education, he served for two years in the United States Navy as a nuclear engineer before being honorably discharged for medical reasons, where he learned discipline, advanced mathematics, and nuclear theory, as well as teamwork and leadership skills. During his years in school, Mathews earned valuable experience with professional game development methods working both by himself and with teams. He is skilled at programming, 3D modeling and animation, drawing, and 2D compositing.

    Browse publications by this author

Latest Reviews

(1 reviews total)
It was very easy to follow, even for a total beginner like me (even though the tutorial for coding the race track can be intimidating at first.) Although now a bit outdated regarding some bits of code in the book, it still has a lot of relevance. If you aren't good with reading the Panda 3D manual, I highly recommend reading this book instead. It has a lot of the same information, it's just taught to you in an easier-to-follow manner. This is also the only information I've seen available for using the Panda 3D engine outside of the official Panda 3D manual and forums. Take that piece of information as you will.
Panda3D 1.6 Game Engine Beginner's Guide
Unlock this book and the full library for FREE
Start free trial