views:

84

answers:

1

I am trying to map the textures of a tree(That is in .3ds format) in OpenGL and C++.I am using vertex buffer objects, vertex array objects and shaders.The vertex coordinates, normals and texture coordinates are uploaded to shader via glVertexAttribPointer.My question is how can I select different textures for different parts of the model(i.e. bark and laeves)?

A: 

Two solutions:

1) Render a hierarchy of objects, and each objects is rendered using the appropriate texture.

2) Draw the appropriate textures is a single texture. Each mesh triangle texture coordinates map the correct protion of the image.

The first solution is simpler (apart the hierarchy handling). The second one requires a complex texture mapping of the loaded object, but allow the use of a single texture (minimize memory). The characters of a game often uses a single texture, which has the texture of face, hands and wearing.

Luca