com.warwlock.mtree 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/.github/workflows/npm.yml +19 -0
  2. package/CHANGELOG.md +17 -0
  3. package/CHANGELOG.md.meta +7 -0
  4. package/Documentation~/Documentation.md +3 -0
  5. package/Editor/BranchEditor.cs +545 -0
  6. package/Editor/BranchEditor.cs.meta +16 -0
  7. package/Editor/EditorCallbacks.cs +69 -0
  8. package/Editor/EditorCallbacks.cs.meta +11 -0
  9. package/Editor/MTree.Editor.asmdef +18 -0
  10. package/Editor/MTree.Editor.asmdef.meta +7 -0
  11. package/Editor/MenuItem.cs +31 -0
  12. package/Editor/MenuItem.cs.meta +11 -0
  13. package/Editor/MtreeBezierInspector.cs +161 -0
  14. package/Editor/MtreeBezierInspector.cs.meta +11 -0
  15. package/Editor/MtreeEditor.cs +434 -0
  16. package/Editor/MtreeEditor.cs.meta +11 -0
  17. package/Editor/TemplateInspector.cs +66 -0
  18. package/Editor/TemplateInspector.cs.meta +12 -0
  19. package/Editor/ValuesEditor.cs +18 -0
  20. package/Editor/ValuesEditor.cs.meta +11 -0
  21. package/Editor/VertexColorAdjustmentEditor.cs +169 -0
  22. package/Editor/VertexColorAdjustmentEditor.cs.meta +11 -0
  23. package/Editor.meta +8 -0
  24. package/LICENSE +21 -0
  25. package/LICENSE.meta +7 -0
  26. package/README.md +68 -0
  27. package/README.md.meta +7 -0
  28. package/Resources/Mtree/MtreeBillboardCamera.prefab +204 -0
  29. package/Resources/Mtree/MtreeBillboardCamera.prefab.meta +8 -0
  30. package/Resources/Mtree/Sprites/DeleteCrossSprite.png +0 -0
  31. package/Resources/Mtree/Sprites/DeleteCrossSprite.png.meta +116 -0
  32. package/Resources/Mtree/Sprites/TreeFunctionSprite.png +0 -0
  33. package/Resources/Mtree/Sprites/TreeFunctionSprite.png.meta +116 -0
  34. package/Resources/Mtree/Sprites/TreeFunctionSpriteSelected.psd +0 -0
  35. package/Resources/Mtree/Sprites/TreeFunctionSpriteSelected.psd.meta +116 -0
  36. package/Resources/Mtree/Sprites.meta +8 -0
  37. package/Resources/Mtree/Vertex Color Editor/Mtree Vertex Color GameObject.prefab +104 -0
  38. package/Resources/Mtree/Vertex Color Editor/Mtree Vertex Color GameObject.prefab.meta +7 -0
  39. package/Resources/Mtree/Vertex Color Editor.meta +8 -0
  40. package/Resources/Mtree/branches.fbx +0 -0
  41. package/Resources/Mtree/branches.fbx.meta +137 -0
  42. package/Resources/Mtree.meta +8 -0
  43. package/Resources.meta +8 -0
  44. package/Runtime/AO/DensityAO.cs +203 -0
  45. package/Runtime/AO/DensityAO.cs.meta +11 -0
  46. package/Runtime/AO/KDTree.cs +169 -0
  47. package/Runtime/AO/KDTree.cs.meta +11 -0
  48. package/Runtime/AO/WeightedRandom.cs +74 -0
  49. package/Runtime/AO/WeightedRandom.cs.meta +11 -0
  50. package/Runtime/AO.meta +8 -0
  51. package/Runtime/Bezier/Bezier.cs +69 -0
  52. package/Runtime/Bezier/Bezier.cs.meta +11 -0
  53. package/Runtime/Bezier/MtreeBezier.cs +185 -0
  54. package/Runtime/Bezier/MtreeBezier.cs.meta +11 -0
  55. package/Runtime/Bezier.meta +8 -0
  56. package/Runtime/ExampleSceneManager.cs +165 -0
  57. package/Runtime/ExampleSceneManager.cs.meta +11 -0
  58. package/Runtime/LODValues.cs +44 -0
  59. package/Runtime/LODValues.cs.meta +11 -0
  60. package/Runtime/LeafPoint.cs +135 -0
  61. package/Runtime/LeafPoint.cs.meta +11 -0
  62. package/Runtime/MTree.Runtime.asmdef +3 -0
  63. package/Runtime/MTree.Runtime.asmdef.meta +7 -0
  64. package/Runtime/MTree.cs +569 -0
  65. package/Runtime/MTree.cs.meta +11 -0
  66. package/Runtime/MtreeComponent.cs +482 -0
  67. package/Runtime/MtreeComponent.cs.meta +11 -0
  68. package/Runtime/MtreeVariables.cs +11 -0
  69. package/Runtime/MtreeVariables.cs.meta +11 -0
  70. package/Runtime/MtreeWind.cs +94 -0
  71. package/Runtime/MtreeWind.cs.meta +11 -0
  72. package/Runtime/Node.cs +331 -0
  73. package/Runtime/Node.cs.meta +11 -0
  74. package/Runtime/SimplexNoise.cs +166 -0
  75. package/Runtime/SimplexNoise.cs.meta +11 -0
  76. package/Runtime/Splines.cs +379 -0
  77. package/Runtime/Splines.cs.meta +11 -0
  78. package/Runtime/TreeBilboard.cs +290 -0
  79. package/Runtime/TreeBilboard.cs.meta +11 -0
  80. package/Runtime/TreeFunctions/BranchFunction.cs +92 -0
  81. package/Runtime/TreeFunctions/BranchFunction.cs.meta +11 -0
  82. package/Runtime/TreeFunctions/GrowFunction.cs +81 -0
  83. package/Runtime/TreeFunctions/GrowFunction.cs.meta +11 -0
  84. package/Runtime/TreeFunctions/LeafFunction.cs +111 -0
  85. package/Runtime/TreeFunctions/LeafFunction.cs.meta +11 -0
  86. package/Runtime/TreeFunctions/RootsFunction.cs +77 -0
  87. package/Runtime/TreeFunctions/RootsFunction.cs.meta +11 -0
  88. package/Runtime/TreeFunctions/SplitFunction.cs +50 -0
  89. package/Runtime/TreeFunctions/SplitFunction.cs.meta +11 -0
  90. package/Runtime/TreeFunctions/TreeFunctionAsset.cs +105 -0
  91. package/Runtime/TreeFunctions/TreeFunctionAsset.cs.meta +11 -0
  92. package/Runtime/TreeFunctions/TrunkFunction.cs +88 -0
  93. package/Runtime/TreeFunctions/TrunkFunction.cs.meta +11 -0
  94. package/Runtime/TreeFunctions.meta +8 -0
  95. package/Runtime/TreePoint.cs +27 -0
  96. package/Runtime/TreePoint.cs.meta +11 -0
  97. package/Runtime/TreeTemplate.cs +50 -0
  98. package/Runtime/TreeTemplate.cs.meta +12 -0
  99. package/Runtime/Utils.cs +268 -0
  100. package/Runtime/Utils.cs.meta +11 -0
  101. package/Runtime/VSProIntegration.cs +132 -0
  102. package/Runtime/VSProIntegration.cs.meta +11 -0
  103. package/Runtime.meta +8 -0
  104. package/Samples~/ExampleTemplates/Examples/Birch.asset +364 -0
  105. package/Samples~/ExampleTemplates/Examples/Birch.asset.meta +8 -0
  106. package/Samples~/ExampleTemplates/Examples/Bush.asset +385 -0
  107. package/Samples~/ExampleTemplates/Examples/Bush.asset.meta +8 -0
  108. package/Samples~/ExampleTemplates/Examples/Eastern Pine.asset +482 -0
  109. package/Samples~/ExampleTemplates/Examples/Eastern Pine.asset.meta +8 -0
  110. package/Samples~/ExampleTemplates/Examples/FantasyTree.asset +406 -0
  111. package/Samples~/ExampleTemplates/Examples/FantasyTree.asset.meta +8 -0
  112. package/Samples~/ExampleTemplates/Examples/Fern.asset +291 -0
  113. package/Samples~/ExampleTemplates/Examples/Fern.asset.meta +8 -0
  114. package/Samples~/ExampleTemplates/Examples/High Poly.asset +300 -0
  115. package/Samples~/ExampleTemplates/Examples/High Poly.asset.meta +8 -0
  116. package/Samples~/ExampleTemplates/Examples/LightingData.asset +0 -0
  117. package/Samples~/ExampleTemplates/Examples/LightingData.asset.meta +8 -0
  118. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch Outline.mat +196 -0
  119. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch Outline.mat.meta +8 -0
  120. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch.mat +196 -0
  121. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch.mat.meta +8 -0
  122. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Fern.mat +181 -0
  123. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Fern.mat.meta +8 -0
  124. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark HighPoly.mat +201 -0
  125. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark HighPoly.mat.meta +8 -0
  126. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Oak.mat +208 -0
  127. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Oak.mat.meta +8 -0
  128. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Palm.mat +180 -0
  129. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Palm.mat.meta +8 -0
  130. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Pine.mat +206 -0
  131. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Pine.mat.meta +8 -0
  132. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Ponderossa.mat +206 -0
  133. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Ponderossa.mat.meta +8 -0
  134. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Poplar.mat +172 -0
  135. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Poplar.mat.meta +8 -0
  136. package/Samples~/ExampleTemplates/Examples/Materials/Bark.meta +8 -0
  137. package/Samples~/ExampleTemplates/Examples/Materials/Example Scene/Floor.mat +392 -0
  138. package/Samples~/ExampleTemplates/Examples/Materials/Example Scene/Floor.mat.meta +8 -0
  139. package/Samples~/ExampleTemplates/Examples/Materials/Example Scene.meta +8 -0
  140. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Fern.mat +202 -0
  141. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Fern.mat.meta +8 -0
  142. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs HighPoly.mat +265 -0
  143. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs HighPoly.mat.meta +8 -0
  144. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Needles.mat +267 -0
  145. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Needles.mat.meta +8 -0
  146. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palm.mat +232 -0
  147. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palm.mat.meta +8 -0
  148. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palmate.mat +250 -0
  149. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palmate.mat.meta +8 -0
  150. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Pine.mat +247 -0
  151. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Pine.mat.meta +8 -0
  152. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Poplar.mat +223 -0
  153. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Poplar.mat.meta +8 -0
  154. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate Outline.mat +262 -0
  155. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate Outline.mat.meta +8 -0
  156. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate.mat +281 -0
  157. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate.mat.meta +8 -0
  158. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Stone Pine.mat +267 -0
  159. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Stone Pine.mat.meta +8 -0
  160. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Willow.mat +236 -0
  161. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Willow.mat.meta +8 -0
  162. package/Samples~/ExampleTemplates/Examples/Materials/Leafs.meta +8 -0
  163. package/Samples~/ExampleTemplates/Examples/Materials.meta +8 -0
  164. package/Samples~/ExampleTemplates/Examples/Oak.asset +364 -0
  165. package/Samples~/ExampleTemplates/Examples/Oak.asset.meta +8 -0
  166. package/Samples~/ExampleTemplates/Examples/Old Oak.asset +364 -0
  167. package/Samples~/ExampleTemplates/Examples/Old Oak.asset.meta +8 -0
  168. package/Samples~/ExampleTemplates/Examples/Palm.asset +500 -0
  169. package/Samples~/ExampleTemplates/Examples/Palm.asset.meta +8 -0
  170. package/Samples~/ExampleTemplates/Examples/Pine 2.asset +387 -0
  171. package/Samples~/ExampleTemplates/Examples/Pine 2.asset.meta +8 -0
  172. package/Samples~/ExampleTemplates/Examples/Pine.asset +405 -0
  173. package/Samples~/ExampleTemplates/Examples/Pine.asset.meta +8 -0
  174. package/Samples~/ExampleTemplates/Examples/Ponderossa Pine.asset +478 -0
  175. package/Samples~/ExampleTemplates/Examples/Ponderossa Pine.asset.meta +8 -0
  176. package/Samples~/ExampleTemplates/Examples/Poplar.asset +309 -0
  177. package/Samples~/ExampleTemplates/Examples/Poplar.asset.meta +8 -0
  178. package/Samples~/ExampleTemplates/Examples/ReflectionProbe-0.exr +0 -0
  179. package/Samples~/ExampleTemplates/Examples/ReflectionProbe-0.exr.meta +117 -0
  180. package/Samples~/ExampleTemplates/Examples/Small Pine.asset +273 -0
  181. package/Samples~/ExampleTemplates/Examples/Small Pine.asset.meta +8 -0
  182. package/Samples~/ExampleTemplates/Examples/Small Tree.asset +364 -0
  183. package/Samples~/ExampleTemplates/Examples/Small Tree.asset.meta +8 -0
  184. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_C.png +0 -0
  185. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_C.png.meta +74 -0
  186. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_N.png +0 -0
  187. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_N.png.meta +96 -0
  188. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_C.png +0 -0
  189. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_C.png.meta +116 -0
  190. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_N.png +0 -0
  191. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_N.png.meta +116 -0
  192. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_C.png +0 -0
  193. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_C.png.meta +132 -0
  194. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_N.png +0 -0
  195. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_N.png.meta +116 -0
  196. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_2_C.png +0 -0
  197. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_2_C.png.meta +132 -0
  198. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_C.png +0 -0
  199. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_C.png.meta +132 -0
  200. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_N.png +0 -0
  201. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_N.png.meta +116 -0
  202. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_C.png +0 -0
  203. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_C.png.meta +132 -0
  204. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_N.png +0 -0
  205. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_N.png.meta +116 -0
  206. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_C.png +0 -0
  207. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_C.png.meta +74 -0
  208. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_N.png +0 -0
  209. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_N.png.meta +96 -0
  210. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_C.png +0 -0
  211. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_C.png.meta +74 -0
  212. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_N.bmp +0 -0
  213. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_N.bmp.meta +96 -0
  214. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_C.png +0 -0
  215. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_C.png.meta +74 -0
  216. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_N.png +0 -0
  217. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_N.png.meta +96 -0
  218. package/Samples~/ExampleTemplates/Examples/Textures/Bark.meta +8 -0
  219. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_C.png +0 -0
  220. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_C.png.meta +96 -0
  221. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_N.png +0 -0
  222. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_N.png.meta +96 -0
  223. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_C.png +0 -0
  224. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_C.png.meta +99 -0
  225. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_N.png +0 -0
  226. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_N.png.meta +96 -0
  227. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_C.png +0 -0
  228. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_C.png.meta +99 -0
  229. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_N.png +0 -0
  230. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_N.png.meta +96 -0
  231. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_C.png +0 -0
  232. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_C.png.meta +88 -0
  233. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_N.png +0 -0
  234. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_N.png.meta +96 -0
  235. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_C.png +0 -0
  236. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_C.png.meta +96 -0
  237. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_N.png +0 -0
  238. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_N.png.meta +96 -0
  239. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_C.png +0 -0
  240. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_C.png.meta +96 -0
  241. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_N.png +0 -0
  242. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_N.png.meta +96 -0
  243. package/Samples~/ExampleTemplates/Examples/Textures/Branch.meta +8 -0
  244. package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_PSD.psd +0 -0
  245. package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_PSD.psd.meta +76 -0
  246. package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_Toon.png +0 -0
  247. package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_Toon.png.meta +76 -0
  248. package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp.meta +8 -0
  249. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_C.png +0 -0
  250. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_C.png.meta +99 -0
  251. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_N.png +0 -0
  252. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_N.png.meta +88 -0
  253. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_C.png +0 -0
  254. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_C.png.meta +88 -0
  255. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_N.png +0 -0
  256. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_N.png.meta +88 -0
  257. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_C.png +0 -0
  258. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_C.png.meta +99 -0
  259. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_N.png +0 -0
  260. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_N.png.meta +88 -0
  261. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_C.png +0 -0
  262. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_C.png.meta +96 -0
  263. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_N.png +0 -0
  264. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_N.png.meta +96 -0
  265. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs.meta +8 -0
  266. package/Samples~/ExampleTemplates/Examples/Textures.meta +8 -0
  267. package/Samples~/ExampleTemplates/Examples/Willow.asset +364 -0
  268. package/Samples~/ExampleTemplates/Examples/Willow.asset.meta +8 -0
  269. package/Samples~/ExampleTemplates/Examples.meta +8 -0
  270. package/Samples~/ExampleTemplates/Examples.unity +12660 -0
  271. package/Samples~/ExampleTemplates/Examples.unity.meta +7 -0
  272. package/Samples~/ExampleTemplates.meta +8 -0
  273. package/Shaders/BarkShader.shadergraph +17215 -0
  274. package/Shaders/BarkShader.shadergraph.meta +10 -0
  275. package/Shaders/Editor/BarkEditor.cs +100 -0
  276. package/Shaders/Editor/BarkEditor.cs.meta +11 -0
  277. package/Shaders/Editor/LeafEditor.cs +173 -0
  278. package/Shaders/Editor/LeafEditor.cs.meta +11 -0
  279. package/Shaders/Editor.meta +8 -0
  280. package/Shaders/LeafShader.shadergraph +34803 -0
  281. package/Shaders/LeafShader.shadergraph.meta +10 -0
  282. package/Shaders/MTree.Shaders.asmdef +3 -0
  283. package/Shaders/MTree.Shaders.asmdef.meta +7 -0
  284. package/Shaders/leafFunctions.hlsl +201 -0
  285. package/Shaders/leafFunctions.hlsl.meta +7 -0
  286. package/Shaders/vertexFunc.hlsl +55 -0
  287. package/Shaders/vertexFunc.hlsl.meta +7 -0
  288. package/Shaders.meta +8 -0
  289. package/package.json +36 -0
  290. package/package.json.meta +7 -0
