ModelInfo.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. transparent(0)
  15. {
  16. for (const char* texturPath : texturePaths)
  17. this->texturePaths.add(new Text(texturPath));
  18. }
  19. ModelInfo::ModelInfo(const ModelInfo& right)
  20. : modelPath(right.modelPath),
  21. transparent(right.transparent)
  22. {
  23. for (int i = 0; i < right.texturePaths.getEintragAnzahl(); i++)
  24. texturePaths.add(right.texturePaths.get(i));
  25. }
  26. ModelInfo& ModelInfo::operator=(const ModelInfo& right)
  27. {
  28. modelPath = right.modelPath;
  29. transparent = right.transparent;
  30. texturePaths.leeren();
  31. for (int i = 0; i < right.texturePaths.getEintragAnzahl(); i++)
  32. texturePaths.add(right.texturePaths.get(i));
  33. return *this;
  34. }
  35. void ModelInfo::writeTo(Framework::StreamWriter* zWriter) const
  36. {
  37. char len = (char)modelPath.getLength();
  38. zWriter->schreibe(&len, 1);
  39. zWriter->schreibe(modelPath.getText(), (int)len);
  40. short count = (short)texturePaths.getEintragAnzahl();
  41. zWriter->schreibe((char*)&count, 2);
  42. for (Text* t : texturePaths)
  43. {
  44. len = (char)t->getLength();
  45. zWriter->schreibe(&len, 1);
  46. zWriter->schreibe(t->getText(), (int)len);
  47. }
  48. zWriter->schreibe((char*)&transparent, 1);
  49. }
  50. ModelInfo& ModelInfo::setTransparent()
  51. {
  52. transparent = 1;
  53. return *this;
  54. }