@TextureDownsize.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /******************************************************************************/
  2. /******************************************************************************/
  3. class TextureDownsize : Viewport4Region
  4. {
  5. enum MODE
  6. {
  7. MATERIAL,
  8. OBJECT ,
  9. MODE_NUM,
  10. };
  11. static cchar8 *ModeName[]
  12. ;
  13. class Settings
  14. {
  15. int global,
  16. base_0,
  17. base_1;
  18. int base0()C;
  19. int base1()C;
  20. public:
  21. Settings();
  22. };
  23. class DownsizedMtrl : Material
  24. {
  25. MaterialPtr original;
  26. static bool Create(DownsizedMtrl &mtrl, C UID &original_id, ptr user);
  27. void create( C UID &original_id );
  28. void setTextures();
  29. void update();
  30. };
  31. Menu menu;
  32. Tabs mode;
  33. GuiImage mtrl_image;
  34. Region region;
  35. Button light_dir, downsize[3][2], revert, apply, prev, next;
  36. Text info[3][2];
  37. Memx<Property> props;
  38. TextBlack prop_ts, left_ts, right_ts;
  39. Map<UID, Settings> settings; // key=Material ID, doesn't need to be thread-safe
  40. Elm *elm; // can be OBJ or MTRL
  41. UID mtrl_id,
  42. obj_id;
  43. Memc<UID> secondary;
  44. int secondary_i;
  45. UID normal_base[2];
  46. MaterialPtr normal_mtrl;
  47. MeshPtr normal_mesh;
  48. Image downsized_base[2];
  49. Map<UID, DownsizedMtrl> downsized_mtrls; // key=Material ID, doesn't need to be thread-safe
  50. MeshLod downsized_mesh;
  51. bool draw_as_obj, different;
  52. Vec2 light_angle;
  53. Vec previewLight()C;
  54. static int MaterialUses(C MeshLod &lod, C MaterialPtr &mtrl, int variation); // how many 'lod' parts use 'mtrl' in 'variation'
  55. static int VariationWithMostMaterialUses(C Mesh &mesh, C MaterialPtr &mtrl);
  56. static void Render();
  57. void render();
  58. static void Draw(Viewport &viewport);
  59. void draw(Edit::Viewport4::View&view);
  60. static void ModeChanged(TextureDownsize &editor);
  61. static void LightMode (TextureDownsize &editor);
  62. static void Mode0(TextureDownsize &td);
  63. static void Mode1(TextureDownsize &td);
  64. static Str Global(C TextureDownsize &td );
  65. static void Global( TextureDownsize &td, C Str &text);
  66. static Str Base0(C TextureDownsize &td );
  67. static void Base0( TextureDownsize &td, C Str &text);
  68. static Str Base1(C TextureDownsize &td );
  69. static void Base1( TextureDownsize &td, C Str &text);
  70. static void Prev(TextureDownsize &editor);
  71. static void Next(TextureDownsize &editor);
  72. static void PrevS(TextureDownsize &editor);
  73. static void NextS(TextureDownsize &editor);
  74. void nextSecondary(int dir);
  75. bool nextSecondary(int dir, C UID (&old_base)[2]);
  76. bool Next(int dir=1); // find next compatible element
  77. static cchar8 *DialogID;
  78. void closeConfirm();
  79. static bool AdjustTexSrc(Str &src, TimeStamp &src_time, C Str &original, C Str &downsized, C TimeStamp &time);
  80. static VecI2 ImageSize(C ImagePtr &image, int down);
  81. static void ApplyConfirm(TextureDownsize &editor);
  82. void applyConfirm(bool revert=false);
  83. static void Revert(TextureDownsize &editor);
  84. static void Apply(TextureDownsize &editor);
  85. void applyDo();
  86. static void Dec(Property &prop);
  87. static void Inc(Property &prop);
  88. Settings* curSettings();
  89. C Settings* curSettings()C;
  90. C Rect& rect( );
  91. virtual TextureDownsize& rect(C Rect &rect)override;
  92. int getPart(GuiObj *go, C Vec2 &screen_pos, Vec *hit_pos=null);
  93. bool selectionZoom(flt &dist);
  94. virtual void camCenter(bool zoom)override;
  95. bool selected ()C;
  96. void selectedChanged();
  97. void toggle();
  98. void close();
  99. void clearProj();
  100. TextureDownsize& create();
  101. void toGui();
  102. void setShader();
  103. void setDrawAs();
  104. static Str ImageInfo(C Image *image, int &size, bool side);
  105. static void SetTextures(C Property &prop);
  106. void setTextures();
  107. void setTexIDs();
  108. void setMtrl();
  109. void setObj();
  110. void refresh();
  111. void setMtrlObj(C UID &mtrl_id, C UID &obj_id);
  112. void getSecondaryList();
  113. void setSecondary(int i);
  114. void setElm(Elm *elm, bool prev=false);
  115. virtual void update(C GuiPC &gpc)override;
  116. public:
  117. TextureDownsize();
  118. };
  119. /******************************************************************************/
  120. /******************************************************************************/
  121. extern TextureDownsize TexDownsize;
  122. /******************************************************************************/