Beispiel #1
0
        public static void SavePrims(ISceneProvider scene, string primsPath, string assetsPath, string textureCacheFolder)
        {
            Dictionary<UUID, UUID> textureList = new Dictionary<UUID, UUID>();

            // Delete all of the old linkset files
            try { Directory.Delete(primsPath, true); }
            catch (Exception) { }

            // Create a new folder for the linkset files
            try { Directory.CreateDirectory(primsPath); }
            catch (Exception ex)
            {
                Logger.Log("Failed saving prims: " + ex.Message, Helpers.LogLevel.Error);
                return;
            }

            // Copy the double dictionary to a temporary list for iterating
            List<SimulationObject> primList = new List<SimulationObject>();
            scene.ForEachObject(delegate(SimulationObject prim)
            {
                if (!(prim.Prim is Avatar))
                    primList.Add(prim);
            });

            foreach (SimulationObject p in primList)
            {
                if (p.Prim.ParentID == 0)
                {
                    Linkset linkset = new Linkset();
                    linkset.Parent = p;
                    linkset.Children = p.GetChildren();

                    SaveLinkset(linkset, Path.Combine(primsPath, "Primitive_" + linkset.Parent.Prim.ID.ToString() + ".xml"));
                }

                // Add all of the textures on this prim to the save list
                for (int i = 0; i < p.Prim.Textures.FaceTextures.Length; i++)
                {
                    Primitive.TextureEntryFace face = p.Prim.Textures.FaceTextures[i];
                    if (face != null && !textureList.ContainsKey(face.TextureID))
                        textureList.Add(face.TextureID, face.TextureID);
                }
            }

            SaveTextures(new List<UUID>(textureList.Keys), assetsPath, textureCacheFolder);
        }
Beispiel #2
0
        static void SOGToXml2(XmlTextWriter writer, Linkset linkset)
        {
            writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
            SOPToXml(writer, linkset.Parent, null);
            writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);

            foreach (SimulationObject child in linkset.Children)
                SOPToXml(writer, child, linkset.Parent);

            writer.WriteEndElement();
            writer.WriteEndElement();
        }
Beispiel #3
0
 static void SaveLinkset(Linkset linkset, string filename)
 {
     try
     {
         using (StreamWriter stream = new StreamWriter(filename))
         {
             XmlTextWriter writer = new XmlTextWriter(stream);
             SOGToXml2(writer, linkset);
             writer.Flush();
         }
     }
     catch (Exception ex)
     {
         Logger.Log("Failed saving linkset: " + ex.Message, Helpers.LogLevel.Error);
     }
 }