protected override void ProcessInnerNode(AseReader reader, AseNode parentNode) { switch (reader.NodeName) { case "TIMEVALUE": int timeValue = int.Parse(reader.NodeData); if (timeValue != 0) { throw new AseException("Only models without any animation is supported."); } break; case "MESH_NUMVERTEX": _vertexList.Count = int.Parse(reader.NodeData); break; case "MESH_NUMFACES": _faceList.Count = int.Parse(reader.NodeData); break; case "MESH_NUMTVERTEX": _texVertexList.Count = int.Parse(reader.NodeData); break; case "MESH_NUMTVFACES": // ignore this value under the assumption that all TFaces will // also have a Face struct associated with them. break; } }
public override void ProcessNode(AseReader reader, AseNode parentNode) { ProcessNodePre(reader, parentNode); reader.ReadNextLine(); while (!(reader.EndOfFile || reader.NodeParentEnd)) { AseNode node = GetParser(reader.NodeName); if (node == null) { if (reader.NodeParentStart) { TraverseUnhandledNodes(reader); } else { ProcessInnerNode(reader, parentNode); } } else { node.ProcessNode(reader, this); } reader.ReadNextLine(); } ProcessNodePost(reader, parentNode); }
protected override void ProcessNodePre(AseReader reader, AseNode parentNode) { if (parentNode is AseMaterialList) { AseMaterialList list = parentNode as AseMaterialList; int index = int.Parse(reader.NodeData); list[index] = this; } }
protected override void ProcessInnerNode(AseReader reader, AseNode parentNode) { switch (reader.NodeName) { case "MATERIAL_COUNT": _materials = new AseMaterial[int.Parse(reader.NodeData)]; break; } }
protected override void ProcessInnerNode(AseReader reader, AseNode parentNode) { if (reader.NodeName == "MESH_VERTEX") { AseStringTokenizer tokens = new AseStringTokenizer(reader.NodeData); int index = int.Parse(tokens.GetNext()); _vertices[index].X = float.Parse(tokens.GetNext()); _vertices[index].Y = float.Parse(tokens.GetNext()); _vertices[index].Z = float.Parse(tokens.GetNext()); } }
protected override void ProcessInnerNode(AseReader reader, AseNode parentNode) { switch (reader.NodeName) { case "NODE_NAME": _name = reader.NodeData; break; case "MATERIAL_REF": _materialRef = int.Parse(reader.NodeData); break; } }
protected override void ProcessInnerNode(AseReader reader, AseNode parentNode) { AseMesh mesh = parentNode as AseMesh; if (reader.NodeName == "MESH_FACENORMAL") { AseStringTokenizer tokens = new AseStringTokenizer(reader.NodeData); int index = int.Parse(tokens.GetNext()); AseFace face = mesh.FaceList[index]; face.NormalFace = new AseVertex( float.Parse(tokens.GetNext()), float.Parse(tokens.GetNext()), float.Parse(tokens.GetNext())); for (int i = 0; i < 3; i++) { reader.ReadNextLine(); tokens = new AseStringTokenizer(reader.NodeData); if (reader.NodeName == "MESH_VERTEXNORMAL") { int vIndex = int.Parse(tokens.GetNext()); if (vIndex == mesh.FaceList[index].A) { face.NormalA = new AseVertex( float.Parse(tokens.GetNext()), float.Parse(tokens.GetNext()), float.Parse(tokens.GetNext())); } else if (vIndex == mesh.FaceList[index].B) { face.NormalB = new AseVertex( float.Parse(tokens.GetNext()), float.Parse(tokens.GetNext()), float.Parse(tokens.GetNext())); } else if (vIndex == mesh.FaceList[index].C) { face.NormalC = new AseVertex( float.Parse(tokens.GetNext()), float.Parse(tokens.GetNext()), float.Parse(tokens.GetNext())); } } else { // we must have atleast 3 MESH_VERTEXNORMAL nodes i--; } } mesh.FaceList[index] = face; } }
protected override void ProcessInnerNode(AseReader reader, AseNode parentNode) { AseMesh mesh = parentNode as AseMesh; if (reader.NodeName == "MESH_TFACE") { AseStringTokenizer tokens = new AseStringTokenizer(reader.NodeData); int index = int.Parse(tokens.GetNext()); AseFace face = mesh.FaceList[index]; face.TextureA = int.Parse(tokens.GetNext()); face.TextureB = int.Parse(tokens.GetNext()); face.TextureC = int.Parse(tokens.GetNext()); mesh.FaceList[index] = face; } }
protected override void ProcessInnerNode(AseReader reader, AseNode parentNode) { switch (reader.NodeName) { case "MATERIAL_NAME": _name = reader.NodeData; break; case "NUMSUBMTLS": if (parentNode is AseSubMaterial) { throw new AseException("Internal Sanity Check: SubMaterial within SubMaterial!"); } _subMaterials = new AseSubMaterial[int.Parse(reader.NodeData)]; break; } }
public virtual void ProcessNode(AseReader reader, AseNode parentNode) { ProcessNodePre(reader, parentNode); reader.ReadNextLine(); while (!(reader.EndOfFile || reader.NodeParentEnd)) { if (reader.NodeParentStart) { TraverseUnhandledNodes(reader); } else { ProcessInnerNode(reader, parentNode); } reader.ReadNextLine(); } ProcessNodePost(reader, parentNode); }
protected AseNode GetParser(string nodeName) { Object parser = _nodeParsers[nodeName]; if (parser == null) { return(null); } if (parser is Type) { Type type = parser as Type; ConstructorInfo ci = type.GetConstructor(Type.EmptyTypes); AseNode node = ci.Invoke(null) as AseNode; return(node); } else { return(parser as AseNode); } }
protected override void ProcessInnerNode(AseReader reader, AseNode parentNode) { AseStringTokenizer tokens; switch (reader.NodeName) { case "TM_ROW0": tokens = new AseStringTokenizer(reader.NodeData); this[0, 0] = float.Parse(tokens.GetNext()); this[0, 1] = float.Parse(tokens.GetNext()); this[0, 2] = float.Parse(tokens.GetNext()); this[0, 3] = 0.0f; break; case "TM_ROW1": tokens = new AseStringTokenizer(reader.NodeData); this[1, 0] = float.Parse(tokens.GetNext()); this[1, 1] = float.Parse(tokens.GetNext()); this[1, 2] = float.Parse(tokens.GetNext()); this[1, 3] = 0.0f; break; case "TM_ROW2": tokens = new AseStringTokenizer(reader.NodeData); this[2, 0] = float.Parse(tokens.GetNext()); this[2, 1] = float.Parse(tokens.GetNext()); this[2, 2] = float.Parse(tokens.GetNext()); this[2, 3] = 0.0f; break; case "TM_ROW3": tokens = new AseStringTokenizer(reader.NodeData); this[3, 0] = float.Parse(tokens.GetNext()); this[3, 1] = float.Parse(tokens.GetNext()); this[3, 2] = float.Parse(tokens.GetNext()); this[3, 3] = 1.0f; break; } }
protected override void ProcessNodePre(AseReader reader, AseNode parentNode) { AseRoot root = parentNode as AseRoot; root.MaterialList = this; }
protected virtual void ProcessInnerNode(AseReader reader, AseNode parentNode) { // do nothing }
protected void AddNodeParser(string nodeName, AseNode parser) { _nodeParsers.Add(nodeName, parser); }
protected override void ProcessNodePre(AseReader reader, AseNode parentNode) { AseRoot root = parentNode as AseRoot; root.AddGeometryObject(this); }
protected override void ProcessInnerNode(AseReader reader, AseNode parentNode) { if (reader.NodeName == "MESH_FACE") { AseStringTokenizer tokens = new AseStringTokenizer(reader.NodeData); string indexStr = tokens.GetNext(); if (indexStr.EndsWith(":")) { indexStr = indexStr.Substring(0, indexStr.Length - 1).Trim(); } int index = int.Parse(indexStr); for (int i = 0; i < 3; i++) { string type = tokens.GetNext(); int value = int.Parse(tokens.GetNext()); if (type == "A:") { _faces[index].A = value; } else if (type == "B:") { _faces[index].B = value; } else if (type == "C:") { _faces[index].C = value; } } for (int i = 0; i < 3; i++) { string type = tokens.GetNext(); bool value = int.Parse(tokens.GetNext()) != 0; if (type == "AB:") { _faces[index].EdgeAB = value; } else if (type == "BC:") { _faces[index].EdgeBC = value; } else if (type == "CA:") { _faces[index].EdgeCA = value; } } while (tokens.HasMore()) { string extended = tokens.GetNext(); if (extended.StartsWith("*")) { if (extended == "*MESH_SMOOTHING") { if (tokens.Peek().StartsWith("*")) { continue; } string[] meshSmooth = tokens.GetNext().Split(','); _faces[index].SmoothingCount = meshSmooth.Length; for (int i = 0; i < meshSmooth.Length; i++) { _faces[index][i] = int.Parse(meshSmooth[i]); } } else if (extended == "*MESH_MTLID") { if (tokens.Peek().StartsWith("*")) { continue; } _faces[index].MaterialID = int.Parse(tokens.GetNext()); } } } } }
protected virtual void ProcessNodePost(AseReader reader, AseNode parentNode) { // do nothing }