ModelInfo.cpp 1.8 KB

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