Material Palette.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /******************************************************************************/
  2. STRUCT_PRIVATE(MaterialPalette , Memc<MaterialPtr>)
  3. //{
  4. // get
  5. Int elms ( )C {return super::elms ( );} // get number of elements
  6. C MaterialPtr& operator[](Int i)C {return super::operator[](i);} // get i-th material
  7. UInt memUsage ( )C {return super::memUsage ( );} // get memory usage
  8. Int getMaterialIndex (C MaterialPtr &material); // get index of desired 'material' in the palette, if 'material' is not listed in the palette it will be added, up to 255 materials can be stored, 0 index is always reserved for null material, -1 on fail
  9. Int getMaterialIndex0(C MaterialPtr &material); // get index of desired 'material' in the palette, if 'material' is not listed in the palette it will be added, up to 255 materials can be stored, 0 index is always reserved for null material, 0 on fail
  10. // manage
  11. void del () {super::del ();} // delete manually
  12. void clear() {super::clear();} // clear
  13. // operations
  14. void remove(Int i ); // remove i-th material , 0-th material can't be removed because it's always reserved for null material
  15. Bool clean (Bool is[256], Byte remap[256]); // remove unused materials, 'is'=array of 256 possible values (true if used, false otherwise), 'remap'=material index remap obtained after function return to be used in followig way: "remap[src]=dest"
  16. // io
  17. Bool save(File &f, CChar *path=null)C; // save to 'f' file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  18. Bool load(File &f, CChar *path=null) ; // load from 'f' file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  19. #if EE_PRIVATE
  20. Bool loadOld(File &f, CChar *path=null);
  21. #endif
  22. private:
  23. Int _last;
  24. };
  25. /******************************************************************************/
  26. STRUCT_PRIVATE(IDPalette , Memc<UID>)
  27. //{
  28. // get
  29. Int elms ( )C {return super::elms ( );} // get number of elements
  30. C UID& operator[](Int i)C {return super::operator[](i);} // get i-th ID
  31. UInt memUsage ( )C {return super::memUsage ( );} // get memory usage
  32. Int getIDIndex (C UID &id); // get index of desired 'id' in the palette, if 'id' is not listed in the palette it will be added, up to 255 ids can be stored, 0 index is always reserved for 'UIDZero' id, -1 on fail
  33. Int getIDIndex0(C UID &id); // get index of desired 'id' in the palette, if 'id' is not listed in the palette it will be added, up to 255 ids can be stored, 0 index is always reserved for 'UIDZero' id, 0 on fail
  34. // manage
  35. void del () {super::del ();} // delete manually
  36. void clear() {super::clear();} // clear
  37. // io
  38. Bool save(File &f)C; // save to 'f' file, false on fail
  39. Bool load(File &f) ; // load from 'f' file, false on fail
  40. private:
  41. Int _last;
  42. };
  43. /******************************************************************************/
  44. inline Int Elms(C MaterialPalette &mp) {return mp.elms();}
  45. inline Int Elms(C IDPalette &ip) {return ip.elms();}
  46. /******************************************************************************/