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.
- package/.github/workflows/npm.yml +19 -0
- package/CHANGELOG.md +17 -0
- package/CHANGELOG.md.meta +7 -0
- package/Documentation~/Documentation.md +3 -0
- package/Editor/BranchEditor.cs +545 -0
- package/Editor/BranchEditor.cs.meta +16 -0
- package/Editor/EditorCallbacks.cs +69 -0
- package/Editor/EditorCallbacks.cs.meta +11 -0
- package/Editor/MTree.Editor.asmdef +18 -0
- package/Editor/MTree.Editor.asmdef.meta +7 -0
- package/Editor/MenuItem.cs +31 -0
- package/Editor/MenuItem.cs.meta +11 -0
- package/Editor/MtreeBezierInspector.cs +161 -0
- package/Editor/MtreeBezierInspector.cs.meta +11 -0
- package/Editor/MtreeEditor.cs +434 -0
- package/Editor/MtreeEditor.cs.meta +11 -0
- package/Editor/TemplateInspector.cs +66 -0
- package/Editor/TemplateInspector.cs.meta +12 -0
- package/Editor/ValuesEditor.cs +18 -0
- package/Editor/ValuesEditor.cs.meta +11 -0
- package/Editor/VertexColorAdjustmentEditor.cs +169 -0
- package/Editor/VertexColorAdjustmentEditor.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/LICENSE +21 -0
- package/LICENSE.meta +7 -0
- package/README.md +68 -0
- package/README.md.meta +7 -0
- package/Resources/Mtree/MtreeBillboardCamera.prefab +204 -0
- package/Resources/Mtree/MtreeBillboardCamera.prefab.meta +8 -0
- package/Resources/Mtree/Sprites/DeleteCrossSprite.png +0 -0
- package/Resources/Mtree/Sprites/DeleteCrossSprite.png.meta +116 -0
- package/Resources/Mtree/Sprites/TreeFunctionSprite.png +0 -0
- package/Resources/Mtree/Sprites/TreeFunctionSprite.png.meta +116 -0
- package/Resources/Mtree/Sprites/TreeFunctionSpriteSelected.psd +0 -0
- package/Resources/Mtree/Sprites/TreeFunctionSpriteSelected.psd.meta +116 -0
- package/Resources/Mtree/Sprites.meta +8 -0
- package/Resources/Mtree/Vertex Color Editor/Mtree Vertex Color GameObject.prefab +104 -0
- package/Resources/Mtree/Vertex Color Editor/Mtree Vertex Color GameObject.prefab.meta +7 -0
- package/Resources/Mtree/Vertex Color Editor.meta +8 -0
- package/Resources/Mtree/branches.fbx +0 -0
- package/Resources/Mtree/branches.fbx.meta +137 -0
- package/Resources/Mtree.meta +8 -0
- package/Resources.meta +8 -0
- package/Runtime/AO/DensityAO.cs +203 -0
- package/Runtime/AO/DensityAO.cs.meta +11 -0
- package/Runtime/AO/KDTree.cs +169 -0
- package/Runtime/AO/KDTree.cs.meta +11 -0
- package/Runtime/AO/WeightedRandom.cs +74 -0
- package/Runtime/AO/WeightedRandom.cs.meta +11 -0
- package/Runtime/AO.meta +8 -0
- package/Runtime/Bezier/Bezier.cs +69 -0
- package/Runtime/Bezier/Bezier.cs.meta +11 -0
- package/Runtime/Bezier/MtreeBezier.cs +185 -0
- package/Runtime/Bezier/MtreeBezier.cs.meta +11 -0
- package/Runtime/Bezier.meta +8 -0
- package/Runtime/ExampleSceneManager.cs +165 -0
- package/Runtime/ExampleSceneManager.cs.meta +11 -0
- package/Runtime/LODValues.cs +44 -0
- package/Runtime/LODValues.cs.meta +11 -0
- package/Runtime/LeafPoint.cs +135 -0
- package/Runtime/LeafPoint.cs.meta +11 -0
- package/Runtime/MTree.Runtime.asmdef +3 -0
- package/Runtime/MTree.Runtime.asmdef.meta +7 -0
- package/Runtime/MTree.cs +569 -0
- package/Runtime/MTree.cs.meta +11 -0
- package/Runtime/MtreeComponent.cs +482 -0
- package/Runtime/MtreeComponent.cs.meta +11 -0
- package/Runtime/MtreeVariables.cs +11 -0
- package/Runtime/MtreeVariables.cs.meta +11 -0
- package/Runtime/MtreeWind.cs +94 -0
- package/Runtime/MtreeWind.cs.meta +11 -0
- package/Runtime/Node.cs +331 -0
- package/Runtime/Node.cs.meta +11 -0
- package/Runtime/SimplexNoise.cs +166 -0
- package/Runtime/SimplexNoise.cs.meta +11 -0
- package/Runtime/Splines.cs +379 -0
- package/Runtime/Splines.cs.meta +11 -0
- package/Runtime/TreeBilboard.cs +290 -0
- package/Runtime/TreeBilboard.cs.meta +11 -0
- package/Runtime/TreeFunctions/BranchFunction.cs +92 -0
- package/Runtime/TreeFunctions/BranchFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/GrowFunction.cs +81 -0
- package/Runtime/TreeFunctions/GrowFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/LeafFunction.cs +111 -0
- package/Runtime/TreeFunctions/LeafFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/RootsFunction.cs +77 -0
- package/Runtime/TreeFunctions/RootsFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/SplitFunction.cs +50 -0
- package/Runtime/TreeFunctions/SplitFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/TreeFunctionAsset.cs +105 -0
- package/Runtime/TreeFunctions/TreeFunctionAsset.cs.meta +11 -0
- package/Runtime/TreeFunctions/TrunkFunction.cs +88 -0
- package/Runtime/TreeFunctions/TrunkFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions.meta +8 -0
- package/Runtime/TreePoint.cs +27 -0
- package/Runtime/TreePoint.cs.meta +11 -0
- package/Runtime/TreeTemplate.cs +50 -0
- package/Runtime/TreeTemplate.cs.meta +12 -0
- package/Runtime/Utils.cs +268 -0
- package/Runtime/Utils.cs.meta +11 -0
- package/Runtime/VSProIntegration.cs +132 -0
- package/Runtime/VSProIntegration.cs.meta +11 -0
- package/Runtime.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Birch.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Birch.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Bush.asset +385 -0
- package/Samples~/ExampleTemplates/Examples/Bush.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Eastern Pine.asset +482 -0
- package/Samples~/ExampleTemplates/Examples/Eastern Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/FantasyTree.asset +406 -0
- package/Samples~/ExampleTemplates/Examples/FantasyTree.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Fern.asset +291 -0
- package/Samples~/ExampleTemplates/Examples/Fern.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/High Poly.asset +300 -0
- package/Samples~/ExampleTemplates/Examples/High Poly.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/LightingData.asset +0 -0
- package/Samples~/ExampleTemplates/Examples/LightingData.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch Outline.mat +196 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch Outline.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch.mat +196 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Fern.mat +181 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Fern.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark HighPoly.mat +201 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark HighPoly.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Oak.mat +208 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Oak.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Palm.mat +180 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Palm.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Pine.mat +206 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Pine.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Ponderossa.mat +206 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Ponderossa.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Poplar.mat +172 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Poplar.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Example Scene/Floor.mat +392 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Example Scene/Floor.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Example Scene.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Fern.mat +202 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Fern.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs HighPoly.mat +265 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs HighPoly.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Needles.mat +267 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Needles.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palm.mat +232 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palm.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palmate.mat +250 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palmate.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Pine.mat +247 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Pine.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Poplar.mat +223 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Poplar.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate Outline.mat +262 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate Outline.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate.mat +281 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Stone Pine.mat +267 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Stone Pine.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Willow.mat +236 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Willow.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Oak.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Oak.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Old Oak.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Old Oak.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Palm.asset +500 -0
- package/Samples~/ExampleTemplates/Examples/Palm.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Pine 2.asset +387 -0
- package/Samples~/ExampleTemplates/Examples/Pine 2.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Pine.asset +405 -0
- package/Samples~/ExampleTemplates/Examples/Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Ponderossa Pine.asset +478 -0
- package/Samples~/ExampleTemplates/Examples/Ponderossa Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Poplar.asset +309 -0
- package/Samples~/ExampleTemplates/Examples/Poplar.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/ReflectionProbe-0.exr +0 -0
- package/Samples~/ExampleTemplates/Examples/ReflectionProbe-0.exr.meta +117 -0
- package/Samples~/ExampleTemplates/Examples/Small Pine.asset +273 -0
- package/Samples~/ExampleTemplates/Examples/Small Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Small Tree.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Small Tree.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_C.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_2_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_2_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_N.bmp +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_N.bmp.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_C.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_PSD.psd +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_PSD.psd.meta +76 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_Toon.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_Toon.png.meta +76 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_N.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_C.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_N.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_N.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Willow.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Willow.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples.meta +8 -0
- package/Samples~/ExampleTemplates/Examples.unity +12660 -0
- package/Samples~/ExampleTemplates/Examples.unity.meta +7 -0
- package/Samples~/ExampleTemplates.meta +8 -0
- package/Shaders/BarkShader.shadergraph +17215 -0
- package/Shaders/BarkShader.shadergraph.meta +10 -0
- package/Shaders/Editor/BarkEditor.cs +100 -0
- package/Shaders/Editor/BarkEditor.cs.meta +11 -0
- package/Shaders/Editor/LeafEditor.cs +173 -0
- package/Shaders/Editor/LeafEditor.cs.meta +11 -0
- package/Shaders/Editor.meta +8 -0
- package/Shaders/LeafShader.shadergraph +34803 -0
- package/Shaders/LeafShader.shadergraph.meta +10 -0
- package/Shaders/MTree.Shaders.asmdef +3 -0
- package/Shaders/MTree.Shaders.asmdef.meta +7 -0
- package/Shaders/leafFunctions.hlsl +201 -0
- package/Shaders/leafFunctions.hlsl.meta +7 -0
- package/Shaders/vertexFunc.hlsl +55 -0
- package/Shaders/vertexFunc.hlsl.meta +7 -0
- package/Shaders.meta +8 -0
- package/package.json +36 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "MTree.Editor",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"GUID:a17eaea2482276b43ac7a9cb9c9ec810"
|
|
6
|
+
],
|
|
7
|
+
"includePlatforms": [
|
|
8
|
+
"Editor"
|
|
9
|
+
],
|
|
10
|
+
"excludePlatforms": [],
|
|
11
|
+
"allowUnsafeCode": false,
|
|
12
|
+
"overrideReferences": false,
|
|
13
|
+
"precompiledReferences": [],
|
|
14
|
+
"autoReferenced": true,
|
|
15
|
+
"defineConstraints": [],
|
|
16
|
+
"versionDefines": [],
|
|
17
|
+
"noEngineReferences": false
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
|
|
4
|
+
public class MenuItems
|
|
5
|
+
{
|
|
6
|
+
[MenuItem("GameObject/3D Object/Create new Mtree...")]
|
|
7
|
+
private static void CreateNewMtree()
|
|
8
|
+
{
|
|
9
|
+
GameObject tree = new GameObject("New Mtree");
|
|
10
|
+
MtreeComponent mtree = tree.AddComponent<MtreeComponent>();
|
|
11
|
+
mtree.GenerateTree();
|
|
12
|
+
Selection.activeGameObject = tree;
|
|
13
|
+
if (SceneView.lastActiveSceneView != null)
|
|
14
|
+
{
|
|
15
|
+
tree.gameObject.transform.position = SceneView.lastActiveSceneView.pivot;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
[MenuItem("Window/Mtree/Add Mtree Global Wind Controller To Scene...")]
|
|
20
|
+
private static void CreateGlobalMtreeWindController()
|
|
21
|
+
{
|
|
22
|
+
GameObject WindController = new GameObject("Mtree Wind Controller");
|
|
23
|
+
WindController.AddComponent<WindZone>();
|
|
24
|
+
WindController.AddComponent<MtreeWind>();
|
|
25
|
+
if (SceneView.lastActiveSceneView != null)
|
|
26
|
+
{
|
|
27
|
+
WindController.transform.position = Vector3.zero;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
using UnityEditor;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
[CustomEditor(typeof(MtreeBezier))]
|
|
5
|
+
public class MtreeBezierInspector : Editor {
|
|
6
|
+
|
|
7
|
+
private const int stepsPerCurve = 10;
|
|
8
|
+
private const float directionScale = 0.5f;
|
|
9
|
+
private const float handleSize = 0.04f;
|
|
10
|
+
private const float pickSize = 0.06f;
|
|
11
|
+
private static Color[] modeColors = {
|
|
12
|
+
Color.white,
|
|
13
|
+
Color.blue,
|
|
14
|
+
Color.cyan
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
private MtreeBezier spline;
|
|
18
|
+
private Transform handleTransform;
|
|
19
|
+
private Quaternion handleRotation;
|
|
20
|
+
private int selectedIndex = -1;
|
|
21
|
+
|
|
22
|
+
private string DoBezier,DoLeaf;
|
|
23
|
+
public override void OnInspectorGUI () {
|
|
24
|
+
|
|
25
|
+
var gs = new GUIStyle();
|
|
26
|
+
gs.fontStyle = FontStyle.Bold;
|
|
27
|
+
|
|
28
|
+
spline = target as MtreeBezier;
|
|
29
|
+
GUILayout.Space(10);
|
|
30
|
+
EditorGUI.BeginChangeCheck();
|
|
31
|
+
EditorGUILayout.LabelField("MTree Addon",gs);
|
|
32
|
+
|
|
33
|
+
if(spline.MTreeDoBezier){
|
|
34
|
+
DoBezier = "Deactivate Bezier Mode";
|
|
35
|
+
}else{
|
|
36
|
+
DoBezier = "Activate Bezier Mode";
|
|
37
|
+
}
|
|
38
|
+
if(GUILayout.Button(DoBezier)){
|
|
39
|
+
Undo.RecordObject(spline,DoBezier);
|
|
40
|
+
spline.MTreeDoBezier = !spline.MTreeDoBezier;
|
|
41
|
+
EditorUtility.SetDirty(spline);
|
|
42
|
+
}
|
|
43
|
+
if (GUILayout.Button("Add Curve")) {
|
|
44
|
+
Undo.RecordObject(spline, "Add Curve");
|
|
45
|
+
spline.AddCurve();
|
|
46
|
+
EditorUtility.SetDirty(spline);
|
|
47
|
+
}
|
|
48
|
+
if(EditorGUI.EndChangeCheck()){
|
|
49
|
+
spline.GetComponent<MtreeComponent>().GenerateTree();
|
|
50
|
+
}
|
|
51
|
+
GUILayout.Space(10);
|
|
52
|
+
EditorGUI.BeginChangeCheck();
|
|
53
|
+
EditorGUILayout.LabelField("Branch / Leaf Directions",gs);
|
|
54
|
+
if(spline.MTreeLeafDirection){
|
|
55
|
+
DoLeaf = "Deactivate Leaf Direction Mode";
|
|
56
|
+
}else{
|
|
57
|
+
DoLeaf = "Activate Leaf Direction Mode";
|
|
58
|
+
}
|
|
59
|
+
if(GUILayout.Button(DoLeaf)){
|
|
60
|
+
Undo.RecordObject(spline,DoLeaf);
|
|
61
|
+
spline.MTreeLeafDirection = !spline.MTreeLeafDirection;
|
|
62
|
+
EditorUtility.SetDirty(spline);
|
|
63
|
+
}
|
|
64
|
+
spline.s_branchdirection = EditorGUILayout.Vector3Field("Branch Growth Direction",spline.s_branchdirection);
|
|
65
|
+
|
|
66
|
+
if(EditorGUI.EndChangeCheck()){
|
|
67
|
+
|
|
68
|
+
spline.s_branchdirection.x = Mathf.Clamp(spline.s_branchdirection.x,-1,1);
|
|
69
|
+
spline.s_branchdirection.y = Mathf.Clamp(spline.s_branchdirection.y,-1,1);
|
|
70
|
+
spline.s_branchdirection.z = Mathf.Clamp(spline.s_branchdirection.z,-1,1);
|
|
71
|
+
Undo.RecordObject(spline,"Branch Growth Direction");
|
|
72
|
+
spline.GetComponent<MtreeComponent>().GenerateTree();
|
|
73
|
+
EditorUtility.SetDirty(spline);
|
|
74
|
+
}
|
|
75
|
+
GUILayout.Space(10);
|
|
76
|
+
|
|
77
|
+
if (selectedIndex >= 0 && selectedIndex < spline.ControlPointCount) {
|
|
78
|
+
EditorGUILayout.LabelField("Bezier Position / Mode",gs);
|
|
79
|
+
DrawSelectedPointInspector();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private void DrawSelectedPointInspector() {
|
|
88
|
+
GUILayout.Label("Selected Point");
|
|
89
|
+
EditorGUI.BeginChangeCheck();
|
|
90
|
+
Vector3 point = EditorGUILayout.Vector3Field("Position", spline.GetControlPoint(selectedIndex));
|
|
91
|
+
if (EditorGUI.EndChangeCheck()) {
|
|
92
|
+
Undo.RecordObject(spline, "Move Point");
|
|
93
|
+
EditorUtility.SetDirty(spline);
|
|
94
|
+
spline.SetControlPoint(selectedIndex, point);
|
|
95
|
+
}
|
|
96
|
+
EditorGUI.BeginChangeCheck();
|
|
97
|
+
BezierControlPointMode mode = (BezierControlPointMode)EditorGUILayout.EnumPopup("Mode", spline.GetControlPointMode(selectedIndex));
|
|
98
|
+
if (EditorGUI.EndChangeCheck()) {
|
|
99
|
+
Undo.RecordObject(spline, "Change Point Mode");
|
|
100
|
+
spline.SetControlPointMode(selectedIndex, mode);
|
|
101
|
+
EditorUtility.SetDirty(spline);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private void OnSceneGUI () {
|
|
107
|
+
spline = target as MtreeBezier;
|
|
108
|
+
handleTransform = spline.transform;
|
|
109
|
+
handleRotation = Tools.pivotRotation == PivotRotation.Local ?
|
|
110
|
+
handleTransform.rotation : Quaternion.identity;
|
|
111
|
+
|
|
112
|
+
Vector3 p0 = ShowPoint(0);
|
|
113
|
+
if(spline.points.Length>3){
|
|
114
|
+
for (int i = 1; i < spline.ControlPointCount; i += 3) {
|
|
115
|
+
Vector3 p1 = ShowPoint(i);
|
|
116
|
+
Vector3 p2 = ShowPoint(i + 1);
|
|
117
|
+
Vector3 p3 = ShowPoint(i + 2);
|
|
118
|
+
|
|
119
|
+
Handles.color = Color.gray;
|
|
120
|
+
Handles.DrawLine(p0, p1);
|
|
121
|
+
Handles.DrawLine(p2, p3);
|
|
122
|
+
|
|
123
|
+
Handles.DrawBezier(p0, p3, p1, p2, Color.white, null, 2f);
|
|
124
|
+
p0 = p3;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
private Vector3 ShowPoint (int index) {
|
|
131
|
+
Vector3 point = handleTransform.TransformPoint(spline.GetControlPoint(index));
|
|
132
|
+
float size = HandleUtility.GetHandleSize(point);
|
|
133
|
+
if (index == 0) {
|
|
134
|
+
size *= 5;
|
|
135
|
+
}
|
|
136
|
+
if(index > 0 ){
|
|
137
|
+
size *= 3;
|
|
138
|
+
}
|
|
139
|
+
if(index % 3 == 1 || index % 3 == 2){
|
|
140
|
+
Handles.color = modeColors[(int)spline.GetControlPointMode(index)] * Color.blue;
|
|
141
|
+
}
|
|
142
|
+
if(index % 3 == 0){
|
|
143
|
+
Handles.color = modeColors[(int)spline.GetControlPointMode(index)] * Color.green;
|
|
144
|
+
}
|
|
145
|
+
if (Handles.Button(point, handleRotation, size * handleSize, size * pickSize, Handles.SphereHandleCap)) {
|
|
146
|
+
selectedIndex = index;
|
|
147
|
+
Repaint();
|
|
148
|
+
}
|
|
149
|
+
if (selectedIndex == index) {
|
|
150
|
+
EditorGUI.BeginChangeCheck();
|
|
151
|
+
|
|
152
|
+
point = Handles.DoPositionHandle(point, handleRotation);
|
|
153
|
+
if (EditorGUI.EndChangeCheck()) {
|
|
154
|
+
Undo.RecordObject(spline, "Move Point");
|
|
155
|
+
EditorUtility.SetDirty(spline);
|
|
156
|
+
spline.SetControlPoint(index, handleTransform.InverseTransformPoint(point));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return point;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
using Mtree;
|
|
4
|
+
using System;
|
|
5
|
+
using System.IO;
|
|
6
|
+
|
|
7
|
+
namespace Mtree
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
[CanEditMultipleObjects]
|
|
11
|
+
[CustomEditor(typeof(MtreeComponent))]
|
|
12
|
+
public class MtreeEditor : Editor
|
|
13
|
+
{
|
|
14
|
+
MtreeComponent tree;
|
|
15
|
+
private static string[] lodOptions = { "0", "1", "2", "3" };
|
|
16
|
+
private static string[] tabNames = { "Functions", "Quality", "Save as prefab" };
|
|
17
|
+
private int rectHeightMultiplier;
|
|
18
|
+
|
|
19
|
+
public float BB_GRP_Brightness = 1;
|
|
20
|
+
public float BB_GRP_TopCardPositon = 0.5f;
|
|
21
|
+
public int BB_GRP_hasTopCard = 1;
|
|
22
|
+
public int BB_GRP_isSingleSided = 1;
|
|
23
|
+
|
|
24
|
+
private void OnEnable()
|
|
25
|
+
{
|
|
26
|
+
tree = (MtreeComponent)target;
|
|
27
|
+
#if UNITY_2018_3_OR_NEWER
|
|
28
|
+
if (PrefabUtility.GetPrefabInstanceHandle(target) != null) // Prefabs with MtreeComponents should not be made as it tempers with the TreeFunctionAsset objects. Thus prefabs are deleted
|
|
29
|
+
{
|
|
30
|
+
DeletePefab();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
#else
|
|
34
|
+
if (PrefabUtility.GetPrefabObject(target) != null) // Prefabs with MtreeComponents should not be made as it tempers with the TreeFunctionAsset objects. Thus prefabs are deleted
|
|
35
|
+
{
|
|
36
|
+
DeletePefab();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
#endif
|
|
40
|
+
if (tree.tree == null && tree.MtreeVersion == Mtree.MtreeVariables.MtreeVersion)
|
|
41
|
+
{
|
|
42
|
+
UpdateTree();
|
|
43
|
+
}
|
|
44
|
+
rectHeightMultiplier = TreeFunctionAsset.height + TreeFunctionAsset.margin;
|
|
45
|
+
Undo.undoRedoPerformed += tree.UndoCallBack;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private void DeletePefab()
|
|
49
|
+
{
|
|
50
|
+
#if UNITY_2018_3_OR_NEWER
|
|
51
|
+
string prefabPath = AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabInstanceHandle(target));
|
|
52
|
+
AssetDatabase.DeleteAsset(prefabPath);
|
|
53
|
+
#else
|
|
54
|
+
string prefabPath = AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabObject(target));
|
|
55
|
+
AssetDatabase.DeleteAsset(prefabPath);
|
|
56
|
+
#endif
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public override void OnInspectorGUI()
|
|
60
|
+
{
|
|
61
|
+
if (IsMultiSelection()) // Editor to display when multiple trees are selected
|
|
62
|
+
{
|
|
63
|
+
DisplayMultiObjectsEditting();
|
|
64
|
+
return; // Not drawing the rest when multpile trees are selected
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
DisplayLodSelection();
|
|
68
|
+
|
|
69
|
+
SerializedProperty tabIndexProperty = serializedObject.FindProperty("tabIndex");
|
|
70
|
+
tabIndexProperty.intValue = GUILayout.Toolbar(tabIndexProperty.intValue, tabNames);
|
|
71
|
+
serializedObject.ApplyModifiedProperties();
|
|
72
|
+
|
|
73
|
+
switch (tabIndexProperty.intValue)
|
|
74
|
+
{
|
|
75
|
+
case 0:
|
|
76
|
+
DisplayTemplates();
|
|
77
|
+
DisplayFunctionsTab();
|
|
78
|
+
break;
|
|
79
|
+
case 1:
|
|
80
|
+
DisplayQualityTab();
|
|
81
|
+
break;
|
|
82
|
+
case 2:
|
|
83
|
+
DisplaySaveTab();
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
EditorGUILayout.LabelField("polycount: " + tree.polycount.ToString(), EditorStyles.boldLabel);
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private void DisplayTemplates()
|
|
93
|
+
{
|
|
94
|
+
EditorGUIUtility.labelWidth = 60;
|
|
95
|
+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
EditorGUILayout.BeginHorizontal();
|
|
99
|
+
|
|
100
|
+
EditorGUILayout.PropertyField(serializedObject.FindProperty("template"),new GUIContent("Template"), true);
|
|
101
|
+
serializedObject.ApplyModifiedProperties();
|
|
102
|
+
string SaveButton = "Save Template"; if (tree.template != null) SaveButton = "Override"; else SaveButton = "Save";
|
|
103
|
+
|
|
104
|
+
EditorGUI.BeginDisabledGroup(tree.template == null);
|
|
105
|
+
if (GUILayout.Button("Load Template"))
|
|
106
|
+
{
|
|
107
|
+
serializedObject.FindProperty("selectedFunctionIndex").intValue = 0;
|
|
108
|
+
serializedObject.FindProperty("template").objectReferenceValue = tree.template;
|
|
109
|
+
serializedObject.ApplyModifiedProperties();
|
|
110
|
+
|
|
111
|
+
tree.FromTemplate();
|
|
112
|
+
UpdateTree();
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
EditorGUI.EndDisabledGroup();
|
|
116
|
+
if(GUILayout.Button(SaveButton + " Template"))
|
|
117
|
+
{
|
|
118
|
+
if(SaveButton == "Override")
|
|
119
|
+
{
|
|
120
|
+
string templatePath = AssetDatabase.GetAssetPath(tree.template);
|
|
121
|
+
AssetDatabase.DeleteAsset(templatePath);
|
|
122
|
+
tree.template = TreeTemplate.CreateFromFunctions(tree.treeFunctionsAssets, templatePath);
|
|
123
|
+
|
|
124
|
+
serializedObject.FindProperty("template").objectReferenceValue = tree.template;
|
|
125
|
+
serializedObject.ApplyModifiedProperties();
|
|
126
|
+
}
|
|
127
|
+
if (SaveButton == "Save")
|
|
128
|
+
{
|
|
129
|
+
string templatePath = EditorUtility.SaveFilePanelInProject("Save Template", tree.name + ".asset", "asset", "");
|
|
130
|
+
if (templatePath.Length > 0)
|
|
131
|
+
{
|
|
132
|
+
tree.template = TreeTemplate.CreateFromFunctions(tree.treeFunctionsAssets, templatePath);
|
|
133
|
+
serializedObject.FindProperty("template").objectReferenceValue = tree.template;
|
|
134
|
+
serializedObject.ApplyModifiedPropertiesWithoutUndo();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
EditorGUILayout.EndHorizontal();
|
|
139
|
+
|
|
140
|
+
EditorGUILayout.EndVertical();
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private void DisplayLodSelection()
|
|
145
|
+
{
|
|
146
|
+
EditorGUI.BeginChangeCheck();
|
|
147
|
+
SerializedProperty lodIndexProp = serializedObject.FindProperty("LodIndex");
|
|
148
|
+
lodIndexProp.intValue = EditorGUILayout.Popup("LOD", lodIndexProp.intValue, lodOptions);
|
|
149
|
+
if (EditorGUI.EndChangeCheck())
|
|
150
|
+
{
|
|
151
|
+
serializedObject.ApplyModifiedProperties();
|
|
152
|
+
UpdateTree();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private void DisplayQualityTab()
|
|
157
|
+
{
|
|
158
|
+
EditorGUI.BeginChangeCheck();
|
|
159
|
+
tree.LODs[tree.LodIndex].DrawProperties();
|
|
160
|
+
if (EditorGUI.EndChangeCheck())
|
|
161
|
+
UpdateTree();
|
|
162
|
+
}
|
|
163
|
+
#if UNITY_2018_3_OR_NEWER
|
|
164
|
+
|
|
165
|
+
private void SetupLegacyMode()
|
|
166
|
+
{
|
|
167
|
+
if (Utils.GetCurrentPipeline() == "hdrp")
|
|
168
|
+
{
|
|
169
|
+
|
|
170
|
+
tree.isHDRP = true;
|
|
171
|
+
tree.hdrpAsset = UnityEngine.Rendering.GraphicsSettings.defaultRenderPipeline;
|
|
172
|
+
UnityEngine.Rendering.GraphicsSettings.defaultRenderPipeline = null;
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
private void SetupHDRPMode(){
|
|
177
|
+
if(tree.isHDRP){
|
|
178
|
+
UnityEngine.Rendering.GraphicsSettings.defaultRenderPipeline = tree.hdrpAsset;
|
|
179
|
+
tree.isHDRP = false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
private void SetupLegacyMaterials(GameObject t){
|
|
183
|
+
if(tree.isHDRP)
|
|
184
|
+
{
|
|
185
|
+
foreach(Material m in t.GetComponent<MeshRenderer>().sharedMaterials){
|
|
186
|
+
if(m.shader.name == "Mtree/SRP/Leafs HDRP")
|
|
187
|
+
m.shader = Shader.Find("Mtree/Leafs");
|
|
188
|
+
if(m.shader.name == "Mtree/SRP/Bark HDRP")
|
|
189
|
+
m.shader = Shader.Find("Mtree/Bark");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
private void SetupHDRPMaterials(GameObject t){
|
|
195
|
+
if(tree.isHDRP){
|
|
196
|
+
|
|
197
|
+
foreach(Material m in t.GetComponent<MeshRenderer>().sharedMaterials){
|
|
198
|
+
if(m.shader.name == "Mtree/Leafs")
|
|
199
|
+
m.shader = Shader.Find("Mtree/SRP/Leafs HDRP");
|
|
200
|
+
if(m.shader.name == "Mtree/Bark")
|
|
201
|
+
m.shader = Shader.Find("Mtree/SRP/Bark HDRP");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
#endif
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
private void DisplaySaveTab()
|
|
209
|
+
{
|
|
210
|
+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
|
211
|
+
EditorGUILayout.BeginHorizontal();
|
|
212
|
+
EditorGUILayout.PropertyField(serializedObject.FindProperty("saveTreeFolder"), new GUIContent("Save folder"));
|
|
213
|
+
if (GUILayout.Button("Find folder"))
|
|
214
|
+
{
|
|
215
|
+
string path = EditorUtility.OpenFolderPanel("save tree location", "Assets", "Assets");
|
|
216
|
+
path = "Assets" + path.Substring(Application.dataPath.Length);
|
|
217
|
+
serializedObject.FindProperty("saveTreeFolder").stringValue = path;
|
|
218
|
+
AssetDatabase.Refresh();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
EditorGUILayout.EndHorizontal();
|
|
223
|
+
tree.gameObject.name = EditorGUILayout.TextField("name", tree.gameObject.name);
|
|
224
|
+
EditorGUILayout.Space();
|
|
225
|
+
EditorGUILayout.BeginVertical("Box");
|
|
226
|
+
EditorGUILayout.LabelField("Billboard Settings");
|
|
227
|
+
serializedObject.FindProperty("BB_Brightness").floatValue = EditorGUILayout.Slider("Brightness",serializedObject.FindProperty("BB_Brightness").floatValue, 0, 3);
|
|
228
|
+
serializedObject.FindProperty("BB_isSingleSided").intValue = GUILayout.Toolbar(serializedObject.FindProperty("BB_isSingleSided").intValue, new string[] { "Double Sided", "Single Sided" });
|
|
229
|
+
serializedObject.FindProperty("BB_hasTopCard").intValue = GUILayout.Toolbar(serializedObject.FindProperty("BB_hasTopCard").intValue, new string[] {"No Top Card","Has Top Card"});
|
|
230
|
+
if (tree.BB_hasTopCard == 1)
|
|
231
|
+
serializedObject.FindProperty("BB_TopCardPositon").floatValue = EditorGUILayout.Slider("Top Card Positon", serializedObject.FindProperty("BB_TopCardPositon").floatValue, 0, 1);
|
|
232
|
+
serializedObject.ApplyModifiedProperties();
|
|
233
|
+
EditorGUILayout.EndVertical();
|
|
234
|
+
if (GUILayout.Button("Save as Prefab")){
|
|
235
|
+
#if UNITY_2018_3_OR_NEWER
|
|
236
|
+
SetupLegacyMode();
|
|
237
|
+
SetupLegacyMaterials(tree.gameObject);
|
|
238
|
+
tree.SaveAsPrefab(false,tree.isHDRP);
|
|
239
|
+
SetupHDRPMaterials(tree.gameObject);
|
|
240
|
+
SetupHDRPMode();
|
|
241
|
+
#else
|
|
242
|
+
tree.SaveAsPrefab(false,false);
|
|
243
|
+
#endif
|
|
244
|
+
}
|
|
245
|
+
EditorGUILayout.EndVertical();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
private void DisplayMultiObjectsEditting()
|
|
249
|
+
{
|
|
250
|
+
//EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
|
251
|
+
//EditorGUILayout.BeginHorizontal();
|
|
252
|
+
//string saveTreeFolder = EditorGUILayout.TextField("Save Folder", tree.saveTreeFolder);
|
|
253
|
+
//if (GUILayout.Button("Find folder"))
|
|
254
|
+
//{
|
|
255
|
+
// string path = EditorUtility.OpenFolderPanel("save tree location", "Assets", "Assets");
|
|
256
|
+
// if (path.Length > 0)
|
|
257
|
+
// {
|
|
258
|
+
// path = "Assets" + path.Substring(Application.dataPath.Length);
|
|
259
|
+
// saveTreeFolder = path;
|
|
260
|
+
// foreach (MtreeComponent t in Array.ConvertAll(targets, item => (MtreeComponent)item))
|
|
261
|
+
// {
|
|
262
|
+
// SerializedObject obj = new SerializedObject(t);
|
|
263
|
+
// obj.FindProperty("saveTreeFolder").stringValue = saveTreeFolder;
|
|
264
|
+
// obj.ApplyModifiedProperties();
|
|
265
|
+
// }
|
|
266
|
+
// AssetDatabase.Refresh();
|
|
267
|
+
// }
|
|
268
|
+
//}
|
|
269
|
+
//EditorGUILayout.EndHorizontal();
|
|
270
|
+
|
|
271
|
+
//EditorGUILayout.BeginVertical("Box");
|
|
272
|
+
//EditorGUILayout.LabelField("Billboard Settings");
|
|
273
|
+
//BB_GRP_Brightness = EditorGUILayout.Slider("Brightness", BB_GRP_Brightness,0,3);
|
|
274
|
+
//BB_GRP_isSingleSided = GUILayout.Toolbar(BB_GRP_isSingleSided, new string[] { "Double Sided", "Single Sided" });
|
|
275
|
+
//BB_GRP_isSingleSided = GUILayout.Toolbar(BB_GRP_hasTopCard, new string[] { "No Top Card", "Has Top Card" });
|
|
276
|
+
//if (BB_GRP_hasTopCard == 1)
|
|
277
|
+
// BB_GRP_TopCardPositon = EditorGUILayout.Slider("Top Card Positon", BB_GRP_TopCardPositon, 0, 1);
|
|
278
|
+
//EditorGUILayout.EndVertical();
|
|
279
|
+
//if (GUILayout.Button("Save all as Prefabs"))
|
|
280
|
+
//{
|
|
281
|
+
// saveTreeFolder = tree.saveTreeFolder;
|
|
282
|
+
// foreach (MtreeComponent t in Array.ConvertAll(targets, item => (MtreeComponent)item))
|
|
283
|
+
// {
|
|
284
|
+
// t.BB_Brightness = BB_GRP_Brightness;
|
|
285
|
+
// t.BB_isSingleSided = BB_GRP_isSingleSided;
|
|
286
|
+
// t.BB_hasTopCard = BB_GRP_hasTopCard;
|
|
287
|
+
// t.BB_TopCardPositon = BB_GRP_TopCardPositon;
|
|
288
|
+
// t.SaveAsPrefab(groupedSave: true);
|
|
289
|
+
// }
|
|
290
|
+
// UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(saveTreeFolder, typeof(UnityEngine.Object));
|
|
291
|
+
// // Select the object in the project folder
|
|
292
|
+
// Selection.activeObject = obj;
|
|
293
|
+
// // Also flash the folder yellow to highlight it
|
|
294
|
+
// EditorGUIUtility.PingObject(obj);
|
|
295
|
+
//}
|
|
296
|
+
//EditorGUILayout.EndVertical();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private void DisplayFunctionsTab()
|
|
300
|
+
{
|
|
301
|
+
EditorGUIUtility.labelWidth = 135;
|
|
302
|
+
int functionCount = tree.treeFunctionsAssets.Count; // Used in multiple for loops
|
|
303
|
+
|
|
304
|
+
EditorGUI.BeginDisabledGroup(tree.treeFunctionsAssets[tree.selectedFunctionIndex].name == "Leaves");
|
|
305
|
+
if (GUILayout.Button("Add function"))
|
|
306
|
+
{
|
|
307
|
+
GenericMenu addFunctionMenu = new GenericMenu();
|
|
308
|
+
if (tree.selectedFunctionIndex == 0)
|
|
309
|
+
addFunctionMenu.AddItem(new GUIContent("Add Roots"), false, tree.AddTreeFunction<RootsFunction>);
|
|
310
|
+
addFunctionMenu.AddItem(new GUIContent("Add Branches"), false, tree.AddTreeFunction<BranchFunction>);
|
|
311
|
+
addFunctionMenu.AddItem(new GUIContent("Add Leafs"), false, tree.AddTreeFunction<LeafFunction>);
|
|
312
|
+
addFunctionMenu.AddItem(new GUIContent("Split"), false, tree.AddTreeFunction<SplitFunction>);
|
|
313
|
+
addFunctionMenu.AddItem(new GUIContent("Grow"), false, tree.AddTreeFunction<GrowFunction>);
|
|
314
|
+
addFunctionMenu.ShowAsContext();
|
|
315
|
+
}
|
|
316
|
+
EditorGUI.EndDisabledGroup();
|
|
317
|
+
|
|
318
|
+
int rectHeight = functionCount * rectHeightMultiplier; // get the height of the drawing window inside inspector
|
|
319
|
+
Rect rect = GUILayoutUtility.GetRect(10, 1000, rectHeight, rectHeight); // Create drawing window
|
|
320
|
+
Event e = Event.current; // Get current event
|
|
321
|
+
|
|
322
|
+
int heighIndex = 0;
|
|
323
|
+
tree.treeFunctionsAssets[0].UpdateRectRec(ref heighIndex, 0);
|
|
324
|
+
|
|
325
|
+
if (e.type == EventType.MouseDown && e.button == 0) // If mouse button is pressed, get button pressed and act accordingly
|
|
326
|
+
{
|
|
327
|
+
for (int i = 0; i < functionCount; i++)
|
|
328
|
+
{
|
|
329
|
+
TreeFunctionAsset tf = tree.treeFunctionsAssets[i];
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
if (tf.rect.Contains(e.mousePosition - rect.position))
|
|
333
|
+
{
|
|
334
|
+
if (tf.deleteRect.Contains(e.mousePosition - rect.position))
|
|
335
|
+
{
|
|
336
|
+
tree.RemoveFunction(tf);
|
|
337
|
+
UpdateTree();
|
|
338
|
+
}
|
|
339
|
+
else
|
|
340
|
+
{
|
|
341
|
+
serializedObject.FindProperty("selectedFunctionIndex").intValue = i;
|
|
342
|
+
serializedObject.ApplyModifiedProperties();
|
|
343
|
+
}
|
|
344
|
+
GUIUtility.ExitGUI();
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if(e.type == EventType.MouseDown && e.button == 1){
|
|
350
|
+
for(int i = 0; i<functionCount;i++){
|
|
351
|
+
TreeFunctionAsset tf = tree.treeFunctionsAssets[i];
|
|
352
|
+
if(tf.rect.Contains(e.mousePosition - rect.position)){
|
|
353
|
+
var menu = new GenericMenu();
|
|
354
|
+
if(!tf.name.Contains("Trunk"))
|
|
355
|
+
menu.AddItem(new GUIContent("Copy Tree Function"),false,SaveTF);
|
|
356
|
+
else
|
|
357
|
+
menu.AddDisabledItem(new GUIContent("Copy Tree Function"));
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
if(tree.savedFunction != null && tree.treeFunctionsAssets[tree.selectedFunctionIndex].name != "Leaves")
|
|
361
|
+
menu.AddItem(new GUIContent("Paste Tree Function"),false,InsertTF);
|
|
362
|
+
else
|
|
363
|
+
menu.AddDisabledItem(new GUIContent("Paste Tree Function"));
|
|
364
|
+
|
|
365
|
+
menu.ShowAsContext();
|
|
366
|
+
e.Use();
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
GUI.BeginClip(rect);
|
|
372
|
+
|
|
373
|
+
for (int i = 0; i < tree.treeFunctionsAssets.Count; i++)
|
|
374
|
+
tree.treeFunctionsAssets[i].DrawFunction(i == tree.selectedFunctionIndex, i>0);
|
|
375
|
+
|
|
376
|
+
GUI.EndClip();
|
|
377
|
+
|
|
378
|
+
EditorGUI.BeginChangeCheck();
|
|
379
|
+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
|
380
|
+
|
|
381
|
+
if (GUILayout.Button("Randomize tree"))
|
|
382
|
+
{
|
|
383
|
+
tree.RandomizeTree();
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
TreeFunctionAsset selectedFunction = tree.treeFunctionsAssets[tree.selectedFunctionIndex];
|
|
387
|
+
selectedFunction.DrawProperties();
|
|
388
|
+
|
|
389
|
+
EditorGUILayout.EndVertical();
|
|
390
|
+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
|
391
|
+
var gs = new GUIStyle();
|
|
392
|
+
gs.richText = true;
|
|
393
|
+
EditorGUILayout.LabelField("Wind");
|
|
394
|
+
EditorGUILayout.Slider(serializedObject.FindProperty("VColBarkModifier"),0.1f,5,new GUIContent("Bark Multiplier"));
|
|
395
|
+
EditorGUILayout.Slider(serializedObject.FindProperty("VColLeafModifier"),0.1f,5,new GUIContent("Leaf Multiplier"));
|
|
396
|
+
serializedObject.ApplyModifiedProperties();
|
|
397
|
+
EditorGUILayout.EndVertical();
|
|
398
|
+
if (EditorGUI.EndChangeCheck())
|
|
399
|
+
UpdateTree();
|
|
400
|
+
EditorGUILayout.Space ();
|
|
401
|
+
BezierMode ();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
void SaveTF(){
|
|
405
|
+
tree.savedFunction = tree.treeFunctionsAssets[tree.selectedFunctionIndex];
|
|
406
|
+
}
|
|
407
|
+
void InsertTF(){
|
|
408
|
+
var tf = Instantiate(tree.savedFunction);
|
|
409
|
+
tf.parent = tree.treeFunctionsAssets[tree.selectedFunctionIndex];
|
|
410
|
+
tf.Init(tree.treeFunctionsAssets[tree.selectedFunctionIndex],true);
|
|
411
|
+
tree.treeFunctionsAssets.Add(tf);
|
|
412
|
+
UpdateTree();
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
private void UpdateTree()
|
|
416
|
+
{
|
|
417
|
+
tree.GenerateTree();
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
private bool IsMultiSelection()
|
|
421
|
+
{
|
|
422
|
+
return targets.Length > 1;
|
|
423
|
+
}
|
|
424
|
+
private void BezierMode(){
|
|
425
|
+
EditorGUI.BeginChangeCheck ();
|
|
426
|
+
serializedObject.FindProperty("hasBezier").intValue = GUILayout.Toolbar(serializedObject.FindProperty("hasBezier").intValue,new string[]{"Use Mtree","Use Bezier"});
|
|
427
|
+
serializedObject.ApplyModifiedProperties();
|
|
428
|
+
if(EditorGUI.EndChangeCheck())
|
|
429
|
+
tree.BezierManager();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
}
|