ModelInfo.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "ModelInfo.h"
  2. #include <Textur.h>
  3. #include "Globals.h"
  4. using namespace Framework;
  5. ModelInfo::ModelInfo(const char* model, const char *texture, bool transparent, int numTextures)
  6. : modelPath(model),
  7. transparent(transparent)
  8. {
  9. for (int i = 0; i < numTextures; i++)
  10. texturPaths.add(new Text(texture));
  11. }
  12. ModelInfo::ModelInfo(Framework::StreamReader* reader)
  13. {
  14. char len;
  15. reader->lese(&len, 1);
  16. char* path = new char[len + 1];
  17. reader->lese(path, len);
  18. path[len] = 0;
  19. modelPath = path;
  20. delete[] path;
  21. short count;
  22. reader->lese((char*)&count, 2);
  23. for (int i = 0; i < count; i++)
  24. {
  25. reader->lese(&len, 1);
  26. path = new char[len + 1];
  27. reader->lese(path, len);
  28. path[len] = 0;
  29. texturPaths.add(new Text(path));
  30. delete[] path;
  31. }
  32. reader->lese((char*)&transparent, 1);
  33. }
  34. Framework::Model3DData* ModelInfo::getModel() const
  35. {
  36. return uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(modelPath);
  37. }
  38. Framework::Model3DTextur* ModelInfo::getTexture() const
  39. {
  40. Model3DTextur* textur = new Model3DTextur();
  41. int index = 0;
  42. for (Text* texturPath : texturPaths)
  43. {
  44. Textur* tex
  45. = uiFactory.initParam.bildschirm->zGraphicsApi()->createOrGetTextur(
  46. texturPath->getText(), 0);
  47. textur->setPolygonTextur(index++, tex);
  48. }
  49. return textur;
  50. }
  51. Framework::Text ModelInfo::getModelName() const
  52. {
  53. return modelPath;
  54. }
  55. const Framework::RCArray<Framework::Text>* ModelInfo::getTexturNames() const
  56. {
  57. return &texturPaths;
  58. }
  59. bool ModelInfo::isTransparent() const
  60. {
  61. return transparent;
  62. }