Exemplo n.º 1
0
 public void loadFromFile(string path)
 {
     string[] file = DataLoader.getCharFile(ContentDistributor.getRealRootPath() + path);
     main = new BodyPart();
     main.loadFromFile(file, 0, new FileInfo(ContentDistributor.getRealRootPath() + path));
 }
Exemplo n.º 2
0
        public void loadFromFile(string[] file, int place, FileInfo characterFile)
        {
            if (characterFile.Extension.ToUpper().Equals(".CHR"))
            {
                int      bracketCount = 0;
                string[] firstLine    = file[place].Split(' ');
                fileName = firstLine[0];

                string voxelFilePath = fileName;
                if (fileName[0] == '.')
                {
                    voxelFilePath = (characterFile.DirectoryName + fileName.Substring(1));
                }

                model = DataLoader.loadSpaceFromName(voxelFilePath);

                model.setLoadedFrompath(voxelFilePath);

                //model.createModel(Main.graphics.GraphicsDevice);
                model.loc = new Vector3((float)Convert.ToDouble(firstLine[1]),
                                        (float)Convert.ToDouble(firstLine[2]),
                                        (float)Convert.ToDouble(firstLine[3]));

                rotationOffset = new Quaternion((float)Convert.ToDouble(firstLine[5]),
                                                (float)Convert.ToDouble(firstLine[6]),
                                                (float)Convert.ToDouble(firstLine[7]),
                                                (float)Convert.ToDouble(firstLine[8]));

                model.scale = (float)Convert.ToDouble(firstLine[9]);


                type = getBodyPartTypeFromString(firstLine[4]);

                place++;
                for (; place < file.Length; place++)
                {
                    if (file[place].Equals("["))
                    {
                        bracketCount++;
                    }
                    else if (file[place].Equals("]"))
                    {
                        bracketCount--;
                    }
                    if (bracketCount == 0)
                    {
                        break;
                    }
                    if (bracketCount == 1 && !file[place].Contains("]") && !file[place].Contains("["))
                    {
                        BodyPart newChild = new BodyPart();
                        newChild.loadFromFile(file, place, characterFile);
                        children.Add(newChild);
                    }
                }
            }
            else if (characterFile.Extension.ToUpper().Equals(".VOX"))
            {
                model = DataLoader.loadSpaceFromName(characterFile.FullName);

                model.setLoadedFrompath(characterFile.FullName);
            }
        }