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,185 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using System.Collections;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using Mtree;
|
|
5
|
+
|
|
6
|
+
[RequireComponent(typeof(MtreeComponent))]
|
|
7
|
+
public class MtreeBezier : MonoBehaviour {
|
|
8
|
+
|
|
9
|
+
[SerializeField]
|
|
10
|
+
public Vector3[] points;
|
|
11
|
+
|
|
12
|
+
[SerializeField]
|
|
13
|
+
public Vector3[] s_positions = new Vector3[0],s_directions = new Vector3[0];
|
|
14
|
+
|
|
15
|
+
[SerializeField]
|
|
16
|
+
public bool MTreeDoBezier,MTreeLeafDirection;
|
|
17
|
+
|
|
18
|
+
[SerializeField]
|
|
19
|
+
private BezierControlPointMode[] modes;
|
|
20
|
+
|
|
21
|
+
[SerializeField]
|
|
22
|
+
public Vector3 s_branchdirection;
|
|
23
|
+
public int ControlPointCount {
|
|
24
|
+
get {
|
|
25
|
+
return points.Length;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public Vector3 GetControlPoint (int index) {
|
|
31
|
+
return points[index];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public void SetControlPoint (int index, Vector3 point) {
|
|
35
|
+
if (index % 3 == 0) {
|
|
36
|
+
Vector3 delta = point - points[index];
|
|
37
|
+
if (index > 0) {
|
|
38
|
+
points[index - 1] += delta;
|
|
39
|
+
}
|
|
40
|
+
if (index + 1 < points.Length) {
|
|
41
|
+
points[index + 1] += delta;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
points[index] = point;
|
|
46
|
+
EnforceMode(index);
|
|
47
|
+
|
|
48
|
+
if(points.Length > 3 && MTreeDoBezier){
|
|
49
|
+
s_positions = new Vector3[0];
|
|
50
|
+
s_directions = new Vector3[0];
|
|
51
|
+
//SetMtreeCalculations();
|
|
52
|
+
#if UNITY_EDITOR
|
|
53
|
+
|
|
54
|
+
GetComponent<MtreeComponent>().GenerateTree();
|
|
55
|
+
#endif
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public BezierControlPointMode GetControlPointMode (int index) {
|
|
61
|
+
return modes[(index + 1) / 3];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public void SetControlPointMode (int index, BezierControlPointMode mode) {
|
|
65
|
+
int modeIndex = (index + 1) / 3;
|
|
66
|
+
modes[modeIndex] = mode;
|
|
67
|
+
if (modeIndex == modes.Length - 1) {
|
|
68
|
+
modes[0] = mode;
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
EnforceMode(index);
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private void EnforceMode (int index) {
|
|
76
|
+
int modeIndex = (index + 1) / 3;
|
|
77
|
+
BezierControlPointMode mode = modes[modeIndex];
|
|
78
|
+
if (mode == BezierControlPointMode.Free || (modeIndex == 0 || modeIndex == modes.Length - 1)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
int middleIndex = modeIndex * 3;
|
|
83
|
+
int fixedIndex, enforcedIndex;
|
|
84
|
+
if (index <= middleIndex) {
|
|
85
|
+
fixedIndex = middleIndex - 1;
|
|
86
|
+
if (fixedIndex < 0) {
|
|
87
|
+
fixedIndex = points.Length - 2;
|
|
88
|
+
}
|
|
89
|
+
enforcedIndex = middleIndex + 1;
|
|
90
|
+
if (enforcedIndex >= points.Length) {
|
|
91
|
+
enforcedIndex = 1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
fixedIndex = middleIndex + 1;
|
|
96
|
+
if (fixedIndex >= points.Length) {
|
|
97
|
+
fixedIndex = 1;
|
|
98
|
+
}
|
|
99
|
+
enforcedIndex = middleIndex - 1;
|
|
100
|
+
if (enforcedIndex < 0) {
|
|
101
|
+
enforcedIndex = points.Length - 2;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Vector3 middle = points[middleIndex];
|
|
106
|
+
Vector3 enforcedTangent = middle - points[fixedIndex];
|
|
107
|
+
if (mode == BezierControlPointMode.Aligned) {
|
|
108
|
+
enforcedTangent = enforcedTangent.normalized * Vector3.Distance(middle, points[enforcedIndex]);
|
|
109
|
+
}
|
|
110
|
+
points[enforcedIndex] = middle + enforcedTangent;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public int CurveCount {
|
|
114
|
+
get {
|
|
115
|
+
return (points.Length - 1) / 3;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public Vector3 GetPoint (float t) {
|
|
120
|
+
int i;
|
|
121
|
+
if (t >= 1f) {
|
|
122
|
+
t = 1f;
|
|
123
|
+
i = points.Length - 4;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
t = Mathf.Clamp01(t) * CurveCount;
|
|
127
|
+
i = (int)t;
|
|
128
|
+
t -= i;
|
|
129
|
+
i *= 3;
|
|
130
|
+
}
|
|
131
|
+
return transform.TransformPoint(Bezier.GetPoint(points[i], points[i + 1], points[i + 2], points[i + 3], t));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public Vector3 GetVelocity (float t) {
|
|
135
|
+
int i;
|
|
136
|
+
if (t >= 1f) {
|
|
137
|
+
t = 1f;
|
|
138
|
+
i = points.Length - 4;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
t = Mathf.Clamp01(t) * CurveCount;
|
|
142
|
+
i = (int)t;
|
|
143
|
+
t -= i;
|
|
144
|
+
i *= 3;
|
|
145
|
+
}
|
|
146
|
+
return transform.TransformPoint(Bezier.GetFirstDerivative(points[i], points[i + 1], points[i + 2], points[i + 3], t)) - transform.position;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public Vector3 GetDirection (float t) {
|
|
150
|
+
return GetVelocity(t).normalized;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public void AddCurve () {
|
|
154
|
+
Vector3 point = points[points.Length - 1];
|
|
155
|
+
System.Array.Resize(ref points, points.Length + 3);
|
|
156
|
+
point.y += 1f;
|
|
157
|
+
points[points.Length - 3] = point;
|
|
158
|
+
point.y += 1f;
|
|
159
|
+
points[points.Length - 2] = point;
|
|
160
|
+
point.y += 1f;
|
|
161
|
+
points[points.Length - 1] = point;
|
|
162
|
+
|
|
163
|
+
System.Array.Resize(ref modes, modes.Length + 1);
|
|
164
|
+
modes[modes.Length - 1] = modes[modes.Length - 2];
|
|
165
|
+
EnforceMode(points.Length - 4);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public float GetLength(){
|
|
169
|
+
return Bezier.GetTotalLenght(points);
|
|
170
|
+
}
|
|
171
|
+
public void Reset () {
|
|
172
|
+
points = new Vector3[] {
|
|
173
|
+
new Vector3(0f, 0f, 0f),new Vector3(0f, 2f, 0f),new Vector3(0f, 6f, 0f),new Vector3(0f, 8f, 0f)
|
|
174
|
+
|
|
175
|
+
};
|
|
176
|
+
modes = new BezierControlPointMode[] {
|
|
177
|
+
BezierControlPointMode.Free,
|
|
178
|
+
BezierControlPointMode.Free
|
|
179
|
+
};
|
|
180
|
+
s_positions = new Vector3[0];
|
|
181
|
+
s_directions = new Vector3[0];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
|
|
2
|
+
using System.Collections;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using UnityEngine.Rendering;
|
|
6
|
+
using Mtree;
|
|
7
|
+
[ExecuteInEditMode]
|
|
8
|
+
public class ExampleSceneManager : MonoBehaviour
|
|
9
|
+
{
|
|
10
|
+
List<Material> BarkMaterials,LeafMaterials;
|
|
11
|
+
Material Floor;
|
|
12
|
+
GameObject Trees,PostProcessing;
|
|
13
|
+
bool Setup = true;
|
|
14
|
+
|
|
15
|
+
void PostProcessActive()
|
|
16
|
+
{
|
|
17
|
+
#if UNITY_POST_PROCESSING_STACK_V2
|
|
18
|
+
|
|
19
|
+
#if UNITY_2019_3_OR_NEWER
|
|
20
|
+
|
|
21
|
+
if( Utils.GetCurrentPipeline() == "legacy"){
|
|
22
|
+
PostProcessing = Instantiate(Resources.Load("Mtree/Examples/Post Processing") as GameObject,this.transform);
|
|
23
|
+
PostProcessing.name = "Post Processing";
|
|
24
|
+
PostProcessing.layer = 8;
|
|
25
|
+
var cam = GetComponentInChildren<Camera>().gameObject;
|
|
26
|
+
cam.layer = 1;
|
|
27
|
+
|
|
28
|
+
var PPlayer = cam.GetComponent<UnityEngine.Rendering.PostProcessing.PostProcessLayer>();
|
|
29
|
+
if(PPlayer == null)
|
|
30
|
+
cam.AddComponent<UnityEngine.Rendering.PostProcessing.PostProcessLayer>();
|
|
31
|
+
|
|
32
|
+
PPlayer.antialiasingMode = UnityEngine.Rendering.PostProcessing.PostProcessLayer.Antialiasing.FastApproximateAntialiasing;
|
|
33
|
+
PPlayer.volumeLayer = 2;
|
|
34
|
+
PostProcessing.transform.SetParent(this.transform);
|
|
35
|
+
}
|
|
36
|
+
#else
|
|
37
|
+
PostProcessing = Instantiate(Resources.Load("Mtree/Examples/Post Processing") as GameObject,this.transform);
|
|
38
|
+
PostProcessing.name = "Post Processing";
|
|
39
|
+
PostProcessing.layer = 8;
|
|
40
|
+
var cam = GetComponentInChildren<Camera>().gameObject;
|
|
41
|
+
cam.layer = 1;
|
|
42
|
+
|
|
43
|
+
var PPlayer = cam.GetComponent<UnityEngine.Rendering.PostProcessing.PostProcessLayer>();
|
|
44
|
+
if(PPlayer == null)
|
|
45
|
+
cam.AddComponent<UnityEngine.Rendering.PostProcessing.PostProcessLayer>();
|
|
46
|
+
|
|
47
|
+
PPlayer.antialiasingMode = UnityEngine.Rendering.PostProcessing.PostProcessLayer.Antialiasing.FastApproximateAntialiasing;
|
|
48
|
+
PPlayer.volumeLayer.value = 2;
|
|
49
|
+
PostProcessing.transform.SetParent(this.transform);
|
|
50
|
+
#endif
|
|
51
|
+
#endif
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
void LegacySetup(){
|
|
55
|
+
#if UNITY_2019_1_OR_NEWER
|
|
56
|
+
var obj = Instantiate(Resources.Load("Mtree/Examples/2019_1 Legacy") as GameObject,this.transform);
|
|
57
|
+
obj.name = "Legacy 2019.1+";
|
|
58
|
+
Debug.Log("Legacy 2019.1+ Scene loaded!");
|
|
59
|
+
#else
|
|
60
|
+
var obj = Instantiate(Resources.Load("Mtree/Examples/2017_4 Legacy") as GameObject,this.transform);
|
|
61
|
+
obj.name = "Legacy 2017.4+";
|
|
62
|
+
Debug.Log("Legacy 2017.4+ was loaded!");
|
|
63
|
+
#endif
|
|
64
|
+
}
|
|
65
|
+
void LWRPSetup()
|
|
66
|
+
{
|
|
67
|
+
#if UNITY_2018_3_OR_NEWER
|
|
68
|
+
var obj = Instantiate(Resources.Load("Mtree/Examples/2018_4 LWRP") as GameObject,this.transform);
|
|
69
|
+
obj.name = "LWRP 2018.4+";
|
|
70
|
+
Debug.Log("LWRP 2018.4+ Scene loaded!");
|
|
71
|
+
#endif
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
void HDRPSetup()
|
|
75
|
+
{
|
|
76
|
+
|
|
77
|
+
#if UNITY_2019_3_OR_NEWER
|
|
78
|
+
var obj = Instantiate(Resources.Load("Mtree/Examples/2019_3 HDRP") as GameObject,this.transform);
|
|
79
|
+
obj.name = "HDRP 2019.3+";
|
|
80
|
+
Debug.Log("HDRP 2019.3+ Scene loaded!");
|
|
81
|
+
#else
|
|
82
|
+
var obj = Instantiate(Resources.Load("Mtree/Examples/2018_4 HDRP") as GameObject,this.transform);
|
|
83
|
+
obj.name = "HDRP 2018.4+";
|
|
84
|
+
Debug.Log("HDRP 2018.4+ Scene loaded!");
|
|
85
|
+
#endif
|
|
86
|
+
}
|
|
87
|
+
void URPSetup()
|
|
88
|
+
{
|
|
89
|
+
#if UNITY_2019_3_OR_NEWER
|
|
90
|
+
Instantiate(Resources.Load("Mtree/Examples/2019_3 URP") as GameObject,this.transform);
|
|
91
|
+
Debug.Log("URP 2019.3+ Scene loaded!");
|
|
92
|
+
#endif
|
|
93
|
+
}
|
|
94
|
+
void Start()
|
|
95
|
+
{
|
|
96
|
+
|
|
97
|
+
if(Setup){
|
|
98
|
+
foreach(Transform t in this.transform)
|
|
99
|
+
DestroyImmediate(t.gameObject);
|
|
100
|
+
switch(Utils.GetCurrentPipeline())
|
|
101
|
+
{
|
|
102
|
+
case "legacy":
|
|
103
|
+
LegacySetup();
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case "lwrp":
|
|
107
|
+
LWRPSetup();
|
|
108
|
+
break;
|
|
109
|
+
|
|
110
|
+
case "hdrp":
|
|
111
|
+
HDRPSetup();
|
|
112
|
+
break;
|
|
113
|
+
|
|
114
|
+
case "urp":
|
|
115
|
+
URPSetup();
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
PostProcessActive();
|
|
119
|
+
UpdateMaterials();
|
|
120
|
+
Setup = false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
void UpdateMaterials(){
|
|
124
|
+
|
|
125
|
+
BarkMaterials = new List<Material>();
|
|
126
|
+
LeafMaterials = new List<Material>();
|
|
127
|
+
var renderers = GameObject.Find("Trees").GetComponentsInChildren<MeshRenderer>();
|
|
128
|
+
Floor = transform.GetComponent<MeshRenderer>().sharedMaterial;
|
|
129
|
+
foreach (var r in renderers){
|
|
130
|
+
foreach(var m in r.sharedMaterials){
|
|
131
|
+
if(m.shader.name.Contains("Leafs"))
|
|
132
|
+
LeafMaterials.Add(m);
|
|
133
|
+
if(m.shader.name.Contains("Bark"))
|
|
134
|
+
BarkMaterials.Add(m);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
for(int i = 0; i<BarkMaterials.Count;i++)
|
|
139
|
+
BarkMaterials[i].shader = Utils.GetBarkShader();
|
|
140
|
+
for(int i = 0; i<LeafMaterials.Count;i++)
|
|
141
|
+
LeafMaterials[i].shader = Utils.GetLeafShader();
|
|
142
|
+
|
|
143
|
+
switch(Utils.GetCurrentPipeline())
|
|
144
|
+
{
|
|
145
|
+
case "legacy":
|
|
146
|
+
Floor.shader = Shader.Find("Standard");
|
|
147
|
+
break;
|
|
148
|
+
|
|
149
|
+
case "lwrp":
|
|
150
|
+
Floor.shader = Shader.Find("Lightweight Render Pipeline/Lit");
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
case "hdrp":
|
|
154
|
+
Floor.shader = Shader.Find("HDRP/Lit");
|
|
155
|
+
break;
|
|
156
|
+
|
|
157
|
+
case "urp":
|
|
158
|
+
Floor.shader = Shader.Find("Universal Render Pipeline/Lit");
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
|
|
11
|
+
public class LODValues : ScriptableObject
|
|
12
|
+
{
|
|
13
|
+
public float radialResolution = 1f;
|
|
14
|
+
public float simplifyAngleThreshold = 0.01f;
|
|
15
|
+
public float simplifyRadiusThreshold = 0f;
|
|
16
|
+
public float simplifyLeafs = 0f;
|
|
17
|
+
|
|
18
|
+
public void Init(LODValues previousLOD = null)
|
|
19
|
+
{
|
|
20
|
+
if (previousLOD == null)
|
|
21
|
+
return;
|
|
22
|
+
this.radialResolution = previousLOD.radialResolution / 2.5f;
|
|
23
|
+
this.simplifyAngleThreshold = Mathf.Lerp(previousLOD.simplifyAngleThreshold, 40, .2f);
|
|
24
|
+
this.simplifyRadiusThreshold = Mathf.Lerp(previousLOD.simplifyRadiusThreshold, .15f, .2f);
|
|
25
|
+
this.simplifyLeafs = Mathf.Clamp(previousLOD.simplifyLeafs + .2f, 0, 1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#if UNITY_EDITOR
|
|
29
|
+
public void DrawProperties()
|
|
30
|
+
{
|
|
31
|
+
SerializedObject obj = new SerializedObject(this);
|
|
32
|
+
|
|
33
|
+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
|
34
|
+
Utils.BoundedFloatProperty(obj.FindProperty("radialResolution"), new GUIContent("Radial resolution"), 0.001f);
|
|
35
|
+
EditorGUILayout.Slider(obj.FindProperty("simplifyAngleThreshold"), 0, 90, new GUIContent("Angle threshold"));
|
|
36
|
+
EditorGUILayout.Slider(obj.FindProperty("simplifyRadiusThreshold"), 0, .9f, new GUIContent("Simplify radius"));
|
|
37
|
+
EditorGUILayout.Slider(obj.FindProperty("simplifyLeafs"), 0, .99f, new GUIContent("Simplify leaves"));
|
|
38
|
+
|
|
39
|
+
EditorGUILayout.EndVertical();
|
|
40
|
+
obj.ApplyModifiedProperties();
|
|
41
|
+
}
|
|
42
|
+
#endif
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace Mtree
|
|
6
|
+
{
|
|
7
|
+
public struct LeafPoint
|
|
8
|
+
{
|
|
9
|
+
public Vector3 position;
|
|
10
|
+
public Vector3 direction;
|
|
11
|
+
public float size;
|
|
12
|
+
public Mesh[] meshes;
|
|
13
|
+
public bool overrideNormals;
|
|
14
|
+
public float distanceFromOrigin;
|
|
15
|
+
private float length;
|
|
16
|
+
private int uLoops;
|
|
17
|
+
private float resolution;
|
|
18
|
+
public bool procedural;
|
|
19
|
+
private float gravityStrength;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
public LeafPoint(Vector3 pos, Vector3 dir, float size, Mesh[] m, bool overrideNorm, float distanceFromOrigin, float length=1, int uLoops=2, float resolution=1, bool procedural=false, float gravityStrength=1)
|
|
23
|
+
{
|
|
24
|
+
position = pos;
|
|
25
|
+
direction = dir;
|
|
26
|
+
this.size = size;
|
|
27
|
+
meshes = m;
|
|
28
|
+
overrideNormals = overrideNorm;
|
|
29
|
+
this.distanceFromOrigin = distanceFromOrigin;
|
|
30
|
+
this.length = length;
|
|
31
|
+
this.uLoops = uLoops;
|
|
32
|
+
this.resolution = resolution;
|
|
33
|
+
this.procedural = procedural;
|
|
34
|
+
this.gravityStrength = gravityStrength;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public Mesh GetMesh(int lodLevel)
|
|
38
|
+
{
|
|
39
|
+
if (!procedural)
|
|
40
|
+
{
|
|
41
|
+
if (meshes != null && meshes.Length > 0)
|
|
42
|
+
return meshes[Mathf.Min(lodLevel, meshes.Length-1)];
|
|
43
|
+
else
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
return GrowLeaf();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private Mesh GrowLeaf()
|
|
51
|
+
{
|
|
52
|
+
Vector3[] profile = new Vector3[uLoops];
|
|
53
|
+
Vector2[] profileUvs = new Vector2[uLoops];
|
|
54
|
+
for (int i=0; i<uLoops; i++)
|
|
55
|
+
{
|
|
56
|
+
float t = (float)i / (uLoops - 1);
|
|
57
|
+
float x_pos = t - 0.5f;
|
|
58
|
+
float y_pos = - Mathf.Pow(t-0.5f, 2);
|
|
59
|
+
if (uLoops == 2)
|
|
60
|
+
y_pos = 0;
|
|
61
|
+
profile[i] = new Vector3(x_pos*2, y_pos, 0);
|
|
62
|
+
profileUvs[i] = new Vector2(t, 0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Queue<Vector3> verts = new Queue<Vector3>();
|
|
66
|
+
Quaternion rot = Quaternion.FromToRotation(Vector3.up, direction);
|
|
67
|
+
rot = Quaternion.LookRotation(direction);
|
|
68
|
+
foreach (Vector3 v in profile)
|
|
69
|
+
verts.Enqueue(rot * v*size + position);
|
|
70
|
+
Queue<Vector2> uvs = new Queue<Vector2>(profileUvs);
|
|
71
|
+
Queue<int> triangles = new Queue<int>();
|
|
72
|
+
Vector3 lastPos = position;
|
|
73
|
+
Vector3 lastDir = direction.normalized;
|
|
74
|
+
int vCount = Mathf.Max(1, (int)(length * resolution));
|
|
75
|
+
float stepLength = length / vCount;
|
|
76
|
+
for (int i=0; i < vCount; i++)
|
|
77
|
+
{
|
|
78
|
+
Vector3 newDir = Vector3.Normalize(lastDir + Vector3.down * gravityStrength / resolution);
|
|
79
|
+
Vector3 newPos = lastPos + lastDir * stepLength;
|
|
80
|
+
if (Vector3.Angle(lastDir, newDir) < 10 && i != vCount - 1 || newPos.y < 0)
|
|
81
|
+
{
|
|
82
|
+
lastPos = newPos;
|
|
83
|
+
lastDir = newDir;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
//newDir = lastDir;
|
|
87
|
+
//newPos = position;
|
|
88
|
+
rot = Quaternion.FromToRotation(Vector3.up, Vector3.Slerp(lastDir, newDir, .5f));
|
|
89
|
+
rot = Quaternion.LookRotation(lastDir, Vector3.up);
|
|
90
|
+
int n = verts.Count;
|
|
91
|
+
for (int j=0; j<uLoops; j++)
|
|
92
|
+
{
|
|
93
|
+
Vector3 v = (rot * profile[j]*size) + newPos;
|
|
94
|
+
verts.Enqueue(v);
|
|
95
|
+
uvs.Enqueue(new Vector2((float)j / (uLoops - 1), (float)(i+1)/vCount));
|
|
96
|
+
if (j < uLoops - 1)
|
|
97
|
+
{
|
|
98
|
+
Utils.AddTriangle(triangles, n-uLoops + j, n + j , n - uLoops + 1 + j);
|
|
99
|
+
Utils.AddTriangle(triangles, n + j , n + j + 1, n - uLoops + j + 1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
lastPos = newPos;
|
|
103
|
+
lastDir = newDir;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
Mesh mesh = new Mesh();
|
|
107
|
+
mesh.vertices = verts.ToArray();
|
|
108
|
+
mesh.uv = uvs.ToArray();
|
|
109
|
+
mesh.triangles = triangles.ToArray();
|
|
110
|
+
mesh.RecalculateNormals();
|
|
111
|
+
return mesh;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public struct LeafCandidate
|
|
116
|
+
{
|
|
117
|
+
public Vector3 position;
|
|
118
|
+
public Vector3 direction;
|
|
119
|
+
public float size;
|
|
120
|
+
public float parentBranchLength;
|
|
121
|
+
public float distanceFromOrigin;
|
|
122
|
+
public bool isEnd;
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
public LeafCandidate(Vector3 pos, Vector3 dir, float size, float branchLength, float distanceFromOrigin, bool isEnd)
|
|
126
|
+
{
|
|
127
|
+
position = pos;
|
|
128
|
+
direction = dir;
|
|
129
|
+
this.size = size;
|
|
130
|
+
parentBranchLength = branchLength;
|
|
131
|
+
this.distanceFromOrigin = distanceFromOrigin; ;
|
|
132
|
+
this.isEnd = isEnd;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|