Skip to content

Commit

Permalink
changed leave generator to use circular radius
Browse files Browse the repository at this point in the history
  • Loading branch information
GandhiGames committed Dec 19, 2016
1 parent 90e978b commit e17678b
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 10 deletions.
Binary file modified documentation/Fractal Tree Information.docx
Binary file not shown.
Binary file modified fractal_tree/Assets/Scenes/Tree Demo.unity
Binary file not shown.
4 changes: 4 additions & 0 deletions fractal_tree/Assets/Scripts/Demo/DemoTreeCreator.cs
Expand Up @@ -21,6 +21,8 @@ public class DemoTreeCreator : MonoBehaviour
/// </summary>
public bool showingStationary = true;

public int startIndex = 0;

/// <summary>
/// Gets the active tree or null if there is none.
/// </summary>
Expand All @@ -36,6 +38,8 @@ public class DemoTreeCreator : MonoBehaviour

void Start()
{
m_TreeIndex = startIndex;

foreach (var demo in treeBuilders) {

if (leafGenerator != null && demo.stationaryTree.treeType == TreeBuilder.TreeType.Colonization) {
Expand Down
16 changes: 8 additions & 8 deletions fractal_tree/Assets/Scripts/Trees/ColonizationLeafGenerator.cs
Expand Up @@ -9,19 +9,21 @@ namespace FractalTree
/// </summary>
public class ColonizationLeafGenerator : MonoBehaviour
{
/// <summary>
/// The bounds within which to spawn the leafs.
/// </summary>
public Rect bounds;
public float radius = 6f;

/// <summary>
/// The number of leaves to spawn.
/// </summary>
public int numToCreate = 100;


public bool buildOnStart = false;

void Awake ()
{
Generate ();
if (buildOnStart) {
Generate ();
}
}

public void Generate()
Expand All @@ -30,9 +32,7 @@ public void Generate()

for (int i = 0; i < numToCreate; i++) {
GameObject leaf = new GameObject ("Leaf " + (i + 1));
leaf.transform.position = new Vector2 (
Random.Range (bounds.xMin, bounds.xMax),
Random.Range (bounds.yMin, bounds.yMax));
leaf.transform.position = (Vector2)transform.position + (Random.insideUnitCircle * radius);
leaf.AddComponent<ColonizationLeaf> ();
leaf.transform.SetParent (transform);

Expand Down
6 changes: 5 additions & 1 deletion fractal_tree/Assets/Scripts/Trees/LTree.cs
Expand Up @@ -153,7 +153,7 @@ private void CalculateNextStep ()
branchesCreated.Add (branch);
current = next;
} else if (currentChar.Equals ('G')) {
current += (Vector2.up * m_Length).Rotate (rotation);
current += (Vector2.up * m_Length).Rotate (rotation);
} else if (currentChar.Equals ('+')) {
rotation -= m_Angle;
} else if (currentChar.Equals ('-')) {
Expand Down Expand Up @@ -187,6 +187,10 @@ private void CalculateNextStep ()

}
}
} else if (currentChar.Equals ('!')) {
m_Angle *= -1f;
} else if (currentChar.Equals ('|')) {
rotation = 180f;
}

}
Expand Down
Binary file modified fractal_tree/Library/CurrentLayout.dwlt
Binary file not shown.
Binary file modified fractal_tree/Library/CurrentMaximizeLayout.dwlt
Binary file not shown.
5 changes: 4 additions & 1 deletion fractal_tree/Library/LastSceneManagerSetup.txt
@@ -1 +1,4 @@
sceneSetups: []
sceneSetups:
- path: Assets/Scenes/Tree Demo.unity
isLoaded: 1
isActive: 1
Binary file modified fractal_tree/Library/ScriptAssemblies/Assembly-CSharp.dll
Binary file not shown.
Binary file modified fractal_tree/Library/ScriptAssemblies/Assembly-CSharp.dll.mdb
Binary file not shown.
Binary file modified fractal_tree/Library/assetDatabase3
Binary file not shown.
Binary file modified fractal_tree/Library/metadata/30/30ecff6a494516c4d8096d2e4a5fb464
Binary file not shown.
Binary file modified fractal_tree/Library/metadata/9e/9e6e2c21b366f4ad58f1a27544e987ff
Binary file not shown.
Binary file not shown.
Binary file modified fractal_tree/obj/Debug/Assembly-CSharp.dll
Binary file not shown.
Binary file modified fractal_tree/obj/Debug/Assembly-CSharp.dll.mdb
Binary file not shown.

0 comments on commit e17678b

Please sign in to comment.