Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The essentials of a cube-based world


In this recipe, we'll build a small framework to generate optimized cube meshes, which can be used to create large-scale worlds. This framework will consist of an AppState object to handle user actions, a class called CubeWorld that will store the terrain data, and a class called CubeCell that will store the data for individual cells. In addition, there is a CubeUtil class that will help us to generate meshes.

Getting ready

This is an advanced recipe that requires an understanding the generation of a basic terrain, which can be found earlier in the chapter, and the building blocks of meshes and how to create custom meshes.

Before we begin, we will create a class called CubeUtil and populate it with some shaped data that we will need later. Since each of the cells is of a box shape, we can borrow some fields from the Box and AbstractBox classes and save some time in setting it up. Just copy the GEOMETRY_INDICES_DATA, GEOMETRY_NORMALS_DATA, and GEOMETRY_TEXTURE_DATA...