RUTextureAttachmentLoader.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // RUTextureAttachmentLoader.hpp
  3. // red_utils
  4. //
  5. // Created by RedInfinity on 2024/1/16.
  6. //
  7. #ifndef RUTextureAttachmentLoader_hpp
  8. #define RUTextureAttachmentLoader_hpp
  9. ///第三方库
  10. #include "editor-support/spine/AttachmentLoader.h"
  11. #include "editor-support/spine/RegionAttachment.h"
  12. #include "editor-support/spine/MeshAttachment.h"
  13. #include "editor-support/spine/BoundingBoxAttachment.h"
  14. #include "editor-support/spine/PathAttachment.h"
  15. #include "editor-support/spine/PointAttachment.h"
  16. #include "editor-support/spine/ClippingAttachment.h"
  17. #include "editor-support/spine/Skin.h"
  18. #include "editor-support/spine/Attachment.h"
  19. #include "editor-support/spine/SpineString.h"
  20. ///项目代码
  21. #include "RUDefine.h"
  22. NS_RU_BEGIN
  23. /**
  24. * 描述:使用非图集纹理的spine附件加载器
  25. */
  26. class TextureAttachmentLoader final : public spine::AttachmentLoader {
  27. public:
  28. /**
  29. * 功能:获取非图集纹理的spine附件加载器
  30. * 返回值:非图集纹理的spine附件加载器实例对象
  31. */
  32. static TextureAttachmentLoader* getInstance();
  33. /**
  34. * 功能:销毁非图集纹理的spine附件加载器
  35. */
  36. static void destoryInstance();
  37. /**
  38. * 功能:重新绑定spine附件使用的纹理
  39. * 参数 attachment:需要重新绑定纹理的spine附件对象
  40. * 参数 imageName:单图的文件名称
  41. */
  42. void rebindAttachmentTexture(spine::Attachment* attachment, const spine::String& imageName);
  43. virtual spine::RegionAttachment* newRegionAttachment(spine::Skin& skin, const spine::String& name, const spine::String& path) override;
  44. virtual spine::MeshAttachment* newMeshAttachment(spine::Skin& skin, const spine::String& name, const spine::String& path) override;
  45. virtual spine::BoundingBoxAttachment* newBoundingBoxAttachment(spine::Skin& skin, const spine::String& name) override;
  46. virtual spine::PathAttachment* newPathAttachment(spine::Skin& skin, const spine::String& name) override;
  47. virtual spine::PointAttachment* newPointAttachment(spine::Skin& skin, const spine::String& name) override;
  48. virtual spine::ClippingAttachment* newClippingAttachment(spine::Skin& skin, const spine::String& name) override;
  49. virtual void configureAttachment(spine::Attachment* attachment) override;
  50. private:
  51. TextureAttachmentLoader() = default;
  52. ~TextureAttachmentLoader() = default;
  53. /**
  54. * 功能:重新绑定spine区域附件使用的纹理
  55. * 参数 attachment:需要重新绑定纹理的spine区域附件对象
  56. * 参数 imageName:单图的文件名称
  57. */
  58. void _rebindRegionAttachmentTexture(spine::RegionAttachment* attachment, const spine::String& imageName);
  59. /**
  60. * 功能:重新绑定spine网格附件使用的纹理
  61. * 参数 attachment:需要重新绑定纹理的spine网格附件对象
  62. * 参数 imageName:单图的文件名称
  63. */
  64. void _rebindMeshAttachmentTexture(spine::MeshAttachment* attachment, const spine::String& imageName);
  65. /**
  66. * 功能:配置区域附件
  67. * 参数 attachment:区域附件对象
  68. */
  69. void _configureRegionAttachment(spine::RegionAttachment* attachment);
  70. /**
  71. * 功能:配置网格附件
  72. * 参数 attachment:网格附件对象
  73. */
  74. void _configureMeshAttachment(spine::MeshAttachment* attachment);
  75. private:
  76. ///非图集纹理的spine附件加载器实例
  77. static TextureAttachmentLoader* _instance;
  78. };
  79. NS_RU_END
  80. #endif /* RUTextureAttachmentLoader_hpp */