private GameObject m_MeshModelInstance = null; //该模型的实例 public Mesh(string name, string MeshPath, string TexturePath, float size, float MaxSize, OrganType Type, TreeModel modelEntry) { m_strName = name; m_strMeshPath = MeshPath; m_strTexturePath = TexturePath; m_fSize = size; m_fMaxSize = MaxSize; m_ModelEntry = modelEntry; m_Type = Type; MeshResource.GetInstance().Add(m_strName); m_iNameValue = MeshResource.GetInstance().GetValueOf(m_strName); }
public override string ToString() { string result = ""; result += m_cSymbol; if (m_listParams.Count == 0) { return(result); } result += "("; if (m_cSymbol.Equals("%")) //存在Mesh名替换的情况 { for (int i = 0; i < m_listParams.Count; i++) { //判断是否为数字,如果为数字则判断时候需要替换 string MeshName = StringValidate.IsNumeric(m_listParams[i]) ? MeshResource.GetInstance().GetNameOf(Convert.ToInt32(m_listParams[i])) : m_listParams[i]; if (i != 0) { result += ","; } if (MeshName != null) { result += MeshName; } else { result += m_listParams[i]; } } } else { for (int i = 0; i < m_listParams.Count; i++) { if (i != 0) { result += ","; } result += m_listParams[i]; } } result += ")"; return(result); }
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); }