protected override object LoadData(Stream stream) { // We use a binary reader for this data. BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.ASCII); // Create a scene. Scene scene = new Scene(); // First, read the header. CaligariFileHeader header = new CaligariFileHeader(); header.Read(reader); // Here we can make sure that it really is a Caligari File. if (header.id != "Caligari " || header.dataMode != 'B') { System.Diagnostics.Debugger.Log(1, "File I/O", "File is not internally compatible.\n"); return(false); } // Now we go through the file, peeping at chunks. while (true) { // Peep at the next chunk. string type = Peep(reader); // Check for every type of chunk. if (type == "PolH") { // Read a polygon into the scene. PolygonChunk polyChunk = new PolygonChunk(); scene.Polygons.Add((Polygon)polyChunk.Read(reader)); } else if (type == "END ") { // It's the end of the file, so we may as well break. break; } else { // Well we don't know what type it is, so just read the generic chunk. CaligariChunk chunk = new CaligariChunk(); chunk.Read(reader); } } return(scene); }
protected override bool SaveData(object data, Stream stream) { // We use a binary writer to write the data. BinaryWriter writer = new BinaryWriter(stream, System.Text.Encoding.ASCII); // Cast the data to a scene. Scene scene = (Scene)data; // Write a file header. CaligariFileHeader header = new CaligariFileHeader(); header.Write(writer); // I haven't yet written the code to write trueSpace stuff. return(false); }
protected override bool SaveData(object data, Stream stream) { // We use a binary writer to write the data. BinaryWriter writer = new BinaryWriter(stream, System.Text.Encoding.ASCII); // Cast the data to a scene. Scene scene = (Scene)data; // Write a file header. CaligariFileHeader header = new CaligariFileHeader(); header.Write(writer); // I haven't yet written the code to write trueSpace stuff. return false; }
protected override object LoadData(Stream stream) { // We use a binary reader for this data. BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.ASCII); // Create a scene. Scene scene = new Scene(); // First, read the header. CaligariFileHeader header = new CaligariFileHeader(); header.Read(reader); // Here we can make sure that it really is a Caligari File. if(header.id != "Caligari " || header.dataMode != 'B') { System.Diagnostics.Debugger.Log(1, "File I/O", "File is not internally compatible.\n"); return false; } // Now we go through the file, peeping at chunks. while(true) { // Peep at the next chunk. string type = Peep(reader); // Check for every type of chunk. if(type == "PolH") { // Read a polygon into the scene. PolygonChunk polyChunk = new PolygonChunk(); scene.Polygons.Add((Polygon)polyChunk.Read(reader)); } else if(type == "END ") { // It's the end of the file, so we may as well break. break; } else { // Well we don't know what type it is, so just read the generic chunk. CaligariChunk chunk = new CaligariChunk(); chunk.Read(reader); } } return scene; }