Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu Panda3D 1. 6 Game Engine Beginner''''s Guide by Dave Mathews doc
PREMIUM
Số trang
356
Kích thước
5.9 MB
Định dạng
PDF
Lượt xem
1403

Tài liệu Panda3D 1. 6 Game Engine Beginner''''s Guide by Dave Mathews doc

Nội dung xem thử

Mô tả chi tiết

www.it-ebooks.info

Panda3D 1.6 Game Engine

Beginner's Guide

Create your own computer game with this 3D rendering and

game development framework

David Brian Mathews

www.it-ebooks.info

Panda3D 1.6 Game Engine

Beginner's Guide

Copyright © 2011 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system,

or transmitted in any form or by any means, without the prior written permission of the

publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the

information presented. However, the information contained in this book is sold without

warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers

and distributors will be held liable for any damages caused or alleged to be caused directly or

indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the

companies and products mentioned in this book by the appropriate use of capitals. However,

Packt Publishing cannot guarantee the accuracy of this information.

First published: February 2011

Production Reference: 1040211

Published by Packt Publishing Ltd.

32 Lincoln Road

Olton

Birmingham, B27 6PA, UK.

ISBN 978-1-849512-72-5

www.packtpub.com

Cover Image by Charwak A ([email protected])

www.it-ebooks.info

Credits

Author

David Brian Mathews

Reviewers

Paulo Barbeiro Ferreira

Joni Hariyanto

Acquisition Editor

Usha Iyer

Development Editor

Reshma Sundaresan

Technical Editors

Arun Nadar

Manasi Poonthottam

Indexer

Hemangini Bari

Editorial Team Leader

Mithun Sehgal

Project Team Leader

Ashwin Shetty

Project Coordinators

Zainab Bagasrawala

Joel Goveya

Proofreaders

Aaron Nash

Jonathan Todd

Graphics

Nilesh R. Mohite

Production Coordinator

Kruthika Bangera

Cover Work

Kruthika Bangera

www.it-ebooks.info

About the Author

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.

I'd like to thank my friends and family, who have been immensely

supportive of me throughout the writing of this book. In particular, I'd like

to thank my mother, Carol Malley, and my friends Jeff Fuja and William

Hebert for all their efforts and sacrifices on my behalf.

www.it-ebooks.info

About the Reviewers

Paulo Barbeiro Ferreira is Brazilian, from São Paulo, and graduated in Graphic Design

in 2004 at Belas Artes SP college. He is a postgraduate in Game Development at SENAC SP.

Paulo started his professional career in 1999 as a web developer.

Today, besides the web and mobile application development work, Paulo is involved in

experimental educational projects in technology and cyber culture at SESC SP, where he

leads activities about creative code and art software, such as interactive environments,

games, and entertainment media.

Joni Hariyanto graduated from the Engineering Faculty of Brawijaya University a few years

ago. Now, he works as a freelance architect.

Actually, he's just a hobbyist in the computer science world. He has been programming since

first grade junior high in languages including Pascal, Python, and C++.

Bored with the never changing architectural visualization teaching materials at uni, he

wandered on the Internet searching for a way to get unlimited control over visualization, for

the sake of design clarity and without sacrificing too much time in the "post-design" phase;

that is, rendering the gazillion frames.

He stumbled upon Panda3D in 2005, a free 3D game engine, which makes perfect balance of

