示例#1
0
        public PSphere AddSphere()
        {
            PSphere newSphere = new PSphere();

            newSphere.ParentModel = this;
            int i = 0;

            foreach (PSphere sphere in Spheres)
            {
                if (sphere.ID == i)
                {
                    i++;
                    continue;
                }
                i++;
            }
            newSphere.ID = i;
            Spheres.Add(newSphere);

            return(newSphere);
        }
示例#2
0
        public static void ReadFile()
        {
            Models.Clear();

            Console.WriteLine("Reading models...");

            using (var file = File.OpenRead(@"sys\Package5.txt"))
            {
                if (file.Length == 0)
                {
                    return;
                }
                using (var reader = new BinaryReader(file))
                {
                    int count = reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        GameModel model = new GameModel();
                        model.ID           = reader.ReadInt32();
                        model.name         = reader.ReadString();
                        model.resourcePath = reader.ReadString();
                        model.ModelID      = reader.ReadInt32();
                        model.Scale        = reader.ReadSingle();

                        if (ModelList.ContainsKey(model.resourcePath))
                        {
                            model.model = ModelList[model.resourcePath];
                        }
                        else
                        {
                            Console.WriteLine("Attempted to load invalid model -- " + model.resourcePath);
                        }

                        int SphereCount = reader.ReadInt32();

                        for (int k = 0; k < SphereCount; k++)
                        {
                            PSphere sphere = new PSphere(reader.ReadInt32(), model);
                            sphere.Part          = (PType)Enum.Parse(typeof(PType), reader.ReadString());
                            sphere.BoneName      = reader.ReadString();
                            sphere.AnchorPoint.X = reader.ReadSingle();
                            sphere.AnchorPoint.Y = reader.ReadSingle();
                            sphere.AnchorPoint.Z = reader.ReadSingle();
                            sphere.Radius        = reader.ReadSingle();

                            sphere.SetSphere();

                            model.Spheres.Add(sphere);
                        }
                        Models.Add(model);

                        int DefaultCount = reader.ReadInt32();

                        for (int j = 0; j < DefaultCount; j++)
                        {
                            string Name   = reader.ReadString();
                            int    PCount = reader.ReadInt32();

                            DefaultPhysics.Add(Name, new DefaultSpheres());

                            for (int m = 0; m < PCount; m++)
                            {
                                PSphere sphere = new PSphere(reader.ReadInt32(), null);
                                sphere.Part          = (PType)Enum.Parse(typeof(PType), reader.ReadString());
                                sphere.BoneName      = reader.ReadString();
                                sphere.AnchorPoint.X = reader.ReadSingle();
                                sphere.AnchorPoint.Y = reader.ReadSingle();
                                sphere.AnchorPoint.Z = reader.ReadSingle();
                                sphere.Radius        = reader.ReadSingle();

                                sphere.SetSphere();

                                DefaultPhysics[Name].Spheres.Add(sphere);
                            }
                        }
                    }
                }
            }
            Console.WriteLine("---Complete!");
        }