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,92 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
#if UNITY_EDITOR
|
|
5
|
+
using UnityEditor;
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
namespace Mtree
|
|
9
|
+
{
|
|
10
|
+
public class BranchFunction : TreeFunctionAsset
|
|
11
|
+
{
|
|
12
|
+
public float length = 7f;
|
|
13
|
+
public AnimationCurve lengthCurve = AnimationCurve.Linear(0, 1, 1, .8f);
|
|
14
|
+
public float resolution = 1f;
|
|
15
|
+
public int number = 30;
|
|
16
|
+
public float splitProba = .1f;
|
|
17
|
+
public float angle = .7f;
|
|
18
|
+
public AnimationCurve shape = AnimationCurve.EaseInOut(0, 1, 1, .1f);
|
|
19
|
+
public AnimationCurve splitProbaCurve = AnimationCurve.Linear(0, .5f, 1, 1f);
|
|
20
|
+
public float radius = .6f;
|
|
21
|
+
public float randomness = .25f;
|
|
22
|
+
public float upAttraction = .5f;
|
|
23
|
+
public float start = .2f;
|
|
24
|
+
public float gravityStrength = .1f;
|
|
25
|
+
public bool obstacleAvoidance = false;
|
|
26
|
+
|
|
27
|
+
public override void Init(TreeFunctionAsset parent, bool preserveSettings = false)
|
|
28
|
+
{
|
|
29
|
+
base.Init(parent);
|
|
30
|
+
name = "Branch";
|
|
31
|
+
|
|
32
|
+
if (parent != null && !(parent is TrunkFunction) && !preserveSettings)
|
|
33
|
+
{
|
|
34
|
+
length = 3;
|
|
35
|
+
start = .3f;
|
|
36
|
+
angle = .4f;
|
|
37
|
+
number = 120;
|
|
38
|
+
resolution = 1;
|
|
39
|
+
splitProba = .3f;
|
|
40
|
+
radius = .8f;
|
|
41
|
+
shape = AnimationCurve.Linear(0, 1, 1, .1f);
|
|
42
|
+
randomness = .4f;
|
|
43
|
+
gravityStrength = 1f;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public override void DrawProperties()
|
|
48
|
+
{
|
|
49
|
+
#if UNITY_EDITOR
|
|
50
|
+
|
|
51
|
+
SerializedObject obj = new SerializedObject(this);
|
|
52
|
+
|
|
53
|
+
EditorGUILayout.PropertyField(obj.FindProperty("seed"), new GUIContent("Seed"));
|
|
54
|
+
Utils.BoundedIntProperty(obj.FindProperty("number"), new GUIContent("Number"), 0);
|
|
55
|
+
|
|
56
|
+
EditorGUILayout.BeginHorizontal();
|
|
57
|
+
Utils.BoundedFloatProperty(obj.FindProperty("length"), new GUIContent("Length"), 0.001f);
|
|
58
|
+
EditorGUILayout.PropertyField(obj.FindProperty("lengthCurve"), new GUIContent(""));
|
|
59
|
+
EditorGUILayout.EndHorizontal();
|
|
60
|
+
|
|
61
|
+
Utils.BoundedFloatProperty(obj.FindProperty("resolution"), new GUIContent("Resolution"), 0.01f);
|
|
62
|
+
EditorGUILayout.Slider(obj.FindProperty("randomness"), 0, 1, new GUIContent("Randomness"));
|
|
63
|
+
EditorGUILayout.Slider(obj.FindProperty("radius"), 0.001f, 1, new GUIContent("Radius"));
|
|
64
|
+
EditorGUILayout.PropertyField(obj.FindProperty("shape"), new GUIContent("Shape"));
|
|
65
|
+
|
|
66
|
+
EditorGUILayout.BeginHorizontal();
|
|
67
|
+
EditorGUILayout.Slider(obj.FindProperty("splitProba"), 0, 1, new GUIContent("Split proba"));
|
|
68
|
+
EditorGUILayout.PropertyField(obj.FindProperty("splitProbaCurve"), new GUIContent(""));
|
|
69
|
+
EditorGUILayout.EndHorizontal();
|
|
70
|
+
|
|
71
|
+
EditorGUILayout.Slider(obj.FindProperty("angle"), 0, 1, new GUIContent("Angle"));
|
|
72
|
+
EditorGUILayout.PropertyField(obj.FindProperty("upAttraction"), new GUIContent("Up attraction"));
|
|
73
|
+
EditorGUILayout.PropertyField(obj.FindProperty("gravityStrength"), new GUIContent("Gravity Strength"));
|
|
74
|
+
EditorGUILayout.Slider(obj.FindProperty("start"), 0, 1, new GUIContent("Start"));
|
|
75
|
+
EditorGUILayout.PropertyField(obj.FindProperty("obstacleAvoidance"), new GUIContent("React to scene colliders"));
|
|
76
|
+
|
|
77
|
+
obj.ApplyModifiedProperties();
|
|
78
|
+
|
|
79
|
+
#endif
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public override void Execute(MTree tree)
|
|
83
|
+
{
|
|
84
|
+
base.Execute(tree);
|
|
85
|
+
|
|
86
|
+
Random.InitState(seed);
|
|
87
|
+
int selection = parent == null ? 0 : parent.id;
|
|
88
|
+
tree.AddBranches(selection, length, lengthCurve, resolution, number, splitProba, splitProbaCurve, angle
|
|
89
|
+
, randomness, shape, radius, upAttraction, id, start, gravityStrength, 0f, 0.001f, obstacleAvoidance);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
#if UNITY_EDITOR
|
|
5
|
+
using UnityEditor;
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
namespace Mtree
|
|
9
|
+
{
|
|
10
|
+
public class GrowFunction : TreeFunctionAsset
|
|
11
|
+
{
|
|
12
|
+
public float length = 10f;
|
|
13
|
+
public AnimationCurve lengthCurve = AnimationCurve.Linear(0, 1, 1, .8f);
|
|
14
|
+
public float resolution = 1f;
|
|
15
|
+
public float splitProba = .1f;
|
|
16
|
+
public float splitAngle = .5f;
|
|
17
|
+
public int maxSplits = 2;
|
|
18
|
+
public AnimationCurve radius = AnimationCurve.EaseInOut(0, 1, 1, .1f);
|
|
19
|
+
public AnimationCurve splitProbaCurve = AnimationCurve.Linear(0, .5f, 1, 1f);
|
|
20
|
+
public float splitRadius = .8f;
|
|
21
|
+
public float randomness = .25f;
|
|
22
|
+
public float upAttraction = .5f;
|
|
23
|
+
public float gravityStrength = .1f;
|
|
24
|
+
public bool obstacleAvoidance = false;
|
|
25
|
+
|
|
26
|
+
public override void Init(TreeFunctionAsset parent, bool preserveSettings = false)
|
|
27
|
+
{
|
|
28
|
+
base.Init(parent);
|
|
29
|
+
name = "Grow";
|
|
30
|
+
if (!preserveSettings)
|
|
31
|
+
{
|
|
32
|
+
Keyframe[] keys = new Keyframe[2] { new Keyframe(0f, 1f, 0f, 0f), new Keyframe(1f, 0f, -.5f, -1f) };
|
|
33
|
+
radius = new AnimationCurve(keys);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public override void DrawProperties()
|
|
38
|
+
{
|
|
39
|
+
#if UNITY_EDITOR
|
|
40
|
+
|
|
41
|
+
SerializedObject obj = new SerializedObject(this);
|
|
42
|
+
|
|
43
|
+
EditorGUILayout.PropertyField(obj.FindProperty("seed"), new GUIContent("Seed"));
|
|
44
|
+
|
|
45
|
+
EditorGUILayout.BeginHorizontal();
|
|
46
|
+
Utils.BoundedFloatProperty(obj.FindProperty("length"), new GUIContent("Length"), 0.001f);
|
|
47
|
+
EditorGUILayout.PropertyField(obj.FindProperty("lengthCurve"), new GUIContent(""));
|
|
48
|
+
EditorGUILayout.EndHorizontal();
|
|
49
|
+
|
|
50
|
+
Utils.BoundedFloatProperty(obj.FindProperty("resolution"), new GUIContent("Resolution"), 0.01f);
|
|
51
|
+
|
|
52
|
+
EditorGUILayout.BeginHorizontal();
|
|
53
|
+
EditorGUILayout.Slider(obj.FindProperty("splitProba"), 0, 1, new GUIContent("Split proba"));
|
|
54
|
+
EditorGUILayout.PropertyField(obj.FindProperty("splitProbaCurve"), new GUIContent(""));
|
|
55
|
+
EditorGUILayout.EndHorizontal();
|
|
56
|
+
|
|
57
|
+
EditorGUILayout.Slider(obj.FindProperty("splitAngle"), 0, 2, new GUIContent("Split Angle"));
|
|
58
|
+
EditorGUILayout.PropertyField(obj.FindProperty("radius"), new GUIContent("Shape"));
|
|
59
|
+
EditorGUILayout.Slider(obj.FindProperty("splitRadius"), .5f, .999f, new GUIContent("Split Radius"));
|
|
60
|
+
EditorGUILayout.IntSlider(obj.FindProperty("maxSplits"), 2, 4, new GUIContent("Max splits at a time"));
|
|
61
|
+
EditorGUILayout.Slider(obj.FindProperty("randomness"), 0, 1, new GUIContent("Randomness"));
|
|
62
|
+
EditorGUILayout.Slider(obj.FindProperty("upAttraction"), 0, 1, new GUIContent("Up attraction"));
|
|
63
|
+
EditorGUILayout.PropertyField(obj.FindProperty("gravityStrength"), new GUIContent("Gravity Strength"));
|
|
64
|
+
EditorGUILayout.PropertyField(obj.FindProperty("obstacleAvoidance"), new GUIContent("React to scene colliders"));
|
|
65
|
+
|
|
66
|
+
obj.ApplyModifiedProperties();
|
|
67
|
+
|
|
68
|
+
#endif
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public override void Execute(MTree tree)
|
|
72
|
+
{
|
|
73
|
+
base.Execute(tree);
|
|
74
|
+
|
|
75
|
+
Random.InitState(seed);
|
|
76
|
+
int selection = parent == null ? 0 : parent.id;
|
|
77
|
+
tree.Grow(length, lengthCurve, resolution, splitProba, splitProbaCurve, splitAngle, maxSplits, selection
|
|
78
|
+
, id, randomness, radius, splitRadius, upAttraction, gravityStrength, 0f, 0.001f, obstacleAvoidance);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
#if UNITY_EDITOR
|
|
5
|
+
using UnityEditor;
|
|
6
|
+
#endif
|
|
7
|
+
using System.Linq;
|
|
8
|
+
namespace Mtree
|
|
9
|
+
{
|
|
10
|
+
public class LeafFunction : TreeFunctionAsset
|
|
11
|
+
{
|
|
12
|
+
public int leafType = 4;
|
|
13
|
+
public static string[] leafTypesNames = { "cross", "diamond cross", "diamond", "long", "plane", "Procedural", "custom" };
|
|
14
|
+
public int number = 250;
|
|
15
|
+
public Mesh customLeafMesh;
|
|
16
|
+
public float maxRadius = .25f;
|
|
17
|
+
public float size = 2f;
|
|
18
|
+
public bool overrideNormals = true;
|
|
19
|
+
public float minWeight = .2f;
|
|
20
|
+
public float maxWeight = .5f;
|
|
21
|
+
public float length = 2f;
|
|
22
|
+
public AnimationCurve lengthCurve = AnimationCurve.Linear(0, 1, 1, 0.5f);
|
|
23
|
+
public int uLoops = 2;
|
|
24
|
+
public float resolution = 1f;
|
|
25
|
+
public float gravityStrength = 1f;
|
|
26
|
+
|
|
27
|
+
public override void Init(TreeFunctionAsset parent, bool preserveSettings = false)
|
|
28
|
+
{
|
|
29
|
+
base.Init(parent);
|
|
30
|
+
name = "Leaves";
|
|
31
|
+
customLeafMesh = null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#if UNITY_EDITOR
|
|
35
|
+
public override void DrawProperties()
|
|
36
|
+
{
|
|
37
|
+
|
|
38
|
+
SerializedObject obj = new SerializedObject(this);
|
|
39
|
+
|
|
40
|
+
EditorGUILayout.PropertyField(obj.FindProperty("seed"), new GUIContent("Seed"));
|
|
41
|
+
|
|
42
|
+
SerializedProperty leafTypeProp = obj.FindProperty("leafType");
|
|
43
|
+
leafTypeProp.intValue = EditorGUILayout.Popup(leafTypeProp.intValue, leafTypesNames);
|
|
44
|
+
|
|
45
|
+
if (leafTypeProp.intValue == 6)
|
|
46
|
+
EditorGUILayout.PropertyField(obj.FindProperty("customLeafMesh"), new GUIContent("Leaf mesh"));
|
|
47
|
+
|
|
48
|
+
Utils.BoundedIntProperty(obj.FindProperty("number"), new GUIContent("Number"), 0);
|
|
49
|
+
EditorGUILayout.PropertyField(obj.FindProperty("size"), new GUIContent("Size"));
|
|
50
|
+
EditorGUILayout.Slider(obj.FindProperty("maxRadius"), 0.001f, 1, "Max branch radius");
|
|
51
|
+
|
|
52
|
+
SerializedProperty minWeihtProp = obj.FindProperty("minWeight");
|
|
53
|
+
SerializedProperty maxWeihtProp = obj.FindProperty("maxWeight");
|
|
54
|
+
float minTmp = minWeihtProp.floatValue;
|
|
55
|
+
float maxTmp = maxWeihtProp.floatValue;
|
|
56
|
+
EditorGUILayout.MinMaxSlider("leafs weight", ref minTmp, ref maxTmp, -1, 1);
|
|
57
|
+
minWeihtProp.floatValue = minTmp;
|
|
58
|
+
maxWeihtProp.floatValue = maxTmp;
|
|
59
|
+
|
|
60
|
+
EditorGUILayout.PropertyField(obj.FindProperty("overrideNormals"), new GUIContent("Override normals"));
|
|
61
|
+
if (leafTypeProp.intValue == 5)
|
|
62
|
+
{
|
|
63
|
+
EditorGUILayout.PropertyField(obj.FindProperty("length"), new GUIContent("Length multiplier"));
|
|
64
|
+
EditorGUILayout.PropertyField(obj.FindProperty("lengthCurve"), new GUIContent("Length"));
|
|
65
|
+
Utils.BoundedFloatProperty(obj.FindProperty("resolution"), "resolution", 0.001f);
|
|
66
|
+
EditorGUILayout.IntSlider(obj.FindProperty("uLoops"), 2, 5, new GUIContent("Middle segments"));
|
|
67
|
+
EditorGUILayout.PropertyField(obj.FindProperty("gravityStrength"), new GUIContent("Gravity strength"));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
obj.ApplyModifiedProperties();
|
|
71
|
+
}
|
|
72
|
+
#endif
|
|
73
|
+
|
|
74
|
+
public override void Execute(MTree tree)
|
|
75
|
+
{
|
|
76
|
+
base.Execute(tree);
|
|
77
|
+
|
|
78
|
+
Random.InitState(seed);
|
|
79
|
+
int selection = parent == null ? 0 : parent.id;
|
|
80
|
+
bool procedural = leafType == 5;
|
|
81
|
+
|
|
82
|
+
Mesh[] leafMeshes = null;
|
|
83
|
+
switch (leafType)
|
|
84
|
+
{
|
|
85
|
+
case 0:
|
|
86
|
+
leafMeshes = new Mesh[] { Resources.LoadAll<Mesh>("Mtree/branches")[0] };
|
|
87
|
+
break;
|
|
88
|
+
case 1:
|
|
89
|
+
leafMeshes = new Mesh[] { Resources.LoadAll<Mesh>("Mtree/branches")[1] };
|
|
90
|
+
break;
|
|
91
|
+
case 2:
|
|
92
|
+
leafMeshes = new Mesh[] { Resources.LoadAll<Mesh>("Mtree/branches")[2], Resources.LoadAll<Mesh>("Mtree/branches")[3] };
|
|
93
|
+
break;
|
|
94
|
+
case 3:
|
|
95
|
+
leafMeshes = new Mesh[] { Resources.LoadAll<Mesh>("Mtree/branches")[4], Resources.LoadAll<Mesh>("Mtree/branches")[5] };
|
|
96
|
+
break;
|
|
97
|
+
case 4:
|
|
98
|
+
leafMeshes = new Mesh[] { Resources.LoadAll<Mesh>("Mtree/branches")[6] };
|
|
99
|
+
break;
|
|
100
|
+
case 5:
|
|
101
|
+
leafMeshes = null;
|
|
102
|
+
break;
|
|
103
|
+
case 6:
|
|
104
|
+
leafMeshes = new Mesh[] { customLeafMesh };
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
tree.AddLeafs(maxRadius, number, leafMeshes, size, overrideNormals, minWeight, maxWeight, selection, 70, procedural, length, resolution, uLoops, gravityStrength);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
#if UNITY_EDITOR
|
|
5
|
+
using UnityEditor;
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
namespace Mtree
|
|
9
|
+
{
|
|
10
|
+
public class RootsFunction : TreeFunctionAsset
|
|
11
|
+
{
|
|
12
|
+
public float length = 1.5f;
|
|
13
|
+
public float resolution = 3f;
|
|
14
|
+
public int number = 8;
|
|
15
|
+
public float splitProba = .4f;
|
|
16
|
+
public float angle = .3f;
|
|
17
|
+
public AnimationCurve shape = AnimationCurve.EaseInOut(0, 1, 1, .5f);
|
|
18
|
+
public AnimationCurve splitProbaCurve = AnimationCurve.Linear(0, .5f, 1, 1f);
|
|
19
|
+
public float radius = .6f;
|
|
20
|
+
public float randomness = .25f;
|
|
21
|
+
public float start = .1f;
|
|
22
|
+
public float end = .3f;
|
|
23
|
+
public float groundHeight = 0f;
|
|
24
|
+
public float attractionStrength = 1f;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public override void Init(TreeFunctionAsset parent, bool preserveSettings = false)
|
|
28
|
+
{
|
|
29
|
+
base.Init(parent);
|
|
30
|
+
name = "Roots";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public override void DrawProperties()
|
|
34
|
+
{
|
|
35
|
+
#if UNITY_EDITOR
|
|
36
|
+
|
|
37
|
+
SerializedObject obj = new SerializedObject(this);
|
|
38
|
+
|
|
39
|
+
EditorGUILayout.PropertyField(obj.FindProperty("seed"), new GUIContent("Seed"));
|
|
40
|
+
Utils.BoundedIntProperty(obj.FindProperty("number"), new GUIContent("Number"), 0);
|
|
41
|
+
|
|
42
|
+
EditorGUILayout.BeginHorizontal();
|
|
43
|
+
Utils.BoundedFloatProperty(obj.FindProperty("length"), new GUIContent("Length"), 0.001f);
|
|
44
|
+
EditorGUILayout.EndHorizontal();
|
|
45
|
+
|
|
46
|
+
Utils.BoundedFloatProperty(obj.FindProperty("resolution"), new GUIContent("Resolution"), 0.01f);
|
|
47
|
+
EditorGUILayout.Slider(obj.FindProperty("randomness"), 0, 1, new GUIContent("Randomness"));
|
|
48
|
+
EditorGUILayout.Slider(obj.FindProperty("radius"), 0.001f, 1, new GUIContent("Radius"));
|
|
49
|
+
EditorGUILayout.PropertyField(obj.FindProperty("shape"), new GUIContent("Shape"));
|
|
50
|
+
|
|
51
|
+
EditorGUILayout.BeginHorizontal();
|
|
52
|
+
EditorGUILayout.Slider(obj.FindProperty("splitProba"), 0, 1, new GUIContent("Split proba"));
|
|
53
|
+
EditorGUILayout.PropertyField(obj.FindProperty("splitProbaCurve"), new GUIContent(""));
|
|
54
|
+
EditorGUILayout.EndHorizontal();
|
|
55
|
+
|
|
56
|
+
EditorGUILayout.Slider(obj.FindProperty("angle"), 0.1f, .95f, new GUIContent("Angle"));
|
|
57
|
+
Utils.BoundedFloatProperty(obj.FindProperty("start"), new GUIContent("Start height"), 0, end);
|
|
58
|
+
Utils.BoundedFloatProperty(obj.FindProperty("end"), new GUIContent("End height"), start);
|
|
59
|
+
|
|
60
|
+
EditorGUILayout.PropertyField(obj.FindProperty("groundHeight"), new GUIContent("Ground height"));
|
|
61
|
+
Utils.BoundedFloatProperty(obj.FindProperty("attractionStrength"), new GUIContent("attraction strength"), 0f);
|
|
62
|
+
|
|
63
|
+
obj.ApplyModifiedProperties();
|
|
64
|
+
|
|
65
|
+
#endif
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public override void Execute(MTree tree)
|
|
69
|
+
{
|
|
70
|
+
base.Execute(tree);
|
|
71
|
+
|
|
72
|
+
Random.InitState(seed);
|
|
73
|
+
int selection = parent == null ? 0 : parent.id;
|
|
74
|
+
tree.AddRoots(selection, this);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
#if UNITY_EDITOR
|
|
5
|
+
using UnityEditor;
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
namespace Mtree
|
|
9
|
+
{
|
|
10
|
+
public class SplitFunction : TreeFunctionAsset
|
|
11
|
+
{
|
|
12
|
+
public int number = 25;
|
|
13
|
+
public float splitAngle = .5f;
|
|
14
|
+
public float splitRadius = .6f;
|
|
15
|
+
public float start = .2f;
|
|
16
|
+
public float spread = 1;
|
|
17
|
+
|
|
18
|
+
public override void Init(TreeFunctionAsset parent, bool preserveSettings = false)
|
|
19
|
+
{
|
|
20
|
+
base.Init(parent);
|
|
21
|
+
name = "Split";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public override void DrawProperties()
|
|
25
|
+
{
|
|
26
|
+
#if UNITY_EDITOR
|
|
27
|
+
|
|
28
|
+
SerializedObject obj = new SerializedObject(this);
|
|
29
|
+
|
|
30
|
+
EditorGUILayout.PropertyField(obj.FindProperty("seed"), new GUIContent("Seed"));
|
|
31
|
+
Utils.BoundedIntProperty(obj.FindProperty("number"), new GUIContent("Number"), 0);
|
|
32
|
+
EditorGUILayout.Slider(obj.FindProperty("splitAngle"), 0, 2, new GUIContent("Split angle"));
|
|
33
|
+
EditorGUILayout.Slider(obj.FindProperty("splitRadius"), 0.001f, 1f, new GUIContent("Split Radius"));
|
|
34
|
+
EditorGUILayout.Slider(obj.FindProperty("start"), 0, 1, new GUIContent("Start"));
|
|
35
|
+
EditorGUILayout.Slider(obj.FindProperty("spread"), 0, 1, new GUIContent("Height spread"));
|
|
36
|
+
|
|
37
|
+
obj.ApplyModifiedProperties();
|
|
38
|
+
#endif
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public override void Execute(MTree tree)
|
|
42
|
+
{
|
|
43
|
+
base.Execute(tree);
|
|
44
|
+
|
|
45
|
+
Random.InitState(seed);
|
|
46
|
+
int selection = parent == null ? 0 : parent.id;
|
|
47
|
+
tree.Split(selection, number, splitAngle, id, splitRadius, start, spread, 0f);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace Mtree
|
|
6
|
+
{
|
|
7
|
+
public class TreeFunctionAsset : ScriptableObject
|
|
8
|
+
{
|
|
9
|
+
public int seed;
|
|
10
|
+
|
|
11
|
+
public static int positionOffset = 30; // offset in x position from parent
|
|
12
|
+
public static int height = 37;
|
|
13
|
+
public static int width = 200;
|
|
14
|
+
public static int margin = -3;
|
|
15
|
+
public static int deleteButtonSize = 18;
|
|
16
|
+
|
|
17
|
+
public static GUIStyle nodeStyle;
|
|
18
|
+
public static GUIStyle selectedNodeStyle;
|
|
19
|
+
public static GUIStyle deleteButtonStyle;
|
|
20
|
+
|
|
21
|
+
public int id;
|
|
22
|
+
|
|
23
|
+
public TreeFunctionAsset parent;
|
|
24
|
+
public List<TreeFunctionAsset> chiildren;
|
|
25
|
+
public bool enabled = true;
|
|
26
|
+
public bool showDeleteButton = true;
|
|
27
|
+
|
|
28
|
+
public Rect rect;
|
|
29
|
+
public Rect deleteRect;
|
|
30
|
+
|
|
31
|
+
public virtual void Init(TreeFunctionAsset parent, bool preserveSettings = false)
|
|
32
|
+
{
|
|
33
|
+
this.parent = parent;
|
|
34
|
+
if (parent != null)
|
|
35
|
+
parent.chiildren.Add(this);
|
|
36
|
+
chiildren = new List<TreeFunctionAsset>();
|
|
37
|
+
id = System.Guid.NewGuid().GetHashCode();
|
|
38
|
+
seed = Random.Range(0, 10000);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public virtual void Execute(MTree tree)
|
|
42
|
+
{
|
|
43
|
+
if (!enabled || (parent != null && !parent.enabled))
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public void DrawFunction(bool isSelected = false, bool deleteButton = true)
|
|
48
|
+
{
|
|
49
|
+
#if UNITY_EDITOR
|
|
50
|
+
showDeleteButton = deleteButton;
|
|
51
|
+
GUIStyle style = isSelected ? selectedNodeStyle : nodeStyle;
|
|
52
|
+
if (style == null)
|
|
53
|
+
UpdateStyle();
|
|
54
|
+
GUI.Box(rect, name, style);
|
|
55
|
+
|
|
56
|
+
if (deleteButton)
|
|
57
|
+
GUI.Button(deleteRect, "", deleteButtonStyle);
|
|
58
|
+
|
|
59
|
+
if (parent != null)
|
|
60
|
+
{
|
|
61
|
+
Vector2 start_pos = parent.rect.position + new Vector2(6, height * 6 / 7);
|
|
62
|
+
Vector2 end_pos = rect.position + new Vector2(6, height / 2);
|
|
63
|
+
UnityEditor.Handles.DrawBezier(start_pos, end_pos, start_pos + Vector2.up * 15, end_pos + Vector2.left * 15, Color.white, null, 4f);
|
|
64
|
+
}
|
|
65
|
+
#endif
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public void UpdateRectRec(ref int heightIndex, int marginIndex)
|
|
69
|
+
{
|
|
70
|
+
float x = marginIndex * positionOffset;
|
|
71
|
+
float y = heightIndex * (height + margin);
|
|
72
|
+
rect.Set(x, y, width, height);
|
|
73
|
+
if (showDeleteButton)
|
|
74
|
+
deleteRect.Set(x + width - 12 - deleteButtonSize, y + (height - deleteButtonSize) / 2, deleteButtonSize, deleteButtonSize);
|
|
75
|
+
else
|
|
76
|
+
deleteRect.Set(0, 0, 0, 0);
|
|
77
|
+
foreach (TreeFunctionAsset child in chiildren)
|
|
78
|
+
{
|
|
79
|
+
heightIndex++;
|
|
80
|
+
child.UpdateRectRec(ref heightIndex, marginIndex + 1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public virtual void DrawProperties() {}
|
|
85
|
+
|
|
86
|
+
private static void UpdateStyle()
|
|
87
|
+
{
|
|
88
|
+
#if UNITY_EDITOR
|
|
89
|
+
nodeStyle = new GUIStyle();
|
|
90
|
+
nodeStyle.normal.background = Resources.Load("Mtree/Sprites/TreeFunctionSprite") as Texture2D;
|
|
91
|
+
nodeStyle.border = new RectOffset(20, 10, 10, 10);
|
|
92
|
+
nodeStyle.alignment = TextAnchor.MiddleCenter;
|
|
93
|
+
nodeStyle.normal.textColor = Color.white;
|
|
94
|
+
nodeStyle.fontStyle = FontStyle.Bold;
|
|
95
|
+
|
|
96
|
+
selectedNodeStyle = new GUIStyle(nodeStyle);
|
|
97
|
+
selectedNodeStyle.normal.background = Resources.Load("Mtree/Sprites/TreeFunctionSpriteSelected") as Texture2D;
|
|
98
|
+
|
|
99
|
+
deleteButtonStyle = new GUIStyle();
|
|
100
|
+
deleteButtonStyle.normal.background = Resources.Load("Mtree/Sprites/DeleteCrossSprite") as Texture2D;
|
|
101
|
+
#endif
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
}
|