
THE EXPERT’S VOICE® IN JAVA™ TECHNOLOGY IncludesIncludes Java™™ SESE 66 Platform Pro Java™ 6 3D Game Development Java 3D,™ JOGL, JInput, and JOAL APIs Learn the key techniques needed to create fun, exciting 3D games in Java™ technology, with an emphasis on 3D landscape construction Andrew Davison Pro Java™ 6 3D Game Development Java 3D™, JOGL, JInput, and JOAL APIs Andrew Davison Pro Java™ 6 3D Game Development: Java 3D™, JOGL, JInput, and JOAL APIs Copyright © 2007 by Andrew Davison All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13: 978-1-59059-817-7 ISBN-10: 1-59059-817-2 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Apress Inc. is not affiliated with Sun Microsystems, Inc. and this book was written without endorsement from Sun Microsystems, Inc. Lead Editor: Steve Anglin Technical Reviewers: Chien Yang and Shawn Kendall Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick, Jonathan Hassell, Chris Mills, Matthew Moodie, Jeffrey Pepper, Paul Sarknas, Dominic Shakeshaft, Jim Sumser, Matt Wade Project Manager: Denise Santoro Lincoln Copy Edit Manager: Nicole Flores Copy Editor: Jennifer Whipple Assistant Production Director: Kari Brooks-Copony Senior Production Editor: Laura Cheu Compositor: Gina Rexrode Proofreader: Elizabeth Berry Indexer: Becky Hornyak Artist: Andrew Davison, April Milne Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precau- tion has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Source Code/ Download section. It is also available at the author’s web site at http://fivedots.coe.psu.ac.th/~ad/jg2/. To Supatra and John Contents at a Glance About the Author . xix About the Technical Reviewers . xxi Acknowledgments . xxiii Introduction . xxv PART 1 ■ ■ ■ Java 3D ■CHAPTER 1 Introducing Java 3D. 3 ■CHAPTER 2 Get a Life (in 3D) . 15 ■CHAPTER 3 Get a Life (the Java 6 Way) . 49 ■CHAPTER 4 The Colliding Grabbers . 83 ■CHAPTER 5 When Worlds Collide . 121 ■CHAPTER 6 A Multitextured Landscape . 145 ■CHAPTER 7 Walking Around the Models. 179 ■CHAPTER 8 More Backgrounds and Overlays . 203 PART 2 ■ ■ ■ Nonstandard Input Devices ■CHAPTER 9 Webcam Snaps . 233 ■CHAPTER 10 Navigating a 3D Scene by Waving Your Arm . 251 ■CHAPTER 11 Building a Gamepad Controller with JInput . 273 ■CHAPTER 12 Gamepad Grabbers . 303 ■CHAPTER 13 3D Sound with JOAL . 327 ■CHAPTER 14 The P5 Glove . 349 PART 3 ■ ■ ■ JOGL ■CHAPTER 15 Two JOGL Programming Frameworks . 377 ■CHAPTER 16 Touring the World. 409 ■CHAPTER 17 Loading Models. 439 ■INDEX . 475 v Contents About the Author . xix About the Technical Reviewers . xxi Acknowledgments . xxiii Introduction . xxv PART 1 ■ ■ ■ Java 3D ■CHAPTER 1 Introducing Java 3D. 3 Overview of Java 3D . 3 Overview of the Scene Graph . 4 Some Java 3D Scene Graph Nodes . 5 The HelloUniverse Scene Graph . 5 Java 3D Strengths . 7 The Scene Graph . 7 Performance. 7 Unique Features. 8 Java Integration . 8 Documentation and Examples . 8 Criticisms of Java 3D for Games Programming . 9 Java 3D’s Level of Abstraction. 9 Java 3D Games . 10 Java 3D Support . 12 Alternatives to Java 3D . 13 Summary . 14 ■CHAPTER 2 Get a Life (in 3D). 15 The Game of Life . 15 Running Life3D. 16 Configuring Life3D. 16 A Life3D Screensaver . 17 An Overview of the Life3D Classes . 18 Deciding How to Start . 19 vii viii ■CONTENTS Displaying the 3D Game . 20 Integrating Java 3D and Swing . 20 Window Sizing . 21 Processing Key Presses . 21 Scene Graph Creation . 22 Lighting the Scene. 24 The Scene’s Background . 24 Building the Cells Grid and Making It Behave. 25 Viewer Positioning . 25 Viewer Movement ..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages508 Page
-
File Size-