Beispiel #1
0
    private void ReadTexture(ReadChunk chunk)
    {
        Texture3D texture      = null;
        bool      optimized    = chunk.Bytes.ReadBoolean();
        int       typeMode     = chunk.Bytes.ReadSByte();
        int       formatMode   = chunk.Bytes.ReadSByte();
        int       texture_type = chunk.Bytes.ReadSByte();

        switch (texture_type)
        {
        case Texture_EMBED:
            int    length = (int)chunk.Bytes.ReadUInt32();
            byte[] data   = chunk.Bytes.ReadBytes(length);
            texture = new Texture3D(data, optimized, formatMode, typeMode);
            //chunk.Bytes.BaseStream.Seek(chunk.Bytes.BaseStream.Position + length, SeekOrigin.Begin);
            break;

        default:
            return;
        }
        texture.Name       = ReadUtil.ReadUTF(chunk.Bytes);
        texture.FilterMode = chunk.Bytes.ReadSByte();
        texture.WrapMode   = chunk.Bytes.ReadSByte();
        texture.MipMode    = chunk.Bytes.ReadSByte();

        resource[chunk.Id] = texture;
    }
Beispiel #2
0
        public void ReadCsvFileTest()
        {
            //create a file that we will try to read using the component
            var printFile = new PrintUtil
            {
                ForceCreation = true,
                OutputColumns = new List <string>(),
                PrintFileName = TxtTestFileName,
                PrintList     = "1234"
            };

            printFile.OutputColumns.Add("#");
            printFile.PrintFile();

            //check if file exists
            Assert.IsTrue(File.Exists(printFile.PrintFileName));

            //check if this file can be read
            Assert.IsTrue(ReadUtil.ReadCsvFile(printFile.PrintFileName).Count > 0);

            //check if the file was loaded with all records
            Assert.IsTrue(ReadUtil.ReadCsvFile(printFile.PrintFileName).Count == 4);

            //clean up now
            File.Delete(printFile.PrintFileName);
            Assert.IsFalse(File.Exists(printFile.PrintFileName));
        }
Beispiel #3
0
 public ReadChunk(System.IO.BinaryReader input)
 {
     this.name   = ReadUtil.ReadUTF(input);
     this.id     = input.ReadInt16();
     this.length = input.ReadUInt32();
     this.bytes  = input;
     this.pos    = input.BaseStream.Position;
 }
Beispiel #4
0
    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();
        }
    }
Beispiel #5
0
    private void ReadParticleSystem(string name, int layer, Matrix4x4 matrix, ReadChunk data, int parent, int chunkId)
    {
        int            texId      = data.Bytes.ReadUInt16();
        uint           surfId     = data.Bytes.ReadUInt16();
        string         jsonStr    = ReadUtil.ReadUTF(data.Bytes);
        JObject        jsonObject = JObject.Parse(jsonStr);
        ParticleSystem ps         = new ParticleSystem();

        ps.ChunkId = chunkId;
        ps.Name    = name;
        ps.Layer   = layer;
        ps.Matrix  = ScaleTransform(matrix, Uf3dLoader.vertexScale);
        ps.TexId   = texId;
        ps.SurfId  = surfId;
        ps.Parent  = parent;
        ps.deserialize(jsonObject);
        particleSystemList.Add(ps);
        //System.Diagnostics.Debug.WriteLine("粒子名字:{0}", name);
    }
Beispiel #6
0
        public void LoadRecords(string filePath)
        {
            //call generic csvReader to read filestream and pass the data as a memory object
            var resultData = ReadUtil.ReadCsvFile(filePath);

            //populate model based on data returned
            if (resultData.Count <= 0)
            {
                return;
            }
            foreach (var resultRow in resultData)
            {
                if (resultRow[0] == "FirstName")
                {
                    continue;
                }
                var contact = new ContactInfo();
                for (var i = 0; i < resultRow.Length; i++)
                {
                    if (i == 0)
                    {
                        contact.FirstName = resultRow[i];
                    }
                    if (i == 1)
                    {
                        contact.LastName = resultRow[i];
                    }
                    if (i == 2)
                    {
                        contact.Address = resultRow[i];
                    }
                    if (i == 2)
                    {
                        contact.StreetName = Regex.Replace(resultRow[i], "[0-9]", "");
                    }
                    if (i == 3)
                    {
                        contact.PhoneNumber = resultRow[i];
                    }
                }
                Records.Add(contact);
            }
        }