|
I would like to make fractal tree in Unity3d, omitting branch angles and lengths, just to instantiate cubes as a tree, like 2,4,8,16... i look for solution all day and i figure it could take me days yet? Should i use an array to store and recall a list of coordinates that each new branch should be at? would it contain 2 or 16 values? Here is an interactive JS code for trees: http://www.processing.org/learning/topics/tree.html It uses the following code, please bypass the canvas, rotations, stalk length, i'd be so happy to just have a tree like in the image. } }
here is my funny attempt thus far:
(comments are locked)
|
|
Try this as a staring point: Put the script on an empty game object. Drag in the parent (you can modify it later to instantiate or whatever), and drag in your cube prefab. The function above is called recursively on the new corners; the depth value makes sure it is not called indefinitely. Thankyou so much! That's very interesting. i will take a long while to understand and tailor it for other shapes now. I had to add the line "using UnityEngine;" at the top.
Jul 21 '11 at 09:39 AM
vestax_ion
the childToParentRatio was scaling exponentially small so i changed line 37 to this: AddChildren(cube, childToParentRatio - (childToParentRatio /2), depth - 1); because otherwise you could only see the first 3 rows although it would make more sense to write: but it wouldnt let me! so it's saying 0.6 is a double not a float? so i have to declare a var as a float and then say it is 0.6? ok i get it. brb ;)
Jul 21 '11 at 10:38 AM
vestax_ion
For float literals, just put an f, for example,
Jul 21 '11 at 11:26 AM
Herman Tulleken
what is the most computationally efficient way to use such a structure in Unity3d? should "combine mesh" to reduce draw calls, should i do some postprocessing to cull hiddent vertexes and objects? I was only just beginning JS, even instantiation seems very tricky in C#, i haven't yet managed to instantiate the central parent cube.
Jul 21 '11 at 04:55 PM
vestax_ion
I think you may want to ask a separate question for that; I am not a 3D model optimisation guru :P.
Jul 24 '11 at 07:02 PM
Herman Tulleken
(comments are locked)
|
|
Here is a JS version of your C# script:
(comments are locked)
|
|
There is some info and a source project to draw reference from here http://tonydincau.com/fractal-trees/
(comments are locked)
|

