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 – populating the sky with stars


There's no better teacher than experience, so let's get some stars in that sky. To get the variety we want, we'll be using nine-point star layers and five billboard star layers. Once we finish with all the layers, we'll do an export to make sure they look how we want them to.

  1. Starting from where we left off, click on the New Layer button to create a new point star layer.

  2. Select the new layer and click on the Move Down button to move the layer down in the stack. We want it to be between the Purple Nebula Ridged Mask and the Purple Nebula Smooth Mask layers.

  3. Change the settings on the new layer to the following:

    Layer Name: Dark Purple Stars
    Near Colour: 96, 0, 96
    Number of Points: 10000
    Point Size: 2
  4. Set the Random Seed for Dark Purple Stars to 2573. Make sure to set the Random Seed, NOT the Mask Random Seed. Random Seed applies to the stars; Mask Random Seed applies to the mask that controls star placement. That mask is turned off right now, so Mask Random Seed won't affect anything.

  5. With the Dark Purple Stars layer highlighted, click on the Copy Layer button. This will put a duplicate layer above it. We're going to use this duplicate layer to create some brighter stars in the background layer. Change its settings to the following values:

    Layer Name: Bright Purple Stars
    Random Seed: 6413
    Near Colour: 255, 64, 255
    Number of Points: 1000
    Point Size: 1
  6. Just because we're using point stars doesn't mean we can't give the bright ones a subtle halo. To do that, we'll use a second layer of darker, larger point stars with the same Random Seed so that the stars will stack on top of each other. Use the Copy Layer button to create a copy of the Bright Purple Stars layer then select the new copy and click on the Move Down button to put it right beneath the Bright Purple Stars layer.

  7. Change the settings of the copied layer as follows:

    Layer Name: Bright Purple Stars Backing
    Near Colour: 160, 0, 160
    Point Size: 2
  8. We have two more layers to add beneath Purple Nebula Ridged Mask. This time, though, we'll be using billboard layers. Click on the New Layer button and then use the Move Down button to move the new layer just underneath Purple Nebula Ridged Mask.

  9. Give the new layer these settings:

    Layer Name: Dark Blue Billboard Stars
    Layer Type: billboards
    Random Seed: 6457
    Far Colour: 127, 127, 127
    Max Billboard Size: 0.050
    Min Billboard Size: 0.010
    Near Colour: 255, 255, 255
    Number of Billboards: 75
    Billboard Texture: flare-blue-purple1.png
  10. Billboard Texture must be set to the exact string flare-blue-purple1.png or it won't be able to find the file. Spacescape looks in the folder Spacescape\media\materials\textures for the images to use on billboards. There's a decent number of images there that we can use.

  11. Use the Copy Layer button to duplicate the Dark Blue Billboard Stars layer then give the copy these settings:

    Layer Name: Dark Red Billboard Stars
    Random Seed: 4153
    Billboard Texture: flare-red1.png
  12. Next, we're going to create some stars that will coincide with small, bright nebulas. We'll make sure the stars stick to the nebulas by turning on the masks in the star layers and setting the mask settings to match the nebula. Create another new layer with the New Layer button. Leave it on the top of the stack this time. These are the settings for it. Note that the mask settings are the same as the settings for the Light Purple Nebula, with the exception of the Threshold.

    Layer Name: Bright Light Purple Stars
    Random Seed: 2837
    Mask Enabled: True (check the box)
    Mask Noise Type: ridged
    Mask Gain: 0.600
    Mask Lacunarity: 2.100
    Mask Octaves: 5
    Mask Power: 0.150
    Mask Noise Scale: 1.025
    Mask Random Seed: 1154
    Mask Threshold: 0.650
    Near Colour: 255, 84, 255
    Number of Points: 2500
  13. Use the Copy Layer button to duplicate the Bright Light Purple Stars layer we just made. Change the settings on the new copy as follows:

    Layer Name: Extra Bright Light Purple Stars Backing
    Random Seed: 3571
    Near Colour: 127, 64, 127
    Number of Points: 500
    Point Size: 2
  14. Copy Extra Bright Light Purple Stars Backing as well. Change the new copy to these settings:

    Layer Name: Extra Bright Light Purple Stars
    Near Colour: 255, 84, 255
    Point Size: 1
  15. Unfortunately, we can't use the layer copying feature to keep the same mask settings for a billboard star layer. Changing the Layer Type to billboards will remove the mask settings. We'll just create a new layer instead, and put in these settings for it:

    Layer Name: Bright Blue Billboard Stars
    Layer Type: billboards
    Random Seed: 2311
    Far Colour: 127, 127, 127
    Mask Enabled: True
    Mask Noise Type: ridged
    Mask Gain: 0.600
    Mask Lacunarity: 2.100
    Mask Octaves: 5
    Mask Power: 0.150
    Mask Noise Scale: 1.025
    Mask Random Seed: 1154
    Mask Threshold: 0.700
    Max Billboard Size: 0.040
    Min Billboard Size: 0.015
    Near Colour: 255, 255, 255
    Number of Billboards: 25
    Billboard Texture: flare-blue-spikey1.png
  16. That's it for the stars that will mimic the Light Purple Nebula layer. Next, we'll use the same techniques to add stars to the Light Pink Nebula. Click on the New Layer button and open the settings for the new layer. Change these values:

    Layer Name: Bright Light Pink Stars
    Random Seed: 9164
    Mask Enabled: True
    Mask Noise Type: ridged
    Mask Gain: 0.450
    Mask Lacunarity: 2.250
    Mask Octaves: 5
    Mask Power: 0.150
    Mask Random Seed: 1154
    Mask Threshold: 0.650
    Near Colour: 255, 114, 114
    Number of Points: 2500
  17. Make a copy of the Bright Light Pink Stars layer we just made and change these settings in the copy:

    Layer Name: Extra Bright Light Pink Stars Backing
    Random Seed: 3654
    Near Colour: 127, 64, 64
    Number of Points: 500
    Point Size: 2
  18. Make a copy of the Extra Bright Light Pink Stars Backing layer we just finished and change the following settings to the new values provided:

    Layer Name: Extra Bright Light Pink Stars
    Near Colour: 255, 114, 114
    Point Size: 1
  19. That's all of our point star layers. We just need two more billboard star layers, and our night sky will be finished. Make a copy of the Bright Blue Billboard Stars layer and use the Move Up button to move the copy up to the top of the layer stack. Then, change the following settings in that layer:

    Layer Name: Bright Pink Billboard Stars
    Random Seed: 7388
    Mask Gain: .0450
    Mask Lacunarity: 2.250
    Near Colour: 255, 180, 180
    Billboard Texture: flare-red-yellow1.png
  20. For our last layer, copy the Bright Pink Billboard Stars layer we just made and make the following changes to it:

    Layer Name: Bright Purple Billboard Stars
    Random Seed: 8414
    Mask Gain: 0.500
    Mask Lacunarity: 2.150
    Near Colour: 255, 170, 255
    Billboard Texture: flare-blue-purple2.png
  21. Next, click on the File menu at the top of the window and select Save. Save the .xml file. We can load this file later if we want to edit the sky we've created.

  22. Once the work we've done is safely saved, go to File | Export Skybox to bring up the export dialog box. At the very bottom, change the Image Size from 512 to 1024. Navigate to BGP3D/Images then type in Purple for the filename and click on the Save button.

What just happened?

The preceding image shows all six of the pictures that Spacescape has output for us, and that brings us to the end of our work with Spacescape. The next step is to take those output images and turn them into a usable sky sphere for Panda3D.