@@ -0,0 +1,19 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - uses: actions/setup-node@v1
13
+ with:
14
+ node-version: 12
15
+ registry-url: https://registry.npmjs.org/
16
+ - run: yarn install
17
+ - run: npm publish --access public
18
+ env:
19
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## \[1.0.1] - 2025-11-20
8
+
9
+ ### Fixed
10
+ - "HDRP" and "Built-In" added to "Active Targets".
11
+
12
+
13
+ ## \[1.0.0] - 2025-11-20
14
+
15
+ ### Added
16
+ - Initial open source release of package.
17
+
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 6bae322c17933874ba6bcaba57a56674
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,3 @@
1
+ # MTree Documentation
2
+
3
+ Will be added...
@@ -0,0 +1,545 @@
1
+ using System.Collections;
2
+ using System.Collections.Generic;
3
+ using System.IO;
4
+ using UnityEditor;
5
+ using UnityEngine;
6
+ #if UNITY_2018_3_OR_NEWER
7
+ using UnityEngine.Rendering;
8
+ using UnityEngine.Experimental.Rendering;
9
+ #endif
10
+ public enum EnumTextureSize
11
+ {
12
+ _512, _1024, _2048, _4096
13
+ }
14
+
15
+ namespace Mtree
16
+ {
17
+ public class BranchEditor : EditorWindow
18
+ {
19
+
20
+ #region Exposed variables
21
+ public Texture2D leafTexture, normalLeafTexture;
22
+ public Texture2D barkTexture, normalBarkTexture;
23
+ bool switchShader = false;
24
+ int NormalMode = 0;
25
+ Vector3 NormalRotation = new Vector3(0, 0, 0);
26
+ Color barkColor = Color.white;
27
+ int branchNumber = 5;
28
+ float stemLength = 1.5f;
29
+ float length = 0.5f;
30
+ float radius = .01f;
31
+ float angle = .4f;
32
+ float randomness = .2f;
33
+ float splitProba = .05f;
34
+ int textureSize = 1024;
35
+ EnumTextureSize texSize = EnumTextureSize._1024;
36
+ int leafNumber = 30;
37
+ float leafCovering = .7f;
38
+ float leafLength = 1f;
39
+ float leafSize = .7f;
40
+ float leafAngle = 45f;
41
+ float cutOff = .5f;
42
+ Vector3 hsv = new Vector3(0, 1, 1);
43
+ float leafColorVariation = .1f;
44
+ float fakeShading = .3f;
45
+ bool deadLeafs,deadLeafsRendering;
46
+ int leafRotation = 0;
47
+
48
+ #endregion
49
+
50
+ #region Editor variables
51
+ GameObject branchObject;
52
+ GameObject colliderObject;
53
+ GameObject cameraObject;
54
+ Camera cam;
55
+ Texture2D texture;
56
+ Mesh leafMesh;
57
+ int seed = 21;
58
+ bool showColorOptions = true;
59
+ Vector2 scrollPos;
60
+ #endregion
61
+
62
+ #region Editor cosmetic variables
63
+ Color backgroundColor = new Color(.25f, .255f, .26f);
64
+ Color inspectorColor = new Color(.8f, .8f, .8f, .8f);
65
+ int parametersWidth = 250;
66
+ int texturePadding = 10;
67
+ #endregion
68
+
69
+ #if UNITY_2018_3_OR_NEWER
70
+ #region Pipeline Switch
71
+ static RenderPipelineAsset renderPipelineAsset;
72
+ #endregion
73
+ #endif
74
+
75
+
76
+
77
+
78
+ [MenuItem("Window/Mtree/Open Branch Editor...")]
79
+ static void Start()
80
+ {
81
+ BranchEditor editor = GetWindow(typeof(BranchEditor)) as BranchEditor;
82
+ editor.Init();
83
+ editor.Show();
84
+ #if UNITY_2018_3_OR_NEWER
85
+ renderPipelineAsset = GraphicsSettings.defaultRenderPipeline;
86
+ GraphicsSettings.defaultRenderPipeline = null;
87
+ #endif
88
+ }
89
+
90
+ void Init()
91
+ {
92
+ seed = Random.Range(0, 100);
93
+ UpdateBranch();
94
+ }
95
+
96
+
97
+ void OnGUI()
98
+ {
99
+ GUI.color = backgroundColor;
100
+ GUI.DrawTexture(new Rect(0, 0, position.width, position.height), EditorGUIUtility.whiteTexture);
101
+
102
+ if (texture != null)
103
+ {
104
+ float sizeReduction = Mathf.Min((position.width - parametersWidth - texturePadding * 2) / texture.width, (position.height - texturePadding * 2) / texture.height);
105
+ float posX = ((position.width - parametersWidth) - texture.width * sizeReduction) / 2;
106
+ float posY = position.height - texturePadding - texture.height * sizeReduction;
107
+ GUI.color = backgroundColor * .8f;
108
+ GUI.DrawTexture(new Rect(posX, posY, texture.width * sizeReduction, texture.height * sizeReduction), EditorGUIUtility.whiteTexture);
109
+ GUI.color = Color.white;
110
+ GUI.DrawTexture(new Rect(posX, posY, texture.width * sizeReduction, texture.height * sizeReduction), texture);
111
+ }
112
+
113
+
114
+ BeginWindows();
115
+ GUI.color = inspectorColor;
116
+ Rect parametersRect = new Rect(position.width - parametersWidth,15, parametersWidth, position.height-15);
117
+ #if UNITY_2018_3_OR_NEWER
118
+ Rect pipelinesRect = new Rect(position.width - parametersWidth,0, parametersWidth, position.height);
119
+ var gs = new GUIStyle();
120
+ gs.fontStyle = FontStyle.Italic;
121
+ gs.normal.textColor = Color.red;
122
+ gs.alignment = TextAnchor.UpperCenter;
123
+ if(renderPipelineAsset != null){
124
+ GUI.Label(pipelinesRect,"Active SRP: "+ renderPipelineAsset.name,gs);
125
+ }else{
126
+ gs.normal.textColor = Color.green;
127
+ GUI.Label(pipelinesRect,"Active SRP: Legacy Pipeline",gs);
128
+ }
129
+ #endif
130
+
131
+ GUI.Window(0, parametersRect, DrawInspector, "Parameters");
132
+ GUI.BringWindowToFront(0);
133
+ EndWindows();
134
+ }
135
+
136
+ private void OnDestroy()
137
+ {
138
+ DestoyObjects();
139
+
140
+ #if UNITY_2018_3_OR_NEWER
141
+ GraphicsSettings.defaultRenderPipeline = renderPipelineAsset;
142
+ renderPipelineAsset = null;
143
+ #endif
144
+
145
+ }
146
+
147
+
148
+ void DrawInspector(int id)
149
+ {
150
+ scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
151
+ GUILayout.Label("Branch Settings", EditorStyles.boldLabel);
152
+ EditorGUI.BeginChangeCheck();
153
+ EditorGUIUtility.labelWidth = 80;
154
+ if (GUILayout.Button("Randomize"))
155
+ seed = Random.Range(int.MinValue, int.MaxValue);
156
+ barkTexture = EditorGUILayout.ObjectField("Bark Texture", barkTexture, typeof(Texture2D), false) as Texture2D;
157
+ normalBarkTexture = EditorGUILayout.ObjectField("Bark Normal", normalBarkTexture, typeof(Texture2D), false) as Texture2D;
158
+ barkColor = EditorGUILayout.ColorField("Bark Color", barkColor);
159
+ fakeShading = EditorGUILayout.Slider("Fake Shading Intensity", fakeShading, 0f, 1f);
160
+ stemLength = EditorGUILayout.FloatField("Stem Length", stemLength);
161
+ stemLength = Mathf.Max(stemLength, 0.01f);
162
+ length = EditorGUILayout.FloatField("Branch Length", length);
163
+ length = Mathf.Max(length, 0.01f);
164
+ radius = EditorGUILayout.Slider("Radius", radius, .001f, .1f);
165
+ angle = EditorGUILayout.Slider("Split angle", angle, 0f, 1f);
166
+ randomness = EditorGUILayout.FloatField("Randomness", randomness);
167
+ branchNumber = EditorGUILayout.IntSlider("Branch Count", branchNumber, 0, 50);
168
+ splitProba = EditorGUILayout.Slider("Split Proba", splitProba, 0f, .2f);
169
+
170
+ EditorGUILayout.Space();
171
+ EditorGUILayout.Space();
172
+
173
+ GUILayout.Label("Leaf Settings", EditorStyles.boldLabel);
174
+ leafTexture = EditorGUILayout.ObjectField("Leaf Texture", leafTexture, typeof(Texture2D), false) as Texture2D;
175
+ normalLeafTexture = EditorGUILayout.ObjectField("Leaf Normal", normalLeafTexture, typeof(Texture2D), false) as Texture2D;
176
+ //leafRotation = EditorGUILayout.Slider("Texture Rotation", leafRotation, -180, 180);
177
+
178
+ GUILayout.Label("Texture alignment");
179
+ leafRotation = GUILayout.SelectionGrid(leafRotation, new string[] { "Y", "X", "-Y", "-X" }, 4);
180
+ showColorOptions = EditorGUILayout.Foldout(showColorOptions, "Shader Parameters");
181
+ if (showColorOptions)
182
+ {
183
+ cutOff = EditorGUILayout.Slider("Cut Off", cutOff, 0f, 1f);
184
+ leafColorVariation = EditorGUILayout.Slider("Color Variation", leafColorVariation, 0f, 1f);
185
+ EditorGUILayout.BeginVertical(EditorStyles.helpBox);
186
+ hsv.x = EditorGUILayout.Slider("Hue", hsv.x, 0f, 1f);
187
+ hsv.y = EditorGUILayout.Slider("Saturation", hsv.y, 0f, 2f);
188
+ hsv.z = EditorGUILayout.Slider("Value", hsv.z, 0f, 2f);
189
+ EditorGUILayout.EndVertical();
190
+ }
191
+ leafNumber = EditorGUILayout.IntField("Leaf Count", leafNumber);
192
+ leafNumber = Mathf.Max(0, leafNumber);
193
+ leafCovering = EditorGUILayout.Slider("Leaf Covering", leafCovering, 0f, 1f);
194
+ leafLength = EditorGUILayout.FloatField("Leaf Length", leafLength);
195
+ leafLength = Mathf.Max(0, leafLength);
196
+ leafSize = EditorGUILayout.FloatField("Leaf Size", leafSize);
197
+ leafSize = Mathf.Max(0, leafSize);
198
+ leafAngle = EditorGUILayout.Slider("Leaf Angle", leafAngle, 0f, 90f);
199
+ EditorGUILayout.BeginVertical("box");
200
+ EditorGUILayout.LabelField("Normal Map Mode", Guistyle("b", 10));
201
+
202
+ if (normalBarkTexture != null && normalLeafTexture != null)
203
+ {
204
+ NormalMode = GUILayout.Toolbar(NormalMode, new string[] { "Default", "Enhanced" });
205
+ }
206
+ else
207
+ {
208
+ NormalMode = GUILayout.Toolbar(NormalMode, new string[] { "Default" });
209
+ NormalMode = 0;
210
+ }
211
+ NormalRotation = EditorGUILayout.Vector3Field("Normal Rotation", NormalRotation);
212
+
213
+ string s_swtichShader = "";
214
+ if (switchShader)
215
+ {
216
+ s_swtichShader = "Show Textures";
217
+ }
218
+ else
219
+ {
220
+ s_swtichShader = "Show Normals";
221
+ }
222
+ if (GUILayout.Button(s_swtichShader))
223
+ {
224
+ switchShader = !switchShader;
225
+ }
226
+
227
+ EditorGUILayout.Space();
228
+ texSize = (EnumTextureSize)EditorGUILayout.EnumPopup("Texture Size:", texSize);
229
+ EditorGUILayout.EndVertical();
230
+ if (EditorGUI.EndChangeCheck())
231
+ {
232
+ CheckTextureType();
233
+ UpdateBranch(switchShader);
234
+ }
235
+ EditorGUILayout.BeginVertical("Box");
236
+ EditorGUILayout.LabelField("Texture Output",Guistyle("b"));
237
+ deadLeafs = GUILayout.Toggle(deadLeafs, new GUIContent("Dead Leafs"));
238
+ EditorGUILayout.EndVertical();
239
+
240
+
241
+ if (GUILayout.Button("Save Texture"))
242
+ {
243
+ AssetDatabase.StartAssetEditing();
244
+ ExportTextures();
245
+ AssetDatabase.StopAssetEditing();
246
+ //SaveTexture();
247
+
248
+ }
249
+
250
+ EditorGUILayout.EndScrollView();
251
+ }
252
+ /// <summary>
253
+ /// Fontstyle: "n" = Normal | "i" = Italic | "b" = Bold | "bi" = Bold and Italic
254
+ /// </summary>
255
+ GUIStyle Guistyle(string style = "n", int size = 12)
256
+ {
257
+ var gs = new GUIStyle();
258
+ switch (style)
259
+ {
260
+ case "n":
261
+ gs.fontStyle = FontStyle.Normal;
262
+ break;
263
+ case "i":
264
+ gs.fontStyle = FontStyle.Italic;
265
+ break;
266
+ case "b":
267
+ gs.fontStyle = FontStyle.Bold;
268
+ break;
269
+ case "bi":
270
+ gs.fontStyle = FontStyle.BoldAndItalic;
271
+ break;
272
+ }
273
+ gs.fontSize = size;
274
+ return gs;
275
+ }
276
+ void UpdateBranch(bool normalShader = false)
277
+ {
278
+ switch (texSize)
279
+ {
280
+ case EnumTextureSize._512:
281
+ textureSize = 512;
282
+ break;
283
+ case EnumTextureSize._1024:
284
+ textureSize = 1024;
285
+ break;
286
+ case EnumTextureSize._2048:
287
+ textureSize = 2048;
288
+ break;
289
+ case EnumTextureSize._4096:
290
+ textureSize = 4096;
291
+ break;
292
+ }
293
+
294
+ if (branchObject == null)
295
+ CreateBranchObject(normalShader);
296
+ if(!deadLeafsRendering)
297
+ CreateLeafMesh();
298
+ MTree branch = new MTree(branchObject.transform);
299
+ TrunkFunction trunkFunction = ScriptableObject.CreateInstance<TrunkFunction>();
300
+ trunkFunction.Init(null);
301
+
302
+ float resolution = 20;
303
+
304
+ Random.InitState(seed);
305
+
306
+
307
+ branch.AddTrunk(Vector3.up, Vector3.forward, stemLength, AnimationCurve.Linear(0, 1, 1, .3f), radius, resolution, randomness / 3, 0, AnimationCurve.Linear(0, 1, 0, 0), 0, .01f, 1, 0);
308
+ branch.TwigSplit(branchNumber, angle*90f, .9f, 0f);
309
+ branch.Grow(length, AnimationCurve.Linear(0, 1, 1, 1), resolution, splitProba, AnimationCurve.Linear(0, 1, 1, 1), angle, 2, 1, 1, randomness, AnimationCurve.Linear(0, 1, 1, .4f), .9f, 0f, 0f, 1f, 0.00001f, obstacleAvoidance:false);
310
+ if(!deadLeafsRendering)
311
+ branch.AddLeafs(leafCovering, leafNumber, new Mesh[] { leafMesh }, leafSize, false, 0, 0, 1, leafAngle, false, 0, 0, 0, 0);
312
+ Mesh mesh = CreateBranchMesh(branch, trunkFunction);
313
+
314
+ branchObject.GetComponent<MeshFilter>().mesh = mesh;
315
+
316
+ if (cameraObject == null)
317
+ CreateCameraObject();
318
+ RenderCamera();
319
+
320
+ DestoyObjects();
321
+ }
322
+
323
+
324
+ void CreateBranchObject(bool normalShader)
325
+ {
326
+ branchObject = new GameObject("Branch Editor");
327
+ branchObject.transform.position = Vector3.down * 200;
328
+ branchObject.AddComponent<MeshFilter>();
329
+ MeshRenderer rend = branchObject.AddComponent<MeshRenderer>();
330
+ Material barkMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Bark"));
331
+ Material leafMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Leafs"));
332
+
333
+ if (normalShader)
334
+ {
335
+ if (NormalMode == 0)
336
+ {
337
+ barkMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Normal"));
338
+ leafMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Normal"));
339
+ }
340
+ if (NormalMode == 1)
341
+ {
342
+ barkMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_EnhancedNormal"));
343
+ leafMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_EnhancedNormal"));
344
+ barkMaterial.SetVector("_Rotation", NormalRotation + new Vector3(90, 0, 0));
345
+ leafMaterial.SetVector("_Rotation", NormalRotation + new Vector3(90, 0, 0));
346
+ }
347
+ barkMaterial.SetTexture("_BumpMap", normalBarkTexture);
348
+ leafMaterial.SetTexture("_BumpMap", normalLeafTexture);
349
+ }
350
+ else
351
+ {
352
+ barkMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Bark"));
353
+ leafMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Leafs")); barkMaterial.SetTexture("_MainTex", barkTexture);
354
+ barkMaterial.SetFloat("_FakeShading", fakeShading);
355
+ barkMaterial.SetColor("_Color", barkColor);
356
+ leafMaterial.SetFloat("_HueShift", hsv.x);
357
+ leafMaterial.SetFloat("_Saturation", hsv.y);
358
+ leafMaterial.SetFloat("_Value", hsv.z);
359
+ leafMaterial.SetFloat("_ColorVariation", leafColorVariation);
360
+ }
361
+ leafMaterial.SetTexture("_MainTex", leafTexture);
362
+ leafMaterial.SetFloat("_Cutoff", cutOff);
363
+ rend.sharedMaterials = new Material[] { barkMaterial, leafMaterial };
364
+
365
+ colliderObject = new GameObject("collider");
366
+ colliderObject.transform.position = branchObject.transform.position + Vector3.back;
367
+ BoxCollider col = colliderObject.AddComponent<BoxCollider>();
368
+ col.size = new Vector3(5, 5, .01f);
369
+
370
+ }
371
+
372
+
373
+ void CreateCameraObject()
374
+ {
375
+ cameraObject = Instantiate(Resources.Load("Mtree/MtreeBillboardCamera") as GameObject);
376
+ cameraObject.transform.position = branchObject.transform.position;
377
+ cameraObject.transform.rotation = Quaternion.Euler(90, 0, 0);
378
+
379
+ cam = cameraObject.GetComponent<Camera>();
380
+ cam.orthographic = true;
381
+
382
+ Bounds bb = branchObject.GetComponent<Renderer>().bounds;
383
+ Vector3 position = bb.center;
384
+ position.x = branchObject.transform.position.x; ;
385
+ float width = Mathf.Abs(position.x - bb.center.x) + bb.extents.x;
386
+ cam.transform.position = position;
387
+ cam.nearClipPlane = -bb.extents.y;
388
+ cam.farClipPlane = bb.extents.y;
389
+ cam.orthographicSize = bb.extents.z;
390
+ cam.aspect = width / bb.extents.z;
391
+ Color color = backgroundColor;
392
+ color.a = 0f;
393
+ cam.backgroundColor = color;
394
+ cam.clearFlags = CameraClearFlags.SolidColor;
395
+ }
396
+
397
+
398
+ void RenderCamera()
399
+ {
400
+ RenderTexture currentRT = RenderTexture.active;
401
+ int sizeY = textureSize;
402
+ int sizeX = (int)(textureSize * cam.aspect);
403
+ RenderTexture camText = new RenderTexture(sizeX, sizeY, 16, RenderTextureFormat.ARGB32);
404
+ cam.targetTexture = camText;
405
+ RenderTexture.active = cam.targetTexture;
406
+ cam.Render();
407
+ Texture2D image = new Texture2D(cam.targetTexture.width, cam.targetTexture.height, TextureFormat.RGBA32, false);
408
+ image.name = "Branch";
409
+ image.ReadPixels(new Rect(0, 0, cam.targetTexture.width, cam.targetTexture.height), 0, 0);
410
+ image.Apply();
411
+ RenderTexture.active = currentRT;
412
+ texture = image;
413
+ }
414
+
415
+
416
+ Mesh CreateBranchMesh(MTree branch, TrunkFunction trunkFunction)
417
+ {
418
+ Mesh mesh = new Mesh();
419
+ branch.GenerateMeshData(trunkFunction, 0, 1, 1, 1);
420
+ mesh.vertices = branch.verts;
421
+ mesh.normals = branch.normals;
422
+ mesh.uv = branch.uvs;
423
+ Color[] colors = branch.colors;
424
+ mesh.triangles = branch.triangles;
425
+ if (branch.leafTriangles.Length > 0)
426
+ {
427
+ mesh.subMeshCount = 2;
428
+ mesh.SetTriangles(branch.leafTriangles, 1);
429
+ }
430
+ mesh.colors = colors;
431
+ return mesh;
432
+ }
433
+
434
+
435
+ void DestoyObjects()
436
+ {
437
+ if (branchObject != null)
438
+ DestroyImmediate(branchObject);
439
+ if (cameraObject != null)
440
+ DestroyImmediate(cameraObject);
441
+ if (colliderObject != null)
442
+ DestroyImmediate(colliderObject);
443
+ }
444
+
445
+
446
+ void CreateLeafMesh()
447
+ {
448
+ Vector3[] verts = new Vector3[4] { Vector3.left / 2, Vector3.left / 2 + Vector3.forward * leafLength, Vector3.right / 2 + Vector3.forward * leafLength, Vector3.right / 2 };
449
+ Quaternion rot = Quaternion.Euler(0, leafRotation * 90, 0);
450
+ Matrix4x4 trans = Matrix4x4.Translate(new Vector3(0, 0, -leafLength / 2));
451
+ Matrix4x4 transInv = trans.inverse;
452
+
453
+ for (int i = 0; i < verts.Length; i++)
454
+ {
455
+ verts[i] = trans.MultiplyPoint(verts[i]);
456
+ verts[i] = rot * verts[i];
457
+ verts[i] = transInv.MultiplyPoint(verts[i]);
458
+ }
459
+ Vector3[] normals = new Vector3[4] { Vector3.up, Vector3.up, Vector3.up, Vector3.up };
460
+ Vector2[] uvs = new Vector2[4] { Vector2.zero, Vector2.up, Vector2.up + Vector2.right, Vector2.right };
461
+ int[] triangles = new int[6] { 0, 1, 3, 1, 2, 3 };
462
+
463
+ leafMesh = new Mesh();
464
+ leafMesh.vertices = verts;
465
+ leafMesh.normals = normals;
466
+ leafMesh.uv = uvs;
467
+ leafMesh.triangles = triangles;
468
+ }
469
+
470
+
471
+ void ExportTextures()
472
+ {
473
+
474
+ UpdateBranch();
475
+ string path = SaveTexture();
476
+ string name = Path.GetFileNameWithoutExtension(path);
477
+ var nameDB = name;
478
+ name += "_Normal.png";
479
+ path = path.Replace(Path.GetFileName(path), name);
480
+ UpdateBranch(true);
481
+ SaveTexture(path);
482
+ if (deadLeafs)
483
+ {
484
+ deadLeafsRendering = true;
485
+ name = nameDB + "_DeadLeafs.png";
486
+ path = path.Replace(Path.GetFileName(path), name);
487
+ UpdateBranch();
488
+ SaveTexture(path);
489
+
490
+ deadLeafsRendering = true;
491
+ name = nameDB + "_DeadLeafs_Normal.png";
492
+ path = path.Replace(Path.GetFileName(path), name);
493
+ UpdateBranch(true);
494
+ SaveTexture(path);
495
+ deadLeafsRendering = false;
496
+ }
497
+ UpdateBranch();
498
+
499
+ }
500
+ void CheckTextureType()
501
+ {
502
+ // var b_path = AssetDatabase.GetAssetPath(normalBarkTexture);
503
+ // var l_path = AssetDatabase.GetAssetPath(normalLeafTexture);
504
+ // TextureImporter b_t = (TextureImporter)TextureImporter.GetAtPath(b_path);
505
+ // TextureImporter l_t = (TextureImporter)TextureImporter.GetAtPath(b_path);
506
+ // if(b_t.textureType != TextureImporterType.NormalMap){
507
+ // b_t.textureType = TextureImporterType.NormalMap;
508
+ // b_t.SaveAndReimport();
509
+ // }
510
+ // if(l_t.textureType != TextureImporterType.NormalMap){
511
+ // l_t.textureType = TextureImporterType.NormalMap;
512
+ // l_t.SaveAndReimport();
513
+ // }
514
+ }
515
+
516
+ string SaveTexture(string path = null)
517
+ {
518
+ if (path == null)
519
+ {
520
+ path = EditorUtility.SaveFilePanelInProject("Save png", texture.name + ".png", "png", "Please enter a file name to save the texture to");
521
+ }
522
+ if (path.Length != 0)
523
+ {
524
+ Utils.DilateTexture(texture, 100);
525
+ byte[] bytes = texture.EncodeToPNG();
526
+ File.WriteAllBytes(path, bytes);
527
+ AssetDatabase.Refresh();
528
+ }
529
+ return path;
530
+ }
531
+
532
+ private void RemoveBackground(ref Color[] colors)
533
+ {
534
+ Color backgroundColor = new Color(0.025f, 0.07f, 0.19f);
535
+ for (int i = 0; i < colors.Length; i++)
536
+ {
537
+ Color c = colors[i];
538
+ if (Mathf.Abs(c.r - backgroundColor.r) + Mathf.Abs(c.g - backgroundColor.g) + Mathf.Abs(c.b - backgroundColor.b) < .05)
539
+ {
540
+ colors[i] = new Color(0, 0, 0, 0);
541
+ }
542
+ }
543
+ }
544
+ }
545
+ }
@@ -0,0 +1,16 @@
1
+ fileFormatVersion: 2
2
+ guid: cde4d011ef4c2cd4ea1a5e4ae0a0bd74
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences:
7
+ - m_PersistentViewDataDictionary: {instanceID: 0}
8
+ - leafTexture: {fileID: 2800000, guid: fa92e022faac9774fa119daa58d30e1e, type: 3}
9
+ - normalLeafTexture: {fileID: 2800000, guid: 484e5ae7bf0555b4d984e8c7cf893017, type: 3}
10
+ - barkTexture: {fileID: 2800000, guid: cbfeb2867c4dc9949806880460cd8903, type: 3}
11
+ - normalBarkTexture: {fileID: 2800000, guid: b3a8b02284c008548941ccb056fa869a, type: 3}
12
+ executionOrder: 0
13
+ icon: {instanceID: 0}
14
+ userData:
15
+ assetBundleName:
16
+ assetBundleVariant:
@@ -0,0 +1,69 @@
1
+ using System.Collections;
2
+ using System.Collections.Generic;
3
+ using UnityEngine;
4
+ using UnityEditor;
5
+ using System.IO;
6
+
7
+ #if UNITY_2018_3_OR_NEWER
8
+ using UnityEditor.Experimental.SceneManagement;
9
+ #endif
10
+
11
+ namespace Mtree
12
+ {
13
+
14
+ [InitializeOnLoad]
15
+ public class EditorCallbacks
16
+ {
17
+ static EditorCallbacks()
18
+ {
19
+ PrefabUtility.prefabInstanceUpdated += OnCreatePrefab;
20
+ }
21
+
22
+ public static void OnCreatePrefab(GameObject instance)
23
+ {
24
+ if (instance.GetComponent<MtreeComponent>() == null)
25
+ return;
26
+
27
+ #if UNITY_2018_3_OR_NEWER
28
+ string prefabPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(instance);
29
+ #else
30
+ string prefabPath = AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabParent(instance));
31
+ #endif
32
+ MtreeComponent[] trees = (MtreeComponent[])GameObject.FindObjectsOfType(typeof(MtreeComponent));
33
+ MtreeComponent originTree = null;
34
+ foreach (MtreeComponent tree in trees)
35
+ {
36
+ #if UNITY_2018_3_OR_NEWER
37
+ bool isInstance = PrefabUtility.GetPrefabInstanceStatus(tree) == PrefabInstanceStatus.Connected;
38
+ string parentPrefabPath = AssetDatabase.GetAssetPath(PrefabUtility.GetCorrespondingObjectFromSource(tree));
39
+ #else
40
+ bool isInstance = PrefabUtility.GetPrefabType(tree) == PrefabType.PrefabInstance;
41
+ string parentPrefabPath = AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabParent(tree));
42
+ #endif
43
+ if (isInstance && parentPrefabPath == prefabPath)
44
+ {
45
+ #if UNITY_2018_3_OR_NEWER
46
+ PrefabUtility.UnpackPrefabInstance(tree.gameObject, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
47
+ #else
48
+ PrefabUtility.DisconnectPrefabInstance(tree);
49
+ #endif
50
+ originTree = tree;
51
+ }
52
+ }
53
+
54
+
55
+ #if UNITY_2018_3_OR_NEWER // Unity 2017 crashes when deleting prefab at this stage. This part is therefore also done in the MtreeComponent editor
56
+ AssetDatabase.DeleteAsset(prefabPath);
57
+ AssetDatabase.Refresh();
58
+ #endif
59
+
60
+ if (originTree == null)
61
+ return;
62
+
63
+ string templatePath = AssetDatabase.GenerateUniqueAssetPath(Path.GetDirectoryName(prefabPath) + "/" + originTree.name + ".asset");
64
+ TreeTemplate template = TreeTemplate.CreateFromFunctions(originTree.treeFunctionsAssets, templatePath);
65
+ originTree.template = template;
66
+ }
67
+ }
68
+
69
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 7b2bffaede70f974c894d86d3b76a446
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: