Ejemplo n.º 1
0
 public BodyPart(PaintedCubeSpace nModel, Vector3 nLoc, BodyPartType nType, string nFileName)
 {
     model           = nModel;
     model.loc       = nLoc;
     children        = new List <BodyPart>();
     animationSystem = new noAnimation();
     type            = nType;
     fileName        = nFileName;
     rotationOffset  = Quaternion.Identity;
 }
Ejemplo n.º 2
0
        static PaintedCubeSpace loadSpaceFromLoadedSpaces(string path)
        {
            LoadedCubeSpaceData data = loadedByteArrays[path];

            PaintedCubeSpace space = new PaintedCubeSpace(data.spaceWidth, data.spaceHeight, new Vector3());

            space.array = /*new byte[data.spaceWidth, data.spaceHeight, data.spaceWidth];*/ data.array;
            //data.unmippedArray.CopyTo(maybeSpace.unmippedArray, 0);
            space.setUnmippedBuffers(data.vertexBuffer, data.indexBuffer);
            space.setLoadedFrompath(path);
            return(space);
        }
Ejemplo n.º 3
0
        public void replacePart(BodyPart toReplace, PaintedCubeSpace replacement)
        {
            if (toReplace == this)
            {
                model.replaceArrayWith(replacement.array);

                return;
            }
            foreach (BodyPart child in children)
            {
                child.replacePart(toReplace, replacement);
            }
        }
Ejemplo n.º 4
0
        static PaintedCubeSpace loadSpaceFromDisk(string path)
        {
            byte[, ,] byteArray;
            string fullPath = ContentDistributor.addNecesaryPathing(path);
            Stream stream   = File.Open(fullPath, FileMode.Open);

            BinaryFormatter formatter = new BinaryFormatter();

            byteArray = (byte[, , ])formatter.Deserialize(stream);

            FileInfo fileInfo    = new FileInfo(fullPath);
            long     fileLength  = fileInfo.Length;
            int      spaceWidth  = (int)Math.Pow(fileLength, 1.0 / 3.0);
            int      spaceHeight = (int)Math.Pow(fileLength, 1.0 / 3.0);

            stream.Close();

            //loadedByteArrays.Add(path, byteArray);
            PaintedCubeSpace paintedCubeSpace = new PaintedCubeSpace(1, 1, new Vector3());

            paintedCubeSpace.spaceWidth  = spaceWidth;
            paintedCubeSpace.spaceHeight = spaceHeight;
            paintedCubeSpace.array       = byteArray;

            paintedCubeSpace.createModel(Main.graphics.GraphicsDevice);

            LoadedCubeSpaceData dataToSave = new LoadedCubeSpaceData();

            dataToSave.array        = byteArray;
            dataToSave.spaceHeight  = spaceHeight;
            dataToSave.spaceWidth   = spaceWidth;
            dataToSave.vertexBuffer = paintedCubeSpace.getVertexBuffer();
            dataToSave.indexBuffer  = paintedCubeSpace.getIndexBuffer();
            loadedByteArrays.Add(path, dataToSave);

            paintedCubeSpace.setLoadedFrompath(path);
            return(paintedCubeSpace);
        }
Ejemplo n.º 5
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);
            }
        }