Textures play a very important role in the visual appearance of any game. They are the images that are wrapped around the models to add color and detail to the polygons that form the model. To use textures properly, a model has to be given texture coordinates that tell Panda3D how to apply the texture to the model. It is possible to automatically generate these coordinates, but this is rarely done in practice. The best way to create these coordinates is in a modeling package, such as Blender. For our game, the models we use will already have the texture coordinates created.
We have two options for applying textures to our model. The first method we've already used, and that is to have the texture applied in the modeling package when we export an egg file, so that when the egg is loaded the texture is already there. That's what we've done with our track.
The second method is to apply the texture with code at runtime. This method is best when we want to use some of Panda3D's texturing effects, such as normal, gloss, or glow maps. Applying several textures to use all of these effects every time a model is loaded is not very practical, though. To get around this, we're going to use another feature of Panda3D that we talked about back when we were discussing eggs and bams. Panda3D can save out a bam file that contains a model and all of its texturing that we can load later on, so we don't have to reapply the textures every time we load the model. This will help us keep our Cycle
class as simple as possible, too, because we won't have to put all of the code for creating and applying the textures into that class.