ModelInfo.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "ModelInfo.h"
  2. using namespace Framework;
  3. ModelInfo::ModelInfo(
  4. const char* modelPath, const char* texturPath, int textureCount)
  5. : modelPath(modelPath),
  6. transparent(0)
  7. {
  8. for (int i = 0; i < textureCount; i++)
  9. texturePaths.add(new Text(texturPath));
  10. }
  11. ModelInfo::ModelInfo(
  12. const char* modelPath, std::initializer_list<const char*> texturePaths)
  13. : modelPath(modelPath)
  14. {
  15. for (const char* texturPath : texturePaths)
  16. this->texturePaths.add(new Text(texturPath));
  17. }
  18. ModelInfo::ModelInfo(const ModelInfo& right)
  19. : modelPath(right.modelPath),
  20. transparent(right.transparent)
  21. {
  22. for (int i = 0; i < right.texturePaths.getEintragAnzahl(); i++)
  23. texturePaths.add(right.texturePaths.get(i));
  24. }
  25. ModelInfo& ModelInfo::operator=(const ModelInfo& right)
  26. {
  27. modelPath = right.modelPath;
  28. transparent = right.transparent;
  29. texturePaths.leeren();
  30. for (int i = 0; i < right.texturePaths.getEintragAnzahl(); i++)
  31. texturePaths.add(right.texturePaths.get(i));
  32. return *this;
  33. }
  34. void ModelInfo::writeTo(Framework::StreamWriter* zWriter) const
  35. {
  36. char len = (char)modelPath.getLength();
  37. zWriter->schreibe(&len, 1);
  38. zWriter->schreibe(modelPath.getText(), (int)len);
  39. short count = (short)texturePaths.getEintragAnzahl();
  40. zWriter->schreibe((char*)&count, 2);
  41. for (Text* t : texturePaths)
  42. {
  43. len = (char)t->getLength();
  44. zWriter->schreibe(&len, 1);
  45. zWriter->schreibe(t->getText(), (int)len);
  46. }
  47. zWriter->schreibe((char*)&transparent, 1);
  48. }
  49. ModelInfo& ModelInfo::setTransparent()
  50. {
  51. transparent = 1;
  52. return *this;
  53. }