static void writeData(VoxelVolumeData data, string path)
 {
     Stream stream = File.Open(path, FileMode.Create);
     BinaryFormatter bformatter = new BinaryFormatter();
     bformatter.Binder = new VersionDeserializationBinder();
     bformatter.Serialize(stream, data);
     stream.Close();
 }
 public static void WriteToDisk(string filePath, VoxelVolumeData data)
 {
     writeData(data, filePath);
 }
示例#3
0
  // ========================================
  //  VolumeCreator save and load operations
  // ========================================
  // Note that no distinction is made here between save-to-file and autosave/save-to-backup.
  //  All changes to this object's filePath and backupPath are made in the VolumeObjectEditor
  //  filePath must be fully-qualified
  public bool DoSaveToDisk( string filePath )
  { 
    if (filePath =="")
    {
      Debug.LogError("No path provided to save funciton.");
      return false;
    }

    #if VC_DEBUG
      Debug.Log("VC: Writing file to "+filePath);
    #endif

    Color[] pixels = texture.GetPixels();
    float[,] tmp_colors = new float[pixels.Length, 4];
    for (uint i=0; i<pixels.Length; i++)
    {
      tmp_colors[i,0] = pixels[i].r;
      tmp_colors[i,1] = pixels[i].g;
      tmp_colors[i,2] = pixels[i].b;
      tmp_colors[i,3] = pixels[i].a;
    }
    
    VoxelVolumeData volData = new VoxelVolumeData( this.data, tmp_colors, this.dimensions, this.voxelScale, this.centerOffset );
    
    try
    {
      VoxelVolumeBinaryHandler.WriteToDisk(filePath, volData);
    }
    catch (System.Exception e)
    {
      Debug.LogError(e);
      return false;
    }

    return true;
  }