74 lines
1.5 KiB
C#
74 lines
1.5 KiB
C#
using UnityEngine;
|
|
|
|
namespace Mtree
|
|
{
|
|
public class TrunkFunction : TreeFunctionAsset
|
|
{
|
|
public float radiusMultiplier = 0.3f;
|
|
|
|
public AnimationCurve radius;
|
|
|
|
public float length = 15f;
|
|
|
|
public int number = 1;
|
|
|
|
public float randomness = 0.1f;
|
|
|
|
public float originAttraction = 0.1f;
|
|
|
|
public float resolution = 1.5f;
|
|
|
|
public AnimationCurve rootShape;
|
|
|
|
public float rootRadius = 0.25f;
|
|
|
|
public float rootInnerRadius = 0.2f;
|
|
|
|
public float rootHeight = 1f;
|
|
|
|
public float rootResolution = 3f;
|
|
|
|
public int flareNumber = 5;
|
|
|
|
public float spinAmount = 0.1f;
|
|
|
|
public float displacementStrength = 1f;
|
|
|
|
public float displacementSize = 2.5f;
|
|
|
|
public float heightOffset = 0.5f;
|
|
|
|
public override void Init(TreeFunctionAsset parent, bool preserveSettings = false)
|
|
{
|
|
base.Init(parent);
|
|
base.name = "Trunk";
|
|
if (!preserveSettings)
|
|
{
|
|
Keyframe[] keys = new Keyframe[2]
|
|
{
|
|
new Keyframe(0f, 1f, 0f, 0f),
|
|
new Keyframe(1f, 0f, -1f, -1f)
|
|
};
|
|
radius = new AnimationCurve(keys);
|
|
Keyframe[] keys2 = new Keyframe[2]
|
|
{
|
|
new Keyframe(0f, 1f, -2f, -2f),
|
|
new Keyframe(1f, 0f, 0f, 0f)
|
|
};
|
|
rootShape = new AnimationCurve(keys2);
|
|
}
|
|
}
|
|
|
|
public override void DrawProperties()
|
|
{
|
|
}
|
|
|
|
public override void Execute(MTree tree)
|
|
{
|
|
base.Execute(tree);
|
|
Random.InitState(seed);
|
|
tree.AddTrunk(Vector3.down * heightOffset, Vector3.up, length, radius, radiusMultiplier, resolution, randomness, id, rootShape, rootRadius, rootHeight, rootResolution, originAttraction);
|
|
}
|
|
}
|
|
}
|