private void ReadObject(ReadChunk chunk) { ReadChunk data; BinaryReader input = chunk.Bytes; string type = ReadUtil.ReadUTF(chunk.Bytes); string name = ReadUtil.ReadUTF(chunk.Bytes); //名字不能包含\ name = System.Text.RegularExpressions.Regex.Replace(name, @"/+|\*+|\\+", string.Empty); if (!uniqueName.ContainsKey(name)) { uniqueName.Add(name, 1); } else { uniqueName[name]++; if (uniqueName[name] > 1) { name = name + uniqueName[name].ToString(); } } UnityEngine.Matrix4x4 matrix = ReadMatrix3D(chunk.Bytes, _compressionLevel); int layer = chunk.Bytes.ReadInt16(); int parent = chunk.Bytes.ReadInt16(); float frameSpeed = chunk.Bytes.ReadSingle(); if (parent != -1) { matrix = cascadeTransform[parent] * matrix; } cascadeTransform[chunk.Id] = matrix; while (chunk.BytesAvailable() > 0) { data = new ReadChunk(input); switch (data.Name) { case "particleSysterm": ReadParticleSystem(name, layer, matrix, data, parent, chunk.Id); break; case "extends": ReadExtends(data); break; default: System.Diagnostics.Debug.WriteLine("未识别属性{0}", data.Name); break; } data.Next(); } }
private void loadDataChunk(BinaryReader binReader) { binReader.BaseStream.Seek(0, SeekOrigin.Begin); while (binReader.BaseStream.Position < binReader.BaseStream.Length) { ReadChunk chunk = new ReadChunk(binReader); switch (chunk.Name) { case "data": ReadData(chunk); break; case "tex": ReadTexture(chunk); break; case "buffer": ReadBuffer(chunk); break; case "idx": ReadIndices(chunk); break; case "surf_ps": ReadPSSurface(chunk); break; case "obj": ReadObject(chunk); break; default: System.Diagnostics.Debug.Print("未识别的类型 {0}", chunk.Name); break; } chunk.Next(); } }