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

Time for action – getting started with Spacescape


To get a basic understanding of how to use Spacescape, let's create a simple nebula with some stars in it.

  1. Double-click the Spacescape.exe file in the Spacescape folder to start the program. When the program starts, a screen similar to the following screenshot comes up:

  2. Click on the New Layer button to introduce a new layer to the scene, and then click on the plus icon to the left of the new layer. This will open the settings for that layer. The second item on the list, Layer Type, is currently set to points. Click on the word points to get a drop-down box of options and then select the noise option.

  3. This changes the available settings for the layer, and instead of seeing white dots in our preview we now see a gray cloud. Without worrying about what they all mean exactly, we're going to edit some of the values for this layer.

  4. Click on the values to the right of the Inner Colour setting and a button with an ellipses(. . .) on it will appear on the right-hand side of those values. Click on that button to open the color picker, and choose the purple color at the bottom-left of the Basic Colours section.

  5. Next, change the Lacunarity from 2.000 to 2.200.

  6. Change the Octaves to 6.

  7. Change the Power to 1.200.

  8. Change the Threshold to .450.

  9. Now, we have a dark purple cloud with a bit of graininess to it that looks sort of like a nebula. Let's go ahead and throw in some stars as well. Click on the New Layer button again.

  10. Click on the plus icon next to the new layer to open its options. Click on the values for the Near Colour and open the color picker again. Choose the same purple, but adjust the Sat down to 180 and then click on the OK button.

What just happened?

We've got a decent start going there, and we've seen the basic premise behind Spacescape: layers of noise and stars. Before we start getting more complicated, though, we should talk about the noise layers and their controls.

The noise layers are generated by adding a series of noise functions together. These noise functions use wave-forms to produce a value between 0 and 1 for each pixel, and that value determines the mix of the inner and outer color for the pixel. A value of 0 means pure outer color, and a value of 1 means pure inner color. A value of .5 would be halfway in between the two.

There are two types of noises to choose from: fbm and ridged . Fbm noise creates a smoother, more cloud noise. Ridged noise contains ridges that resemble tendrils or electricity.

There are three settings that control the basic wave-form: octaves, gain, and lacunarity.

  • Lacunarity: Controls the size of the "major" regions in the noise. Higher values produce smaller, more numerous regions. Typically, this value is kept fairly close to 2.

  • Gain: Controls the grittiness, or roughness, of the "major" regions. Higher values will produce rougher regions. This value is usually set between 0 and 1.

  • Octaves: Controls the number of additive noise functions that are used. This value effectively multiplies the lacunarity and gain. Usually 4 to 8 octaves are used. If this value is less than 2, gain and lacunarity will have no effect.

We have two settings that let us control the distribution of the noise value after it has been generated by the wave-form: power and threshold.

  • Threshold: This setting creates a lower limit for the noise value. Essentially, the noise value in each pixel is reduced by the threshold. This value needs to remain between 0 and 1.

  • Power: This setting is an amplifier for the noise value, and it is applied after the threshold. Essentially, a higher power will push the noise values that remain toward 1, the inner color. Noise values of 0 are not affected by power.

There are three remaining settings for noise that we haven't talked about yet. They are noise scale, noise offset, and random seed.

  • Noise scale: Adjusts the initial coordinates for the noise. It's difficult to predict exactly how this will affect the result, but that doesn't mean it's useless. We'll use noise scale to produce variation in noise layers we've copied.

  • Noise offset: This setting is only used by ridged noise. It controls the contrast of the ridges. A value of .5 results in a flat mix of the inner and outer colors, and a value of 1 allows the ridges to reach the pure inner color. Overdriving this value beyond 1 will force more of the ridges to the pure inner color, which can look pretty ugly. Values between .5 and 1 are recommended.

  • Random Seed: It's impossible for a computer to generate a truly random number, but by performing operations on a seed number a pseudo-random number can be generated. Spacescape uses pseudo-random numbers when generating noise, and random seed is the seed number used. The same seed number will always produce the same result, so two layers that have the same settings and the same random seed will be the same. Different random seeds will produce different layers of the same style.