power, flexibility, and handling (from programmer's point of view). Liked it, melted with it in

no time, thanks to Python.

www.it-ebooks.info

www.PacktPub.com

Support files, eBooks, discount offers, and more

You might want to visit www.PacktPub.com for support files and downloads related to your

book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub

files available? You can upgrade to the eBook version at www.PacktPub.com and as a print

book customer, you are entitled to a discount on the eBook copy. Get in touch with us at

[email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a

range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book

library. Here, you can access, read and search across Packt's entire library of books.

Why Subscribe?

‹ Fully searchable across every book published by Packt

‹ Copy and paste, print, and bookmark content

‹ On demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access

PacktLib today and view nine entirely free books. Simply use your login credentials for

immediate access.

www.it-ebooks.info

Table of Contents

Preface 1

Chapter 1: Installing Panda3D and Preparing a Workspace 7

Getting started with Panda3D installation packages 8

Time for action – downloading and installing Panda3D 8

Switching to an advanced text editor 11

Time for action – downloading and installing Notepad++ 11

Installing the game content 13

Time for action – demoing Suicide Jockeys 13

Installing optional tools 14

Blender and Chicken 15

Spacescape 16

Explosion Texture Generator 16

Summary 17

Chapter 2: Creating the Universe: Loading Terrain 19

Notepad++ 20

Setting up a new file in Notepad++ 20

Time for action – setting up a new file in Notepad++ 20

Importing Panda3D components 21

Time for action – importing DirectStart 21

Creating a World Object 22

Time for action – creating a World Object 23

Loading the terrain 27

Time for action – loading the terrain 28

Loading files into Panda3D 30

The model path 30

Eggs 30

Bams 32

NodePaths and nodes 32

www.it-ebooks.info

Table of Contents

[ ii ]

Time for action – introducing NodePaths and nodes 33

Manipulating NodePaths 35

Time for action – manipulating NodePaths 36

The Scene Graph 37

Time for action – understanding parent child inheritance 38

Time for action – explaining relative coordinate systems 40

Loading a file multiple times 41

Render attributes 41

Time for action – demonstrating render attributes 43

Summary 46

Chapter 3: Managing Tasks Over Time 47

The task manager 48

Time for action – printing the task list from the task manager 48

Avoiding multiple task managers 49

Adding tasks to the task manager 49

Time for action – creating a task and adding it to the task manager 50

Time for action – looking at task statistics 52

Adding a delay to tasks 54

Time for action – using doMethodLater 54

Using delta time 55

Time for action – using delta time 56

Over viewing task return options 57

About the None type object 58

Time for action – exploring task return options 58

Prioritizing tasks 61

Removing tasks from the task manager 61

Time for action – removing tasks by name 62

Dissecting task objects 64

Summary 65

Chapter 4: Taking Control: Events and User Input 67

Working with events 67

Time for action – registering and responding to events 68

Using keyboard events 70

Using a key map 71

Time for action – creating and using a key map 72

Implementing advanced cycle controls 75

Time for action – implementing acceleration 75

Time for action – implementing throttle control 78

Time for action – implementing turning 80

Utilizing mouse input and creating camera control 82

www.it-ebooks.info

Table of Contents

[ iii ]

Time for action – tying the camera to the cycle 82

Reacting to mouse movement 84

Time for action – turning the camera with the mouse position 85

Ending event response 86

Summary 87

Chapter 5: Handling Large Programs with Custom Classes 89

Importing custom classes 89

Time for action – making and importing a custom class 90

Adding NodePath functionality to a custom class 93

Time for action – defining the Cycle class 93

Simulating drift 97

Time for action – simulating drift 97

Accessing classes from within another class 103

Time for action – adding an input manager 103

Summary 107

Chapter 6: The World in Action: Handling Collisions 109

Collision basics: Our first collision system 109

Time for action – creating a simple collision detection system 110

Creating inter-cycle collisions 116

Time for action – inter-cycle collisions 116

Using BitMasks to organize collisions 122

Time for action – implementing BitMasks 123

Time for action – setting a range of bits with BitMask.range 124

Using Python tags to get colliding objects 126

Time for action – setting and getting PythonTags 126

Setting up ground collision 128

Time for action – creating a ground collision system 128

Overview of additional collision solids and handlers 142

Collision solids 142

Collision handlers 144

Summary 144

Chapter 7: Making it Fancy: Lighting, Textures, Filters, and Shaders 145

Adding lighting 145

Time for action – adding lights to the game 146

Types of lights 149

Applying textures to models 150

Time for action – creating a bam writer 151

Texture stages 154

Time for action – using TextureStages 156

Creating filters 161

www.it-ebooks.info

Table of Contents

[ iv ]

Time for action – adding a bloom filter 161

Using a sky sphere 164

Time for action – adding a sky sphere 164

Summary 167

Chapter 8: GUI Goodness: All About the Graphic User Interface 169

Creating a menu system 169

About DirectGUI 170

Time for action – creating a menu system 171

Putting menus to use 187

Time for action – using menus 188

In-game HUD 195

Time for action – creating a basic HUD 196

Summary 203

Chapter 9: Animating in Panda3D 205

Actors and Animations 205

Time for action – loading Actors and Animations 206

Controlling animations 208

Animation blending 209

Time for action – blending two animations 209

Creating and using Actor subparts 211

Time for action – playing animations on subparts 213

Exposing joints 214

Time for action – animating our cycles 215

Summary 219

Chapter 10: Creating Weaponry: Using Mouse Picking and Intervals 221

Using mouse picking 221

Time for action – setting up mouse aim 222

Understanding Intervals, Sequences, and Parallels 225

Sequences and Parallels 228

Creating machine guns 229

Time for action – using Intervals in Sequences and Parallels 229

Time for action – adding collision detection to the MachineGun 235

Implementing the main cannon 238

Time for action – creating the main cannon 238

Adding weapon information to the HUD 242

Time for action – adding a new HUD section 243

Handling damage response 247

Time for action – finalizing weapons with damage response 247

Summary 251

www.it-ebooks.info

Table of Contents

[ v ]

Chapter 11: What's that Noise? Using Sound 253

Editing Config.prc 253

Time for action – selecting an audio library 254

Adding music 254

AudioSound objects 254

AudioManager objects 256

Time for action – creating background music 257

Adding sound effects 258

Time for action – generating 3D audio with Audio3DManager 258

About sound intervals 263

Summary 264

Chapter 12: Finishing Touches: Getting the Game Ready for the Customer 265

Collecting garbage 265

Time for action – collecting garbage from the Explosion classes 267

Time for action – collecting garbage from the Gun classes 269

Time for action – collecting garbage from the Cycle class 270

Time for action – collecting garbage from the Track class 272

Creating a preloader 273

Time for action – creating a preloader to load models 273

File handling 276

Time for action – reading data from a file 277

Customizing the mouse cursor 278

Time for action – customizing the mouse cursor 279

Creating an Installer 282

Time for action – packing a Panda3D game 282

Summary 285

Appendix A: Creating a Sky Sphere with Spacescape 287

Learning Spacescape basics 288

Time for action – getting started with Spacescape 289

Blending layers 292

Time for action – blending layers to create nebulas 294

Using point stars and billboard stars 297

Time for action – populating the sky with stars 297

Creating a sky sphere from a skybox made with Spacescape 302

Time for action – populating the sky with stars 302

Time for action – creating the sky sphere in Panda3D 303

Summary 305

Appendix B: Using Egg-Texture-Cards and ExploTexGen 307

Using ExploTexGen 308

Time for action – reading the ExploTexGen documentation 308

www.it-ebooks.info

Table of Contents

[ vi ]

Time for action – designing an explosion 310

Creating flipbook animations with egg-texture-cards 313

Time for action – using egg-texture-cards 313

Additional egg-texture-card options 314

Summary 315

Appendix C: Pop quiz Answers 317

Chapter 2: Creating the Universe: Loading Terrain 317

Starting Panda3D and loading models 317

Using NodePath and understanding scene graph inheritance 318

Chapter 3: Managing Tasks Over Time 318

The task manager 318

Delta time 318

Task return options 318

Chapter 4: Taking Control: Events and User Input 319

Working with events 319

Using keyboard input 319

Utilizing mouse input 319

Chapter 5: Handling Large Programs with Custom Classes 319

Importing custom classes 319

Accessing custom classes from other classes 320

Chapter 6: The World in Action: Handling Collisions 320

Regarding basic collision detection 320

Understanding handlers that generate events 320

Understanding BitMasks 321

Using Python tags 321

Complex collision detection 321

Chapter 7: Making it Fancy: Lighting, Textures, Filters, and Shaders 322

Using lights 322

Understanding textures and TextureStages 322

Setting up a sky sphere 322

Chapter 8: GUI Goodness: All About the Graphic User Interface 323

Understanding DirectGUI 323

Creating a Heads Up Display 323

Chapter 9: Animating in Panda3D 323

Animation basics 323

Advanced animation 323

Chapter 10: Creating Weaponry: Using Mouse Picking and Intervals 324

Mouse picking 324

Intervals 324

www.it-ebooks.info

Table of Contents

[ vii ]

Chapter 11: What's that Noise? Using Sound 325

Making music 325

Sounding off 325

Chapter 12: Finishing Touches: Getting the Game Ready for the Customer 325

Garbage collection 325

Using a custom mouse cursor 326

Building an installer 326

Index 327

www.it-ebooks.info

www.it-ebooks.info

Tải ngay đi em, còn do dự, trời tối mất!