this print for content only—size & color not accurate 7" x 9-1/4" / CASEBOUND / MALLOY (1.0625 INCH BULK 528 pages 50# Thor) The eXPeRT’s VOIce ® In JaVa ™ TechnOlOgy Andrew Davison 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 eMPOWeRIng PRODUcTIVITy FOR The JaVa ™ DeVelOPeR Pro Java ™ 6 3D Game Development: Java 3D, ™ JOGL, JInput, and JOAL APIs Dear Reader, Throw away your keyboard and mouse, and explore strange new lands filled with mysterious objects (cows frozen in blocks of ice, chirping penguins, gold- en globes with wavering eyes), armed with a gamepad, a power glove, or just your bare hands. In this book, I show you how to develop and program 3D games in Java™ technology on a PC, with an emphasis on the construction of 3D landscapes. I assume you have a reasonable knowledge of Java, the sort of things picked up in a first Java course at school. Different from other Java games programming books, here you’ll find the focus is on the latest 3D APIs, covering a range of libraries that you can’t find described in one place anywhere else. I’ve split the topics into three sections: Java 3D ™ API, nonstandard input devices for game playing, and JOGL. Java 3D is a high-level 3D graphics API, and JOGL is a lower-level Java wrapper around the popular OpenGL graphics API. I look at three nonstandard input devices: the webcam, the gamepad, and the P5 data glove. Along the way, I utilize several other games-related libraries, including JInput, JOAL, JMF, and Odejava. I describe the latest Java SE 6 features relevant to gaming, including splash screens, JavaScript ™ scripting, and the desktop and system tray interfaces. Read, enjoy, and create—new techniques and endless possibilities await, using Java 6 for your 3D games programming. Regards, Andrew Davison THE APRESS JAVA™ ROADMAP Beginning Java™ SE 6 Beginning Java™ Objects, Second Edition Java™ 6 Platform Revealed Pro Java™ 6 3D Game Development Pro Java ™ 6 3D Game Development: Java 3D, ™ JOGL, JInput, and JOAL APIs Davison cyan MagenTa yellOW BlacK PanTOne 123 c The unconventionally handsome author of Killer Game Programming in Java ISBN-13: 978-1-59059-817-7 ISBN-10: 1-59059-817-2 9 781590 598177 5 9 0 0 0 Shelve in Java/Games Programming User level: Intermediate–Advanced www.apress.com java.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version Companion eBook Available Includes Java ™ SE 6 Platform Includes Java ™ SE 6 Platform http://fivedots.coe.psu.ac.th/~ad/jg2/ Andrew Davison Pro Java ™ 6 3D Game Development Java 3D ™ , JOGL, JInput, and JOAL APIs 817-2FM.qxd 3/27/07 3:40 PM Page i 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 orders-ny@springer-sbm.com, 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 info@apress.com, 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 indir ectly b y the infor mation 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/. 817-2FM.qxd 3/27/07 3:40 PM Page ii To Supatra and John 817-2FM.qxd 3/27/07 3:40 PM Page iii 817-2FM.qxd 3/27/07 3:40 PM Page iv 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 JO AL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 ■CHAPTER 14 The P5 Glove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 PART 3 ■ ■ ■ JOGL ■CHAPTER 15 T w o JOGL Prog ramming Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 ■CHAPTER 16 Touring the World. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 ■CHAPTER 17 Loading Models. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439 ■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 v 817-2FM.qxd 3/27/07 3:40 PM Page v 817-2FM.qxd 3/27/07 3:40 PM Page vi 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 817-2FM.qxd 3/27/07 3:40 PM Page vii 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Behaviors in Java 3D. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 A Time-Based Behavior. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Managing the Grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Accessing Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Creating the Grid Scene Graph. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Updating the Cells States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Will the Cell Live or Die? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Rotating the Grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 The Cell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Building the Cell’s Scene Graph. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Coloring the Cells. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Setting the Cell’s Visibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Changing a Cell’s Life State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Visual Changes to a Cell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Time for Screensavers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Changing Life3D into a Screensaver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Problems with Screensavers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 The SaverBeans SDK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 More Life Required? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 ■CHAPTER 3 Get a Life (the Java 6 Way) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Life3D Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 An Overview of the Life3D Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Making a Splash. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Anima ting a Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Drawing onto a Splash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Dra wing the Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 JAR Packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Adding ClockAnimation to Life3D. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 ■CONTENTSviii 817-2FM.qxd 3/27/07 3:40 PM Page viii The Desktop API. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Using the Desktop Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 What Other Browser Capabilities Are There? . . . . . . . . . . . . . . . . . . . . . . . . 57 The System Tray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Creating Life3D’s Popup Menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 The Menu Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Creating the TrayIcon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Building the Popup Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Listening for Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Using a Text Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Launching an E-mail Client. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Listening for the Check Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Scripting in Java SE 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Executing a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Communicating with a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Speeding Things Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Calling Script Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Letting a Script Use Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 More Scripting Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Scripting in Life3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Initializing the Grid. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Changing the Grid’s State. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Executing the Script Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 The Rules Script. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 ■CHAPTER 4 The Colliding Grabbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Building Articulated Arms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Class Diagrams for Arms3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Creating the Application Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Drawing the 3D Scene. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Processing the Keys. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Monitoring Grabber Joints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Managing the Grabbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Adding the Grabbers to the Scene Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Processing Keyboard Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Translating the Grabbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Rota ting a Grabber Joint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Collecting the Collision Joints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Collision Detection and Recovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Why Bother with JointsBeha vior? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Touching the Floor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 ■CONTENTS ix 817-2FM.qxd 3/27/07 3:40 PM Page ix [...]... code example for a Java 3D programmer is HelloUniverse (it appears in Chapter 1 of Sun’s Java 3D tutorial at http:/ /java. sun.com/developer/onlineTraining /java3 d and in the Java 3D examples collection at https:/ /java3 d.dev .java. net/) The HelloUniverse program displays a rotating colored cube, as shown in Figure 1-3 5 817-2CH01.qxd 6 3/ 26/ 07 2:12 PM Page 6 CHAPTER 1 s INTRODUCING JAVA 3D Figure 1-3 A rotating... main aims of Java 3D 1 .6 (due out by the summer of 2008) is to use the JOGL binding to combine OpenGL and Java 3D rendering more closely The principal Java 3D web site is https:/ /java3 d.dev .java. net/, where Java 3D can be downloaded as a binary installation for various platforms; for example, I retrieved the final release version 1.5 for Windows Java 3D should be installed after Java SE, with Java SE 5... C, C++), and increased programmer productivity That list adds up to my personal reason for programming in Java it’s fun, especially when you’re programming something inherently good for you, such as games Most Java bashers, skipping over the advantages, have the following criticisms: • Java is too slow for games programming • Java has memory leaks • Java is too high-level • Java application installation... from the same site 3 817-2CH01.qxd 4 3/ 26/ 07 2:12 PM Page 4 CHAPTER 1 s INTRODUCING JAVA 3D The Java 3D roadmap site (http://wiki .java. net/bin/view/Javadesktop /Java3 DRoadmap) details plans for versions 1.5.1, 1 .6, and beyond For instance, 1.5.1 will mainly add support for Microsoft Vista Overview of the Scene Graph Java 3D uses a scene graph to organize and manage a 3D application The underlying graphics... many more PC games, particularly in the area of multiplayer online games 817-2CH01.qxd 3/ 26/ 07 2:12 PM PART Page 1 1 Java 3D 817-2CH01.qxd 3/ 26/ 07 2:12 PM Page 2 817-2CH01.qxd 3/ 26/ 07 2:12 PM CHAPTER Page 3 1 Introducing Java 3D T he Java 3D API, a scene graph API developed by Sun Microsystems, provides a collection of highlevel constructs for creating, rendering, and manipulating a 3D scene graph... for my earlier book, Killer Game Programming in Java KGPJ is about 2D, 3D, and network games programming, but this book concentrates solely on 3D programming KGPJ has sixteen chapters on Java 3D, while this book has eight (roughly half the book), and also covers nonstandard input devices and JOGL Of those eight chapters, four are on topics not covered in KGPJ, namely Java SE 6 integration, physics modeling,... the United States alone There are numerous Java gaming sites, including a showcase at Sun Microsystems at http:// www .java. com/en/games/, community pages at http://community .java. net/games/, a collection of open source gaming tools at https://games.dev .java. net/, the Java Games Factory at http:// javagamesfactory.org/, and many very helpful forums at http://www.javagaming.org/ xxvii 817-2FM.qxd xxviii... This Book About? This book is divided into three main sections: Java 3D, nonstandard input devices for game playing, and JOGL Java 3D is a high-level 3D graphics API based around the construction of a scene graph data structure that contains the objects that appear in the 3D scene Java 3D topics covered here include how to build your own 3D models, load existing models, create detailed landscapes, display... (first-person shooter) Instead I describe game elements, building blocks that can be used in a lot of different 3D games This book isn’t about building a 3D rendering engine; I’m using Java 3D and JOGL for that If you’re interested in creating an engine from the ground up, I recommend Developing Games in Java by David Brackeen, Bret Barker, and Laurence Vanhelswue (New Riders Games, 2003) As I explain JOGL,... cutting-edge Java and Java 3D based game technology demos for Full Sail Real World Education and Sun Microsystems, displayed at various conferences such as GDC and SIGGRAPH since 1999 In 2002, Shawn founded Immediate Mode Interactive (http://www.imilabs.com), a game technology company dedicated to the use of Java in games Shawn has been developing in Java since 1995, starting with JDK 1.0 on SGI machines and Java . Davison THE APRESS JAVA ROADMAP Beginning Java SE 6 Beginning Java Objects, Second Edition Java 6 Platform Revealed Pro Java 6 3D Game Development Pro Java ™ 6 3D Game Development: Java 3D, ™ JOGL,. exciting 3D games in Java ™ technology, with an emphasis on 3D landscape construction eMPOWeRIng PRODUcTIVITy FOR The JaVa ™ DeVelOPeR Pro Java ™ 6 3D Game Development: Java 3D, ™ JOGL,. eBook Available Includes Java ™ SE 6 Platform Includes Java ™ SE 6 Platform http://fivedots.coe.psu.ac.th/~ad/jg2/ Andrew Davison Pro Java ™ 6 3D Game Development Java 3D ™ , JOGL, JInput, and