public void setBranch(BranchInfo _branch) { branch = _branch; }
public static BoundsOctree <BranchLineInfo> TreesInWorld;// = new BoundsOctree<BranchLineInfo>(10, origin, .1, 1); public TreeInfo(List <string[]> _text, int _id) { id = _id; Vector3 tempStart = Vector3.one; for (int i = 0; i < _text.Count; i++) { if (_text[i].Length == 23) { BranchLineInfo newBranchLine = new BranchLineInfo(_text[i]); BranchInfo newBranch = new BranchInfo(_text[i], this); if (i == 0) { tempStart = newBranchLine.startPt; } if (tempStart.y > newBranchLine.startPt.y) { tempStart = newBranchLine.startPt; } if (!branchLines.ContainsKey(newBranchLine.id)) { branchLines.Add(newBranchLine.id, newBranchLine); } if (branches.ContainsKey(newBranch.id)) { branches[newBranch.id].addLine(newBranchLine); newBranchLine.setBranch(branches[newBranch.id]); } else { branches.Add(newBranch.id, newBranch); newBranch.addLine(newBranchLine); newBranchLine.setBranch(newBranch); } } } // set branch transforms. foreach (var branch in branches) { branch.Value.SetTransform(this); } branchTransforms = new List <List <Matrix4x4> >();// new Matrix4x4[branchLines.Count]; branchColour = new List <List <Vector4> >(); branchs = new List <List <BranchLineInfo> >(); int count = 0; int index = 0; branchTransforms.Add(new List <Matrix4x4>()); branchColour.Add(new List <Vector4>()); branchs.Add(new List <BranchLineInfo>()); foreach (var branchLine in branchLines) { count++; if (count > 1020) { branchTransforms.Add(new List <Matrix4x4>()); branchColour.Add(new List <Vector4>()); branchs.Add(new List <BranchLineInfo>()); count = 0; index++; } branchTransforms[index].Add(branchLine.Value.transform); branchs[index].Add(branchLine.Value); /* * switch (branchLine.Value.branch.bType) * { * case BranchType.Hidden: * branchColour[index].Add((new Vector4(0.5f, 0.5f, 0.5f, 1))); * break; * case BranchType.Undefined: * branchColour[index].Add((new Vector4(0.5f, 0.5f, 0.5f, 1))); * break; * case BranchType.Exposed: * branchColour[index].Add((new Vector4(1, 0, 0, 1))); * break; * case BranchType.Lateral: * branchColour[index].Add((new Vector4(1, 0.5f, 1, 1))); * break; * case BranchType.DeadTipLow: * branchColour[index].Add((new Vector4(0, 0.5f, 1, 1))); * break; * case BranchType.DeadLateralLow: * branchColour[index].Add((new Vector4(0.5f, 0, 0.5f, 1))); * break; * default: * break; * } */ if (branchLine.Value.radius > 0.1) { branchColour[index].Add((new Vector4(1, 0, 0, 1))); } else { branchColour[index].Add((new Vector4(0.5f, 0.5f, 0.5f, 1))); } /* * if (branchLine.Value.branch.isDead && branchLine.Value.inclanation < 45 && branchLine.Value.radius > 0.02) * branchColour[index].Add((new Vector4(1, 0, 0, 1))); * else * branchColour[index].Add((new Vector4(0.5f, 0.5f, 0.5f, 1))); */ //branchColour[index].Add((new Vector4(branchLine.Value.distanceToTip, branchLine.Value.elevation, branchLine.Value.inclanation, 1.0f)).normalized); } origin = tempStart; if (TreesInWorld == null) { TreesInWorld = new BoundsOctree <BranchLineInfo>(30, origin, .1f, 1); } foreach (var branchLine in branchLines) { TreesInWorld.Add(branchLine.Value, new Bounds((branchLine.Value.endPt + branchLine.Value.startPt) / 2, branchLine.Value.endPt - branchLine.Value.startPt)); } }