[ This chapter does not appear in the book. ]
A model can only be loaded into JOGL-ES once it's been translated into its component coordinates arrays (for the shape's vertices, normal, colors, and texture coordinates), and other variables for the materials and/or texture images. Generating these manually is impossible for any reasonably complicated shape.
This chapter describes how to convert a Wavefront OBJ model into a JOGL-ES class which can load, position, scale, and render the model. This allows fairly complex models, involving textures and materials, to be utilized in JOGL-ES applications. The conversion process is illustrated in the diagram below.
The OBJ model is loaded and displayed by a Java 3D application called ObjView. More importantly, ObjView generates a text file (examObj.txt) of JOGL-ES arrays and variables which represent the shape. These data structures must be manually pasted into a JOGL-ES class called OBJShape, which can render the shape defined by the arrays and variables.
ObjView is used solely to generate the arrays and other data. It plays no part in the JOGL-ES application, which only uses OBJShape to render the shape.
The model rendering performed by OBJShape is shown in the screenshot at the top of this page, as utilized in the ViewerES JOGL-ES application.
The version of ViewerES in the screenshot employs two versions of OBJShape, renamed as PenguinModel and HandModel. PenguinModel contains arrays and variables representing a penguin, while HandModel holds the data for the hand model.
The 3D scene in the ViewerES application consists of a textured floor (first seen in the previous chapter), and one or more OBJ models. The camera can be moved around the scene via keyboard controls, utilizing the same technology as in the last chapter (i.e. the KeyCamera and Camera classes).
By default when OBJShape loads a model into a scene, it's centered at the origin and its longest dimension is 1 unit. However, it's possible to adjust the shape's position and size, as shown in the screenshot.
The manual pasting of the JOGL-ES arrays and variables into OBJShape is a bit low-tech, but it's a only single copy-and-paste. It's also good practice to rename the resulting class (e.g. I renamed the copy of OBJShape containing penguin data to PenguinModel).