Chapter 3

Dealing with Complex Geometry

WHAT’S IN THIS CHAPTER?

  • Loading complex geometry from disk using the Wavefront file format
  • Building VBOs and VAOs using custom geometry data
  • Handling touch screen events
  • Loading a PNG file from disk and converting it to a usable texture
  • Implementing per-vertex lighting calculations

In games, as in graphic programming, it is important to be able to load external mesh data. Hard-coding geometry information inside your apps would just not be practical. From a simple crate to an entire level, every asset used in games has been exported from 2D or 3D software and loaded at initialization.

In this chapter, you will learn how to handle the Wavefront OBJ format using the loader that comes with this book’s SDK. In addition to model loading, you will learn how to read the Wavefront material files. You’ll also discover how to use the pre-made functions of the book’s SDK to load a PNG texture from disk. You will also learn how to handle and work with complex geometry using vertex buffer objects (VBOs) and vertex array objects (VAOs).

By the end of this chapter, you will have built from scratch a 3D viewer, able to load a custom OBJ file along with its associated texture. In addition, your viewer will also be able to support dynamic lighting, and will respond to the user touch to rotate the 3D model in real time.

THE WAVEFRONT FILE FORMAT

Over the years, the Wavefront file format has almost become a standard for exchanging geometry data between different ...

Get Game and Graphics Programming for iOS and Android® with OpenGL® ES 2.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.