예제 #1
0
    public static void SaveBool(LBinaryFile fs, bool val)
    {
        if (fs == null || fs.Writer == null)
        {
            return;
        }

        fs.Writer.Write(val ? 1 : 0);
    }
예제 #2
0
    public static void SaveVector3(LBinaryFile fs, Vector3 vec)
    {
        if (fs == null || fs.Writer == null)
        {
            return;
        }

        fs.Writer.Write(vec.x);
        fs.Writer.Write(vec.y);
        fs.Writer.Write(vec.z);
    }
예제 #3
0
    public static void SaveColor(LBinaryFile fs, Color col)
    {
        if (fs == null || fs.Writer == null)
        {
            return;
        }

        fs.Writer.Write(col.r);
        fs.Writer.Write(col.g);
        fs.Writer.Write(col.b);
        fs.Writer.Write(col.a);
    }
예제 #4
0
    public static void SaveQuaternion(LBinaryFile fs, Quaternion rot)
    {
        if (fs == null || fs.Writer == null)
        {
            return;
        }

        fs.Writer.Write(rot.x);
        fs.Writer.Write(rot.y);
        fs.Writer.Write(rot.z);
        fs.Writer.Write(rot.w);
    }
예제 #5
0
    public virtual bool Load(LBinaryFile fs, uint version)
    {
        Normal = SLBinary.LoadVector3(fs);
        Dist   = fs.Reader.ReadSingle();
        int elenum = fs.Reader.ReadInt32();

        for (int i = 0; i < elenum; i++)
        {
            int vid = fs.Reader.ReadInt32();
            AddElement(vid);
        }
        return(true);
    }
예제 #6
0
    public static bool LoadBool(LBinaryFile fs)
    {
        bool val = false;

        if (fs == null || fs.Reader == null)
        {
            return(val);
        }

        val = (fs.Reader.ReadInt32() != 0);

        return(val);
    }
예제 #7
0
    public virtual bool Save(LBinaryFile fs)
    {
        SLBinary.SaveVector3(fs, Normal);
        fs.Writer.Write(Dist);
        int elenum = GetEdgeNum();

        fs.Writer.Write(elenum);
        for (int i = 0; i < elenum; i++)
        {
            fs.Writer.Write(mLstVIDs[i]);
        }
        return(true);
    }
예제 #8
0
    public static void SaveBounds(LBinaryFile fs, Bounds bounds)
    {
        if (fs == null || fs.Writer == null)
        {
            return;
        }

        fs.Writer.Write(bounds.center.x);
        fs.Writer.Write(bounds.center.y);
        fs.Writer.Write(bounds.center.z);
        fs.Writer.Write(bounds.extents.x);
        fs.Writer.Write(bounds.extents.y);
        fs.Writer.Write(bounds.extents.z);
    }
예제 #9
0
    public static Vector3 LoadVector3(LBinaryFile fs)
    {
        Vector3 vec = Vector3.zero;

        if (fs == null || fs.Reader == null)
        {
            return(vec);
        }

        vec.x = fs.Reader.ReadSingle();
        vec.y = fs.Reader.ReadSingle();
        vec.z = fs.Reader.ReadSingle();
        return(vec);
    }
예제 #10
0
    public static void SaveAABB(LBinaryFile fs, Bounds aabb)
    {
        if (fs == null || fs.Writer == null)
        {
            return;
        }

        fs.Writer.Write(aabb.center.x);
        fs.Writer.Write(aabb.center.y);
        fs.Writer.Write(aabb.center.z);
        fs.Writer.Write(aabb.extents.x);
        fs.Writer.Write(aabb.extents.y);
        fs.Writer.Write(aabb.extents.z);
    }
예제 #11
0
    public static Quaternion LoadQuaternion(LBinaryFile fs)
    {
        Quaternion rot = Quaternion.identity;

        if (fs == null || fs.Reader == null)
        {
            return(rot);
        }

        rot.x = fs.Reader.ReadSingle();
        rot.y = fs.Reader.ReadSingle();
        rot.z = fs.Reader.ReadSingle();
        rot.w = fs.Reader.ReadSingle();
        return(rot);
    }
예제 #12
0
    public static Color LoadColor(LBinaryFile fs)
    {
        UnityEngine.Color col = Color.white;
        if (fs == null || fs.Reader == null)
        {
            return(col);
        }

        col.r = fs.Reader.ReadSingle();
        col.g = fs.Reader.ReadSingle();
        col.b = fs.Reader.ReadSingle();
        col.a = fs.Reader.ReadSingle();

        return(col);
    }
