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

Downloading and configuring NetBeans to work with Panda3D


When writing code, having the right set of tools at hand and feeling comfortable when using them is very important. Panda3D uses Python for scripting and there are plenty of good integrated development environments available for this language like IDLE, Eclipse, or Eric. Of course, Python code can be written using the excellent Vim or Emacs editors too.

Tastes do differ, and every programmer has his or her own preferences when it comes to this decision. To make things easier and have a uniform working environment, however, we are going to use the free NetBeans IDE for developing Python scripts throughout this book. This choice was made out of pure preference and one of the many great alternatives might be used as well for following through the recipes in this book, but may require different steps for the initial setup and getting samples to run.

In this recipe we will install and configure the NetBeans integrated development environment to suit our needs for developing games with Panda3D using the Python programming language.

Getting ready

Before beginning, be sure to download and install Panda3D. To download the engine SDK and tools, go to www.panda3d.org/download.php:

The Panda3D Runtime for End-Users is a prebuilt redistributable package containing a player program and a browser plugin. These can be used to easily run packaged Panda3D games. You can find more information on this topic in Chapter 12, Packaging and Distribution.

Under Snapshot Builds, you will be able to find daily builds of the latest version of the Panda3D engine. These are to be handled with care, as they are not meant for production purposes.

Finally, the link labeled Panda3D SDK for Developers is the one you need to follow to retrieve a copy of the Panda3D development kit and tools. This will always take you to the latest release of Panda3D, which at this time is version 1.7.0. This version was marked as unstable by the developers but has been working in a stable way for this book. This version also added a great amount of interesting features, like the web browser plugin, an advanced shader, and graphics pipeline or built-in shadow effects, which really are worth a try and will be treated in the following chapters.

Click the link that says Panda3D SDK for Developers to reach the page shown in the following screenshot:

Here you can select one of the SDK packages for the platforms that Panda3D is available on. This book assumes a setup of NetBeans on Windows but most of the samples should work on these alternative platforms too, as most of Panda3D's features have been ported to all of these operating systems.

To download and install the Panda3D SDK, click the Panda3D SDK 1.7.0 link at the top of the page and download the installer package. Launch the program and follow the installation wizard, always choosing the default settings. In this and all of the following recipes we'll assume the install path to be C:\Panda3D-1.7.0, which is the default installation location. If you chose a different location, it might be a good idea to note the path and be prepared to adapt the presented file and folder paths to your needs!

How to do it...

Follow these steps to set up your Panda3D game development environment:

  1. Point your web browser to netbeans.org and click the prominent Download FREE button:

  2. Ignore the big table showing all kinds of different versions on the following page and scroll down. Click the link that says JDK with NetBeans IDE Java SE bundle.

  3. This will take you to the following page as shown here. Click the Downloads link to the right to proceed.

  4. You will find yourself at another page, as shown in the screenshot. Select Windows in the Platform dropdown menu and tick the checkbox to agree to the license agreement. Click the Continue button to proceed.

  5. Follow the instructions on the next page. Click the file name to start the download.

  6. Launch the installer and follow the setup wizard.

  7. Once installed, start the NetBeans IDE.

  8. In the main toolbar click Tools | Plugins.

  9. Select the tab that is labeled Available Plugins.

  10. Browse the list until you find Python and tick the checkbox next to it:

  11. Click Install. This will start a wizard that downloads and installs the necessary features for Python development.

  12. At the end of the installation wizard you will be prompted to restart the NetBeans IDE, which will finish the setup of the Python feature.

  13. Once NetBeans reappears on your screen, click Tools| Python Platforms.

  14. In the Python Platform Manager window, click the New button and browse for the file C:\Panda3D-1.7.0\python\ppython.exe.

  15. Select Python 2.6.4 from the platforms list and click the Make Default button. Your settings should now reflect the ones shown in the following screenshot:

  16. Finally we select the Python Path tab and once again, compare your settings to the screenshot:

  17. Click the Close button and you are done!

How it works...

In the preceding steps we configured NetBeans to use the Python runtime that drives the Panda3D engine and as we can see, it is very easy to install and set up our working environment for Panda3D.

There's more...

Different than other game engines, Panda3D follows an interesting approach in its internal architecture. While the more common approach is to embed a scripting runtime into the game engine's executable, Panda3D uses the Python runtime as its main executable. The engine modules handling such things as loading assets, rendering graphics, or playing sounds are implemented as native extension modules. These are loaded by Panda3D's custom Python interpreter as needed when we use them in our script code.

Essentially, the architecture of Panda3D turns the hierarchy between native code and the scripting runtime upside down. While in other game engines, native code initiates calls to the embedded scripting runtime, Panda3D shifts the direction of program flow. In Panda3D, the Python runtime is the core element of the engine that lets script code initiate calls into native programming libraries.

To understand Panda3D, it is important to understand this architectural decision. Whenever we start the ppython executable, we start up the Panda3D engine.

Note

If you ever get into a situation where you are compiling your own Panda3D runtime from source code, don't forget to revisit steps 13 to 17 of this recipe to configure NetBeans to use your custom runtime executable!