private void GetIndexesFrom(LLinkedListNode <LTerm> node, BranchIndex fromBranch, GameObjectInfo objectInfo, ref List <OrganIndex> indexList) { if (node == null) { throw new ArgumentNullException("No start node."); } LLinkedListNode <LTerm> headNode = m_RuleData.FinalList.First; BranchIndex curBranchIndex = fromBranch; do { if (node.Value != null) { switch (node.Value.Symbol[0]) //符号解析 { case 'F': objectInfo.Length = Convert.ToSingle(node.Value.Params[0]); BranchIndex branchIndex = GetBranchIndex(curBranchIndex, fromBranch, objectInfo); indexList.Add(branchIndex); //在器官索引列表中添加,后续绘制用,绘制完成后删除 AddBranchIndex(branchIndex); //在枝干索引列表中添加,不删除 curBranchIndex = branchIndex; //设置当前的枝干索引 break; case 'f': objectInfo.Position = MoveForward(objectInfo); break; case '!': objectInfo.Radius = Convert.ToSingle(node.Value.Params[0]); break; case '+': objectInfo.Rotation -= new Vector3(Convert.ToSingle(node.Value.Params[0]), 0, 0); break; case '-': objectInfo.Rotation += new Vector3(Convert.ToSingle(node.Value.Params[0]), 0, 0); break; case '&': objectInfo.Rotation -= new Vector3(0, Convert.ToSingle(node.Value.Params[0]), 0); break; case '^': objectInfo.Rotation += new Vector3(0, Convert.ToSingle(node.Value.Params[0]), 0); break; case '\\': objectInfo.Rotation += new Vector3(0, 0, Convert.ToSingle(node.Value.Params[0])); break; case '/': objectInfo.Rotation -= new Vector3(0, 0, Convert.ToSingle(node.Value.Params[0])); break; case '%': OrganIndex organIndex = GetOrganIndex(MeshResource.GetInstance().GetNameOf(Convert.ToInt32(node.Value.Params[0])) /*将标识码转换成对应的名字*/, curBranchIndex, objectInfo); if (organIndex != null) { indexList.Add(organIndex); AddOrganIndex(organIndex); } break; case '[': node = node.Next; GetIndexesFrom(node, curBranchIndex, objectInfo.Clone(), ref indexList); //入栈 node = _CurrentNode; //将节点设置成分支结束的节点 break; case ']': _CurrentNode = node; node = headNode.Previous; //出栈,中断该函数 break; } } node = node.Next; } while (node != headNode); }