# OpenGL, Blender and model optimization

I'm learning OpenGL and there is something I don't understand regarding model loading.

Lets say I found a free .blend model of a tree. The problem is - currently in my program all models have only one texture. But this model use two textures, one for trunk and another for branches and leaves. Actually trunk and leaves are two separated models on one scene.

What to do in this situation? Editing model manually could take a long time (I'm not an expert in Blender). I could join two textures in one and correct UV's automatically. But most likely a lot of space will be wasted on such an automatically created texture. I could also modify my model format (it's more like memory dump + header actually) so I could store N models with N textures as one object. But using N times more VBOs and textures when you actually need only one is inefficient.

I'm wondering maybe there is a well known tool for automatically joining multiple objects in one? Or maybe some good practice for this case? Or something like this.

You can load the trunk and branches as separate meshes with their own textures (preferably storing them in the same VBO as well, each starting at an offset, and using the offset while calling glDrawArrays ). Then after you load the meshes into memory, you can create a hierarchy of their transforms where the trunk is the parent node and the branches are the children. When you want to render the branches, you just need to multiply the local transform of the branches with their parent trunk's transform to get their final transformation matrix.