Beispiel #1
0
        public static Node3D LoadNode(string path)
        {
            FileStream   fs = new FileStream(path, FileMode.Open, FileAccess.Read);
            BinaryReader r  = new BinaryReader(fs);

            Help.IOHelp.r = r;

            int et = IOHelp.ReadInt();

            switch (et)
            {
            case 1:
                var new_ent = new Entity3D();
                new_ent.Read();
                fs.Close();
                return(new_ent);

                break;

            case 2:
                var new_node = new Node3D();
                new_node.Read();
                fs.Close();
                return(new_node);

                break;
            }

            fs.Close();
            return(null);
        }
Beispiel #2
0
 public override void SaveNode()
 {
     IOHelp.WriteFloat(_Width);
     IOHelp.WriteFloat(_Depth);
     IOHelp.WriteFloat(_YScale);
     IOHelp.WriteString(_HeightMapPath);
 }
Beispiel #3
0
 public void Read()
 {
     LocalTurn = IOHelp.ReadMatrix();
     LocalPos  = IOHelp.ReadVec3();
     MinZ      = IOHelp.ReadFloat();
     MaxZ      = IOHelp.ReadFloat();
     LR        = IOHelp.ReadVec3();
 }
Beispiel #4
0
 public void Write()
 {
     IOHelp.WriteMatrix(LocalTurn);
     IOHelp.WriteVec(LocalPos);
     IOHelp.WriteFloat(MinZ);
     IOHelp.WriteFloat(MaxZ);
     IOHelp.WriteVec(LR);
 }
Beispiel #5
0
 public void WriteClass(object cls)
 {
     IOHelp.WriteString(cls.GetType().Name);
     IOHelp.WriteInt(cls.GetType().GetProperties().Length);
     foreach (var prop in cls.GetType().GetProperties())
     {
         IOHelp.WriteString(prop.GetType().Name);
         var val = prop.GetValue(cls);
         WriteVal(val);
     }
 }
Beispiel #6
0
    public override void LoadNode()
    {
        _Width         = IOHelp.ReadFloat();
        _Depth         = IOHelp.ReadFloat();
        _YScale        = IOHelp.ReadFloat();
        _HeightMapPath = IOHelp.ReadString();
        Node3D prev_t = SceneGraph3D.CurScene.FindNode("TerrainObjNode");

        if (prev_t != null)
        {
            TerrainNode = prev_t as Terrain3D;
            //    SceneGraph3D.CurScene.Remove(prev_t);
        }
    }
Beispiel #7
0
        public void SaveNode(string path)
        {
            FileStream   fs = new FileStream(path, FileMode.Create, FileAccess.Write);
            BinaryWriter bw = new BinaryWriter(fs);

            Help.IOHelp.w = bw;

            if (this is Entity3D)
            {
                IOHelp.WriteInt(1);
                this.Write();
            }
            else if (this is Node3D)
            {
                IOHelp.WriteInt(2);
                this.Write();
            }

            bw.Flush();
            fs.Flush();
            fs.Close();
        }
Beispiel #8
0
        private void WriteVal(object val)
        {
            if (val == null)
            {
                IOHelp.WriteInt(-1);
            }
            else
            if (val is string)
            {
                IOHelp.WriteInt(0);
                IOHelp.WriteString(val as string);
            }
            else
            if (val is int)
            {
                IOHelp.WriteInt(1);
                IOHelp.WriteInt((int)val);
            }
            else
            if (val is float)
            {
                IOHelp.WriteInt(2);
                IOHelp.WriteFloat((float)val);
            }
            else
            if (val is double)
            {
                IOHelp.WriteInt(3);
                IOHelp.WriteDouble((double)val);
            }
            else
            if (val is Texture.Texture2D)
            {
                IOHelp.WriteInt(4);
                IOHelp.WriteTexture2D(val as Texture.Texture2D);
            }
            else if (val is bool)
            {
                IOHelp.WriteInt(5);
                IOHelp.WriteBool((bool)val);
            }
            else if (val is Vector3)
            {
                IOHelp.WriteInt(6);
                IOHelp.WriteVec((Vector3)val);
            }
            else if (val is Vector4)
            {
                IOHelp.WriteInt(7);
                IOHelp.WriteVec((Vector4)val);
            }
            else if (val is Matrix4)
            {
                IOHelp.WriteInt(8);
                IOHelp.WriteMatrix((Matrix4)val);
            }
            else
            {
                if (val.GetType().Name.Contains("List"))
                {
                    IOHelp.WriteInt(9);

                    dynamic vo = val;

                    IOHelp.WriteInt(vo.Count);

                    //dynamic vo = val;

                    foreach (dynamic vi in vo)
                    {
                        WriteVal(vi);
                    }
                }
                else
                {
                    //    IOHelp.WriteInt(10);
                    //     WriteClass(val);
                }
            }
        }
Beispiel #9
0
        public void ReadClass(object cls)
        {
            var cn = IOHelp.ReadString();
            var np = IOHelp.ReadInt();

            foreach (var prop in cls.GetType().GetProperties())
            {
                var pn = IOHelp.ReadString();
                int pt = IOHelp.ReadInt();
                switch (pt)
                {
                case -1:
                    prop.SetValue(cls, null);
                    break;

                case 0:
                    prop.SetValue(cls, IOHelp.ReadString());
                    break;

                case 1:
                    prop.SetValue(cls, IOHelp.ReadInt());
                    break;

                case 2:
                    prop.SetValue(cls, IOHelp.ReadFloat());
                    break;

                case 3:
                    prop.SetValue(cls, IOHelp.ReadDouble());
                    break;

                case 4:
                    prop.SetValue(cls, IOHelp.ReadTexture2D());
                    break;

                case 5:
                    prop.SetValue(cls, IOHelp.ReadBool());
                    break;

                case 6:
                    prop.SetValue(cls, IOHelp.ReadVec3());
                    break;

                case 7:
                    prop.SetValue(cls, IOHelp.ReadVec4());
                    break;

                case 8:
                    prop.SetValue(cls, IOHelp.ReadMatrix());
                    break;

                case 9:

                    dynamic nl = prop.GetValue(cls);

                    nl.Clear();

                    int ec = IOHelp.ReadInt();

                    for (int i = 0; i < ec; i++)
                    {
                    }


                    break;
                }
            }
        }
Beispiel #10
0
 public override void LoadNode()
 {
     _Body        = (BodyType)IOHelp.ReadInt();
     _InertiaDrag = IOHelp.ReadInt();
 }
Beispiel #11
0
 public override void SaveNode()
 {
     IOHelp.WriteInt((int)_Body);
     IOHelp.WriteFloat(_InertiaDrag);
 }
Beispiel #12
0
 public override void LoadNode()
 {
     SongPath = IOHelp.ReadString();
 }
Beispiel #13
0
 public override void SaveNode()
 {
     IOHelp.WriteString(SongPath);
 }