ModelInfo.cpp 1.9 KB

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