public Node(NodeDNA dna, Vector3 pos) { this.dna = dna; this.position = pos; this.baseAngle = this.angle = -MathHelper.PiOver2; this.radius = (10f * dna.BaseRadius) + NodeDNA.NextFloat() + 4f; this.idColor = makeIDColor(this.dna, this.depth); }
public Node(Node parent, float childPct) { this.id = NextID++; this.parent = parent; if (parent != null) { this.depth = parent.depth + 1; this.dna = parent.dna; // As a child, offset the child index var skew = (float)Math.Pow(this.dna.AngleSkew - .5f, 3); var spread = (2f * this.dna.Bushiness); this.baseAngle = parent.angle + spread * (childPct - .5f) + skew; this.baseAngle += this.dna.Wiggle * .1f * MathF.Sin(this.depth) * this.depth; // Set the position relative to the parent var mult = 15 - 12 * this.dna.Bushiness; this.branchLength = .7f * mult * parent.radius; this.branchLength *= (1 + 1 * this.dna.Variation * (NodeDNA.NextFloat() - .5f)); this.radius = parent.radius * (.6f + .3f * this.dna.Shrinkage); this.position = MathF.PolarOffset( parent.position, this.branchLength, this.baseAngle ); } this.angle = this.baseAngle; this.idColor = makeIDColor(this.dna, this.depth); }