best way to have a mesh with multiple textures

Hey all

I’m currently working on a blender file loader. https://github.com/underdoeg/ofxBlender

I can load blender meshes into an ofMesh just fine. But I am not sure yet on the best way to handle material and texture informations. Because blender stores materials per face. So a mesh can have an unlimited amount of materials which is nice, especially for textures.

That is something I’d like to port at one point. Should I just add an ofMesh for each texture/material combination. Or is there a way to draw an ofMesh partially. Like draw Faces number 12 to 20? That would make things way easier to handle.

thanks for thoughts

You could try storing the indicies, and then changing them based on what you need to draw and then restoring the originals. You would have to call a draw call after every time you wanted to draw part of the mesh.
something like

  
  
vector<ofIndexType> originalIndicies = mesh.getIndicies();  
  
vector<ofIndexType> mySweetIndicies = mesh.getIndicies();  
int myStartIndex = mySweetIndicies.size()/2;  
int myStopIndex = mySweetIndicies.size();  
  
mySweetIndicies.erase( mySweetIndicies.begin()+myStartIndex, mySweetIndicies.begin()+myStopIndex);  
mesh.clearIndices();  
mesh.addIndices( mySweetIndicies );  
  
mesh.draw();  
  
mesh.clearIndices();  
mesh.addIndices( originalIndicies );  

This should work, though I didnt test it.

Nick