   [C#] Load/Save data.  Storing surface textures as integers is the best approach?
  I have a level that is made entirely of 3D tiles.  When I load a level from an .XML file I'm currently only loading the type of tile (0 = empty tile, 1 = solid).    public class Tile3D    {   public Quadrangle[] quads;   public Vector3 position;   public Tile3D_Type type;   public Tile3D()   {  quads = new Quadrangle[6];   }    }In the case of an empty tile all the quadrangles are null.  If a tile is solid then the quadranlge count can be anything up to 6 depending on the surrounding tiles.  This is because hidden tile faces are removed and the quadrangle for that face is null.I've now got the stage where I need to load/save the texture for each quadrangle and I was wondering how you guys would suggest doing this.I've thought about a texture index that obtains the texture from a texture array as the sensible method to progress with.  However, how can I make sure that textures indices are set correctly knowing that not all 6 quadrangle faces will be assigned.Should I use a separate class for containing load/save data:    public class LevelData    {   public int[] tileMap;    // Type of tile (1 = solid)   public int[] textureMap;    }How can I then associate the quads with the textureMap?Thanks.   
  Well, your Quadrangle class should contain an unique index to an texture. Then your level data should map these index to a loaded texture. In this case it doesn't matter how many quadrangles your tile contains.public class Quadrangle{...public int textureIndex;...}public class LevelData{  public int[] tileMap;    // Type of tile (1 = solid)  public Texture[] textureMap;}...// adhoc loading of texturesif(tile.containsQuad(NORTH)){  Quadrangle quad = tile.getQuad(NORTH);  int textureIndex = quad.getTextureIndex();  // get texture  LevelData levelData = LevelDate.getInstance();  Texture tex = levelData.getTextureByIndex( textureIndex);  // texture is null ?  if(tex==null)  {    // load texture    levelData.loadTextureByIndex( textureIndex);   // access again    tex = levelData.getTextureByIndex( textureIndex);    // still not present ?    if(tex==null)    {   .. some error handling ...    }  }  // render quad with given texture  ...};Quote:Well, your Quadrangle class should contain an unique index to an texture. Then your level data should map these index to a loaded texture. In this case it doesn't matter how many quadrangles your tile contains.Wouldn't that require serializing all quadrangle data to an .xml file. Isn't there a way where I can just store texture index in an array instead?   ;  If a quadrangle exists, then it will have a texture ID you can use to look up a texture.  If a quadrangle doesn't exist, then it doesn't matter.  The textures and the quadrangles should be stored separately and the ID shouldn't depend on the number of textures or quadrangles.  Adding or removing individual textures or quadrangles shouldn't invalidate any other data.   