예제 #13
0
    public bool Save(LBinaryFile fs)
    {
        SLBinary.SaveAABB(fs, BoundAABB);
        fs.Writer.Write(Flags);
        int numsides = LstSides.Count;

        fs.Writer.Write(numsides);
        for (int i = 0; i < numsides; i++)
        {
            SLBinary.SaveVector3(fs, LstSides[i].Plane.Normal);
            fs.Writer.Write(LstSides[i].Plane.Dist);
            SLBinary.SaveBool(fs, LstSides[i].Bevel);
        }

        return(true);
    }
예제 #14
0
    public virtual bool Save(LBinaryFile fs)
    {
        fs.Writer.Write(mFlags);
        int vertnum = GetVertexNum();

        fs.Writer.Write(vertnum);
        for (int i = 0; i < vertnum; i++)
        {
            SLBinary.SaveVector3(fs, mLstVertices[i]);
        }
        int facenum = GetFaceNum();

        fs.Writer.Write(facenum);
        for (int i = 0; i < facenum; i++)
        {
            mLstCovFace[i].Save(fs);
        }
        return(true);
    }
예제 #15
0
    // Load and save method
    public bool Load(LBinaryFile fs)
    {
        Release();
        BoundAABB = SLBinary.LoadAABB(fs);
        Flags     = fs.Reader.ReadUInt32();
        int numsides = fs.Reader.ReadInt32();

        for (int i = 0; i < numsides; i++)
        {
            Vector3 normal = SLBinary.LoadVector3(fs);
            float   dist   = fs.Reader.ReadSingle();
            bool    bevel  = SLBinary.LoadBool(fs);
            CDSide  side   = new CDSide();
            side.Init(normal, dist, bevel);
            LstSides.Add(side);
        }

        return(true);
    }
예제 #16
0
    public static string LoadString(LBinaryFile fs)
    {
        string str = "";

        if (fs == null || fs.Reader == null)
        {
            return(str);
        }

        int len = fs.Reader.ReadInt32();

        if (len > 0)
        {
            byte[] buf = fs.Reader.ReadBytes(len);
            str = fs.CurEncoding.GetString(buf);
        }

        return(str);
    }
예제 #17
0
    public static void SaveString(LBinaryFile fs, string str)
    {
        if (fs == null || fs.Writer == null)
        {
            return;
        }

        if (string.IsNullOrEmpty(str))
        {
            str = "";
        }

        byte[] buf = fs.CurEncoding.GetBytes(str);
        fs.Writer.Write(buf.Length);
        if (buf.Length > 0)
        {
            fs.Writer.Write(buf);
        }
    }
예제 #18
0
    public static Bounds LoadAABB(LBinaryFile fs)
    {
        Bounds aabb = new Bounds();

        if (fs == null || fs.Reader == null)
        {
            return(aabb);
        }

        Vector3 center  = Vector3.zero;
        Vector3 extents = Vector3.zero;

        center.x     = fs.Reader.ReadSingle();
        center.y     = fs.Reader.ReadSingle();
        center.z     = fs.Reader.ReadSingle();
        extents.x    = fs.Reader.ReadSingle();
        extents.y    = fs.Reader.ReadSingle();
        extents.z    = fs.Reader.ReadSingle();
        aabb.center  = center;
        aabb.extents = extents;
        return(aabb);
    }
예제 #19
0
    public static Bounds LoadBounds(LBinaryFile fs)
    {
        Bounds bounds = new Bounds();

        if (fs == null || fs.Reader == null)
        {
            return(bounds);
        }

        Vector3 center  = Vector3.zero;
        Vector3 extents = Vector3.zero;

        center.x       = fs.Reader.ReadSingle();
        center.y       = fs.Reader.ReadSingle();
        center.z       = fs.Reader.ReadSingle();
        extents.x      = fs.Reader.ReadSingle();
        extents.y      = fs.Reader.ReadSingle();
        extents.z      = fs.Reader.ReadSingle();
        bounds.center  = center;
        bounds.extents = extents;

        return(bounds);
    }
예제 #20
0
    public virtual bool Load(LBinaryFile fs, uint version)
    {
        Reset();

        mFlags = fs.Reader.ReadUInt32();
        int vertnum = fs.Reader.ReadInt32();

        for (int i = 0; i < vertnum; i++)
        {
            Vector3 vec = SLBinary.LoadVector3(fs);
            mLstVertices.Add(vec);
        }
        int facenum = fs.Reader.ReadInt32();

        for (int i = 0; i < facenum; i++)
        {
            CovFace face = new CovFace();
            face.Load(fs, version);
            mLstCovFace.Add(face);
        }
        //mAABBDirty = true;

        return(true);
    }