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 – blending layers to create nebulas


Blending layers together will allow us to produce nebulas that are richer and more complicated.

  1. In Spacescape, go to File | New.

  2. Click on the New Layer button and open the settings for the new layer. Change the Layer Name to Purple Nebula.

  3. Change the Layer Type to noise.

  4. Click on the little plus icon next to Inner Colour to open the list of channels. Input the following values for the color channels, and leave Alpha at 255:

    Red: 0
    Green: 0
    Blue: 255
  5. Click on the little plus icon next to Outer Colour to open the list of channels. Input the following values:

    Red: 255
    Green: 0
    Blue: 0
  6. Set the Gain to 0.700. Set the Lacunarity to 2.2000. Set the Octaves to 6. Set the Random Seed to 3587.

  7. Click on the New Layer button again. Change the name for this layer to Purple Nebula Smooth Mask, and then change the Layer Type to noise.

  8. Set the Random Seed to 9216, set the Octaves to 6, and change the Threshold to 0.200.

  9. Change the Dest Blend Factor to src_alpha and the Source Blend Factor to zero.

  10. Add another new layer. Name this one Purple Nebula Ridged Mask and change the Layer Type to noise.

  11. Change the Noise Type to ridged.

  12. Enter the following settings:

    Random Seed: 4981
    Dest Blend Factor: one_minus_src_alpha
    Gain: 0.700
    Lacunarity: 2.700
    Octaves: 7
    Power: 0.500
    Source Blend Factor: zero
  13. Create another new layer and give it these settings:

    Layer Name: Light Pink Nebula
    Layer Type: noise
    Noise Type: ridged
    Random Seed: 1154
    Gain: 0.450
    Lacunarity: 2.250
    Octaves: 5
    Power: 0.150
    Threshold: 0.700
  14. Click on the small plus icon beside Inner Colour and change the three color channel values.

    Red: 127
    Green: 32
    Blue: 63
  15. Use the Copy Layer button to create a duplicate of the Light Pink Nebula layer. Change its settings to match the following values:

    Layer Name: Light Purple Nebula
    Gain: 0.600
    Lacunarity: 2.100
    Noise Scale: 1.025
  16. Naturally, we need to change the color of this layer to be light purple instead of pink:

    Red: 127
    Green: 32
    Blue: 127

What just happened?

That should do it for our nebulas. The layer blending options we picked for the two masks are the real stars of the show here. We set the Source Blend Factor to zero to turn off the layer's color completely. We only need the noise values.

For the smooth mask we set the Dest Blend Factor to src_alpha to tell the layers underneath, in our case just Purple Nebula, to use the noise values of Purple Nebula Smooth Mask for its alpha. This darkened it because the background in Spacescape is black and we're letting more of the background show through. The important part is that we based it on the mask's noise values, which means parts of it darkened more than others, creating additional variation.

The second mask, Purple Nebula Ridged Mask, adds some grit and detail to the background nebula. We used one_minus_src_alpha for the Dest Blend Factor on that layer because we wanted the higher noise values, the peaks of the ridges, to be the darkest parts of our nebula. In effect, by using one_minus_src_alpha instead of src_alpha, we turned the peaks of the ridges into canyons that cut into Purple Nebula.