Book Image

jMonkeyEngine 3.0 : Beginner's Guide

Book Image

jMonkeyEngine 3.0 : Beginner's Guide

Overview of this book

jMonkeyEngine 3.0 is a powerful set of free Java libraries that allows you to unlock your imagination, create 3D games and stunning graphics. Using jMonkeyEngine's library of time-tested methods, this book will allow you to unlock its potential and make the creation of beautiful interactive 3D environments a breeze."jMonkeyEngine 3.0 Beginner's Guide" teaches aspiring game developers how to build modern 3D games with Java. This primer on 3D programming is packed with best practices, tips and tricks and loads of example code. Progressing from elementary concepts to advanced effects, budding game developers will have their first game up and running by the end of this book.From basic concepts and project creation to building a complex 3D Game, you will learn to layout 3D scenes, make them interactive and add various multi-media effects.You will find answers to common questions including best practices and approaches, how game characters can act and interact, how to simulate solid walls and physical forces, how to take it online to play over a network and much more.From Zero to Hero, start your journey to make your game idea a reality.
Table of Contents (20 chapters)
jMonkeyEngine 3.0 Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – 3D objects in the 2D GUI?


Up to now, all assets you attached to the guiNode were two-dimensional, such as fonts and icons. What happens if you attach a 3D object, such as the blue cube geom, the blue cube, to the guiNode instead of the rootNode? Why not try and see yourself.

Modify a fresh BasicGame and add the following change:

geom.setLocalTranslation(
    settings.getWidth()/2,
    settings.getHeight()/2,
    0);                      // center the box
geom.scale(10f);             // scale the box
guiNode.attachChild(geom);

When you run the sample code, it seems the jMonkeyEngine renders the box as before. But when you move the mouse, the box does not turn along as objects attached to the rootNode would.

What just happened?

A 3D object on the GUI node is treated as a flat 2D image, which is pinned to a coordinate on the 2D screen. If that's the effect you want, go ahead and do it: many games use "orthogonal" 3D objects to display the active weapon on the bottom edge of the...