US Customers - Please use Barnes and Noble for a fast turnaround for print copies of this book
Are you interested in developing cutting-edge 3D games? Do you want to master jMonkey 3.0’s fully-featured graphics and game technologies? If so, then this book is for you!
jMonkeyEngine 3.0 is a high level Open Source game development environment that supports advanced 3D graphics, techniques, and hardware. Built on Java, it is integrated with OpenGL and its SDK is built on Netbeans. The jMonkey platform allows developers to build sophisticated high-end 3D graphics and game environments to create games with the feel and appearance that top developers demand.
jMonkeyEngine 3.0 Game Development: A Practical Guide covers the basics of game development with just the right amount of theory and background information to make you a proficient game developer. Chapters cover real-world content on User Interactions, Animations, SFX, Multiplayer games, and much more. By the end of this book, you will have in-depth knowledge of creating professional quality games with Java and JME3.
> Learn how to develop 3D games using Java and JME3
> Discover how to create and manipulate scene graphs
> Learn how to use lighting and materials to create gripping graphics
> Create first-class landscapes and models
> Explore JME’s physics engine to develop realistic worlds
> Learn how to support multiple players and embed AI techniques
> Develop a space-based game that illustrates the techniques presented across the book
> Masses of Code. Download it for Free.
This book is for developers who are familiar with Java and interested in learning how to develop games and graphic applications using JME3. Readers who are interested in understanding both the mechanics of 3D graphics and game design will find this a useful and rewarding book.
Richard Reese has written several Java and C books and brings a concise and easy to follow approach to topics at hand. He currently teaches at Tarleton State University where he is able to apply years of industry experience to enhance his classes. Richard is the author of P8’s book: Java 8 New Features: A Practical Heads-Up Guide
Justin Johnson enjoys playing and developing computer games. He finds writing about JME3 to be a very rewarding experience. He has developed across different game engines, and feels that JME3 is the most versatile and customizable open source game engine about.
Prefer a PDF?
Table of Contents
Chapter 1 – Introduction to JME3 1
Introduction 1
Why JME3? 1
Installing JME3 2
The JME3 Development Environment 2
Structure of a JME3 Application 4
The BasicGame Project 4
Application Lifecycle 8
Understanding the Scene Graph 9
The Coordinate System 10
Understanding the BasicGame’s Code 11
Adding a Library 14
Using the HUD 15
Performance and FPS 16
Controlling the Default Display Settings 16
Adding Text to the HUD 16
Adding a Picture to the HUD 19
Shades of Infinity Initial HUD 20
Creating a Simple Background Sound 23
Using the Camera 25
Application and Display Settings 27
Controlling the Application Settings 27
Controlling the Display Settings 28
Controlling an Application’s Title 28
Controlling an Application’s Resolution 29
Controlling Full Screen 29
Controlling Icons 29
Input Devices Settings 30
Audio Settings 31
Saving and Loading an Application’s Settings 31
Using a File to Save/Load Settings 33
Conclusion 33
Chapter 2 – Objects in Space 35
Creating and Managing a Scene Graph 36
Spatials, Nodes, and Geometries 37
Understanding Nodes 37
Understanding Geometries 37
Using Materials 40
Maintaining a Scene Graph 41
Adding Objects 41
Removing Objects 44
Swapping Objects 44
Locating Objects in a Scene Graph 44
Scene Graph Traversal 45
Using Transformations 49
Changing the Position of an Object 49
Changing the Size of an Object 50
Changing an Object’s Orientation 52
Working with Meshes 56
Displaying a Wireframe 57
Using Shapes 58
Using the Box Shape 59
Using the Cylinder Shape 60
Using the Sphere Shape 61
Using Non-3D Shapes 63
Rendering a Quad 63
Rendering a Line 64
Creating a Custom Mesh 65
Creating a new Mesh object 65
Creating a Vertices Array 66
Creating the Texture Array 66
Defining the Triangle Array 67
Storing the Mesh Data 67
Creating Complex Shapes 69
Using 3D Models 70
Adding a .blend Model to Your Project 70
Using Different Levels of Detail 72
Understanding Vertex Buffers 72
Building a Space Station 73
Conclusion 76
Chapter 3 – User Interaction 77
Introduction 77
Handling Player Input 78
Action Versus Analog Listeners 79
Understanding the Sphere Application 80
Using the simpleRender Method 80
Using Triggers 80
Understanding Default Trigger Mappings 81
Handling Keyboard Input 83
Defining a Key Trigger 83
Assigning a Trigger to a Mapping Name 84
Associating a Mapping Name with a Listener 85
Adding Multiple Mappings to a Listener 85
Processing an Event with a Listener 86
Using Different Keyboards 87
Handling Mouse Input 88
Using Mouse Buttons 88
Using the Mouse Wheel 90
Using a Joystick 92
Using a Gamepad Controller 94
Adding Picking 96
Implementing Ray Casting 97
Implementing Collision Detection 97
Implementing Picking 98
Adding Situational Sound 102
Improving our Shades of Infinity Game 103
Conclusion 105
Chapter 4 – Game Logic 107
Introduction 107
Understanding Application States 108
Creating an AppState Object 108
Using an AppState 111
The SimpleApplication Class’ AppStates 112
Understanding the FlyCamAppState 113
Creating Custom Input Settings Using an Application State 114
Understanding Custom Controls 115
Creating a Custom Control 116
Overriding the Base Class Methods 116
Using a Custom Control 117
Improving our Shades of Infinity Game 118
Modifying the Main Class 119
The simpleInitApp Method 119
The simpleUpdate Method 120
Creating the CombatAppState Class 121
The initialize Method 121
The setEnabled Method 122
The onAction Method 122
The addCollision Method 122
Creating the AISpaceShip Class 123
Conclusion 125
Chapter 5 – Materials 127
Introduction 127
Understanding Materials 127
Demystifying Material Terms and Concepts 128
Common Graphics Terms 128
Texture Mapping Terms 129
Using Unshaded Materials 132
Using the Color Property 133
Using the ColorMap Property 134
Using the LightMap Technique 134
Editing Textures 135
Using Lighted Materials 136
Using Simple Lights 136
Using Diffuse Light 137
Using Ambient Light 138
Making an Object Shiny 140
Using a DiffuseMap 141
Using a NormalMap 142
Making an Object Transparent 143
Creating Materials 146
Using a Text Editor to Create a Material 147
Using the Material Editor 148
Managing Assets 149
Models 151
Working With Blender Models 151
Loading Models 153
Shades of Infinity – 5 154
Handling Collisions 157
Conclusion 158
Chapter 6 – Lights, Camera, Action! 159
Introduction 159
Using Lighting Effects 160
The Basics of Lights 160
Creating a Spot Light 161
Creating a Point of Light 164
Adding Shadows to a Game 165
Understanding Shadow Modes 166
Using the Shadow Renderer 166
Using the Shadow Filter 169
Understanding the Projection Matrix 171
The Camera and FlyByCamera Classes 171
Using the flyCam Variable 172
Using Positional Sounds 173
Handling Multiple Cameras 174
Using Viewports 174
Setting up Multiple Viewports 176
Setting Up a Picture in a Picture 179
Capturing Screenshots 180
Capturing Video 181
Shades of Infinity Enhancements 181
Adding Shadows 182
Creating a Picture in a Picture 184
Capturing Screenshots and Videos 184
Conclusion 185
Chapter 7 – Animation 187
Introduction 187
Animation Basics 187
Animating with the simpleUpdate Method 188
Using tpf to Control the Speed of an Animation 188
Using the speed Variable 189
Understanding Model Animation 190
Animation Terms 190
Understanding Model Files 191
Loading Animations 192
Using Animation Controls 192
Using Animation Channels 194
Playing Animations 195
Triggering Animations 195
Switching Between Animations 196
Motion Paths and Way Points 198
Configuring the Motion Event 200
Capturing Motion Path Events 202
Understanding Cinematics 203
Using a Motion Event 204
Using a Sound Event 205
Using a Listener with a Cinematic 206
Using an Animation Event 206
Shades of Infinity – 7 208
Ship Modifications 208
Adding the MotionEvent 209
Adding Cinematics 210
Conclusion 211
Chapter 8 – Creating Landscapes 213
Introduction 213
Understanding and Creating Terrains 213
Creating Code-Based Terrain 214
Defining the Material 215
Defining the Heightmap 215
Defining an Alpha Texture 217
Defining the Terrain Textures 218
Defining the TerrainQuad 219
Creating a Terrain with the Scene Composer 221
Creating an Empty Scene 222
Using the Scene Composer 223
Using the Terrain Editor 227
Using the Terrain Editor Heightmap Tools 228
Painting Textures 230
Adding a Light Source 234
Loading New Terrain 236
Understanding and Creating a Sky 236
Loading a Sky 236
Building a Sky Box with Individual Images 238
Loading a Dome Sky 240
Creating a Sky Texture 241
Using Water and Reflection 242
Using the SimpleWaterProcess Class 242
Creating and Configuring the SimpleWaterProcess class 242
Creating and Configuring the Quad class 244
Creating the Water’s Geometry 244
Using the SeaMonkey WaterFilter 245
Conclusion 247
Chapter 9 – Physics 249
Introduction 249
Handling Collisions 249
Adding a Physics Space 250
Adding Physics to Objects 250
Adding Physics to the Player 251
Using the CharacterControl and CapsuleCollisionShape Classes 252
Using BetterCharacterControl 255
Collisions in Action 258
Gravity 261
Observing Gravity 262
Physics Listeners 264
Using the Tick Listener 265
Using the PhysicsCollisionListener Interface 265
Using Collision Groups 271
Adding Physics to Shades of Infinity 272
Applying the Physics Space 272
Applying Physics to the Player’s Ship 272
Applying Physics to the AI Ships 273
Demonstrating AI Ships in Collision 274
Creating an Orbiting Moon 275
Conclusion 278
Chapter 10 – Special Effects 279
Introduction 279
Understanding Filters 279
Understanding the FilterPostProcessor 280
Understanding Environmental Effects Filters 280
Using the DepthOfFieldFilter Class 280
Using the FogFilter Class 282
Understanding Shadow Filters 283
Using the SSAOFilter Class 283
Adding the ShaderBlow Library 285
Understanding Special Effects Filters 286
Using the CartoonEdgeFilter Class 287
Using the ColorScaleFilter Class 289
Using the GrayScaleFilter Class 289
Using the OldFilmEffectFilter Class 290
Understanding Particle emitters 291
Creating a Particle Emitter 292
Configuring a Particle Emitter 293
Using a Material with a Particle Emitter 294
Attaching and Positioning a Particle Emitter 295
Controlling the Lifecycle of a Particle Emitter 296
Using Fade In and Fade Out 297
Setting Up the Fade Variables 298
Setting Up the FilterPostProcessor and FadeFilter Instances 298
Configuring the Fade Duration 299
Executing Fade Out 299
Executing Fade In 299
Understanding Bloom and Glow 300
Using a Glow Color 301
Using a Glow Map 303
Stopping a Glow 304
Shades of Infinity Enhancements 304
Conclusion 307
Chapter 11 – Multiple Players and Networking 309
Introduction 309
Understanding the Basics of the SpiderMonkey API 311
Creating a Server 311
Creating a Client 313
Creating a New Message Type 315
Using Messages 315
Creating a Client Listener 316
Implementing the MessageListener Interface 316
Sending Messages 317
Creating a Simple Client/Server Application 317
Creating the ProjectileMessage Class 318
Building the Server 319
Listening for Messages 323
Building the Client 324
Using the ConnectionListener interface 328
Using the ErrorListener interface 329
Networking with Shades of Infinity 329
Understanding the SOIMessage Class 330
Creating the SOI Server 331
Creating the SOI Client 333
Adding New Ships 334
Destroying Ships 335
Conclusion 337
Epilogue 339
Introduction 339
Exploring Other JME3 Topics 339
Enhancing the GUI 339
Understanding 3D Math 340
Managing Character Movement 340
Incorporating Multithreading 340
Incorporating Artificial Intelligence 340
Other Topics 341
Improving the Shades of Infinity Game 341
Build Your Own Game 342
Authors: Richard Reese and Justin Johnson
Richard is also the author of Java 8 New Features: A Practical Heads-Up Guide
368 color pages | Published March 29, 2015 | 978-0992910587 | $44.99 | ebook $20 | code download
Book Categories: Java.