Beispiel #1
0
    public static string ReadLU3(string file, ref SiSpillets[] spillRec)
    {
        FileStream fs = null;
        BinaryReader reader = null;

        try
        {
            fs = File.Open(file,FileMode.Open,FileAccess.Read);
            long recCount = fs.Length/96;
            spillRec = new SiSpillets[recCount];
            reader = new BinaryReader(fs);
            for(int i = 0; i < recCount; i++)
            {
                spillRec[i] = new SiSpillets();
                spillRec[i].iver = reader.ReadInt32();
                spillRec[i].simtime = reader.ReadInt32();
                spillRec[i].time = reader.ReadSingle();
                spillRec[i].rec1st = reader.ReadInt32();
                spillRec[i].rec2st = reader.ReadInt32();
                spillRec[i].rec2end = reader.ReadInt32();
                spillRec[i].rec3st = reader.ReadInt32();
                spillRec[i].rec3end = reader.ReadInt32();
                spillRec[i].rec5st = reader.ReadInt32();
                spillRec[i].rec5end = reader.ReadInt32();
                spillRec[i].sed2st = reader.ReadInt32();
                spillRec[i].sed2end = reader.ReadInt32();
                spillRec[i].rar1st = reader.ReadInt32();
                spillRec[i].rar1end = reader.ReadInt32();
                spillRec[i].rth1st = reader.ReadInt32();
                spillRec[i].rth1end = reader.ReadInt32();
                spillRec[i].rsf1st = reader.ReadInt32();
                spillRec[i].rsf1end = reader.ReadInt32();
                spillRec[i].rsp1st = reader.ReadInt32();
                spillRec[i].rsp1end = reader.ReadInt32();
                spillRec[i].rss1st = reader.ReadInt32();
                spillRec[i].rss1end = reader.ReadInt32();
                spillRec[i].rat1st = reader.ReadInt32();
                spillRec[i].rat1end = reader.ReadInt32();
            }
        }
        catch (Exception ex)
        {
            return "Error: " + ex.Message;
        }
        finally
        {
            if(fs != null)
                fs.Close();
            if(reader != null)
                reader.Close();
        }
        return "LU3 file read!";
    }
Beispiel #2
0
    public static string ReadTR3(string file, SiSpillets[] recs, ref Particle3D[] parts,int recNum)
    {
        int fpos = 0;
        FileStream fs_tr3 = null;
        BinaryReader reader = null;
        try
        {
            fs_tr3 = File.Open(file,FileMode.Open,FileAccess.Read);
            reader = new BinaryReader(fs_tr3);

            System.Array.Resize(ref parts, (recs[recNum].rec2end-recs[recNum].rec2st)+1);

            fpos = (recs[recNum].rec2st-1)*40;

            reader.BaseStream.Seek(fpos,SeekOrigin.Begin);
            for(int i = 0; i < parts.Length; i++)
            {
                parts[i] = new Particle3D(reader.ReadSingle(),reader.ReadSingle(),reader.ReadSingle(),reader.ReadSingle(),reader.ReadSingle(),reader.ReadInt32(),reader.ReadSingle(),reader.ReadSingle(),reader.ReadSingle(),reader.ReadSingle());
            }
            reader.Close();
            fs_tr3.Close();
            fs_tr3.Dispose();
        }
        catch (Exception ex)
        {
            return "Error: ReadTR3: " + ex.Message;
        }
        finally
        {
            if(reader != null)
                reader.Close();
            if(fs_tr3 != null)
            {
                fs_tr3.Close();
            }
        }
        return "READ OK";
    }