private void ObjectLoadedHandler(AssetPrim linkset, long bytesRead, long totalBytes) { if (m_primMesher == null) { return; } // Get the root prim LLPrimitive parent = LLUtil.PrimObjectToLLPrim(linkset.Parent, m_scene, m_primMesher); // Get the child prims and sort them by link order SortedList <int, LLPrimitive> children = new SortedList <int, LLPrimitive>(linkset.Children.Count); for (int i = 0; i < linkset.Children.Count; i++) { children.Add(linkset.Children[i].LinkNumber, LLUtil.PrimObjectToLLPrim(linkset.Children[i], m_scene, m_primMesher)); } // Set the child prims as children of the root, in order foreach (LLPrimitive child in children.Values) { child.SetParent(parent, false, false); } // Send updates for everything m_scene.EntityAddOrUpdate(this, parent, UpdateFlags.FullUpdate, 0); foreach (LLPrimitive child in children.Values) { m_scene.EntityAddOrUpdate(this, child, UpdateFlags.FullUpdate, 0); } PrintProgress(bytesRead, totalBytes); }
public static void LoadObjects(byte[] objectData, SceneObjectLoadedCallback objectCallback, long bytesRead, long totalBytes) { XmlDocument doc = new XmlDocument(); using (XmlTextReader reader = new XmlTextReader(new MemoryStream(objectData))) { reader.WhitespaceHandling = WhitespaceHandling.None; doc.Load(reader); } XmlNode rootNode = doc.FirstChild; if (rootNode.LocalName.Equals("scene")) { foreach (XmlNode node in rootNode.ChildNodes) { AssetPrim linkset = new AssetPrim(node.OuterXml); if (linkset != null) { objectCallback(linkset, bytesRead, totalBytes); } } } else { AssetPrim linkset = new AssetPrim(rootNode.OuterXml); if (linkset != null) { objectCallback(linkset, bytesRead, totalBytes); } } }
public static void LoadObjects(byte[] objectData, SceneObjectLoadedCallback objectCallback, long bytesRead, long totalBytes) { XmlDocument doc = new XmlDocument(); using (XmlTextReader reader = new XmlTextReader(new MemoryStream(objectData))) { reader.WhitespaceHandling = WhitespaceHandling.None; doc.Load(reader); } XmlNode rootNode = doc.FirstChild; if (rootNode.LocalName.Equals("scene")) { foreach (XmlNode node in rootNode.ChildNodes) { AssetPrim linkset = new AssetPrim(node.OuterXml); if (linkset != null) objectCallback(linkset, bytesRead, totalBytes); } } else { AssetPrim linkset = new AssetPrim(rootNode.OuterXml); if (linkset != null) objectCallback(linkset, bytesRead, totalBytes); } }
public static void SOGToXml2(XmlTextWriter writer, AssetPrim prim) { writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); SOPToXml(writer, prim.Parent, null); writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); foreach (PrimObject child in prim.Children) { SOPToXml(writer, child, prim.Parent); } writer.WriteEndElement(); writer.WriteEndElement(); }
static void SavePrim(AssetPrim prim, string filename) { try { using (StreamWriter stream = new StreamWriter(filename)) { XmlTextWriter writer = new XmlTextWriter(stream); SOGToXml2(writer, prim); writer.Flush(); } } catch (Exception ex) { Logger.Log("Failed saving linkset: " + ex.Message, Helpers.LogLevel.Error); } }
private Asset CreateAssetWrapper(AssetType type) { Asset asset; switch (type) { case AssetType.Notecard: asset = new AssetNotecard(); break; case AssetType.LSLText: asset = new AssetScriptText(); break; case AssetType.LSLBytecode: asset = new AssetScriptBinary(); break; case AssetType.Texture: asset = new AssetTexture(); break; case AssetType.Object: asset = new AssetPrim(); break; case AssetType.Clothing: asset = new AssetClothing(); break; case AssetType.Bodypart: asset = new AssetBodypart(); break; case AssetType.Animation: asset = new AssetAnimation(); break; case AssetType.Sound: asset = new AssetSound(); break; case AssetType.Landmark: asset = new AssetLandmark(); break; case AssetType.Gesture: asset = new AssetGesture(); break; default: Logger.Log("Unimplemented asset type: " + type, Helpers.LogLevel.Error, Client); return null; } return asset; }
public static void SOGToXml2(XmlTextWriter writer, AssetPrim prim) { writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); SOPToXml(writer, prim.Parent, null); writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); foreach (PrimObject child in prim.Children) SOPToXml(writer, child, prim.Parent); writer.WriteEndElement(); writer.WriteEndElement(); }
static void SavePrim(AssetPrim prim, string filename) { try { using (StreamWriter stream = new StreamWriter(filename)) { XmlTextWriter writer = new XmlTextWriter(stream); writer.Formatting = Formatting.Indented; writer.Indentation = 4; writer.IndentChar = ' '; SOGToXml2(writer, prim); writer.Flush(); } } catch (Exception ex) { Logger.Log("Failed saving linkset: " + ex.Message, Helpers.LogLevel.Error); } }
private static bool LoadAsset(string assetPath, byte[] data, AssetLoadedCallback assetCallback, long bytesRead, long totalBytes) { // Right now we're nastily obtaining the UUID from the filename string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR); if (i == -1) { Logger.Log(String.Format( "[OarFile]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR), Helpers.LogLevel.Warning); return false; } string extension = filename.Substring(i); UUID uuid; UUID.TryParse(filename.Remove(filename.Length - extension.Length), out uuid); if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) { AssetType assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; Asset asset = null; switch (assetType) { case AssetType.Animation: asset = new AssetAnimation(uuid, data); break; case AssetType.Bodypart: asset = new AssetBodypart(uuid, data); break; case AssetType.Clothing: asset = new AssetClothing(uuid, data); break; case AssetType.Gesture: asset = new AssetGesture(uuid, data); break; case AssetType.Landmark: asset = new AssetLandmark(uuid, data); break; case AssetType.LSLBytecode: asset = new AssetScriptBinary(uuid, data); break; case AssetType.LSLText: asset = new AssetScriptText(uuid, data); break; case AssetType.Notecard: asset = new AssetNotecard(uuid, data); break; case AssetType.Object: asset = new AssetPrim(uuid, data); break; case AssetType.Sound: asset = new AssetSound(uuid, data); break; case AssetType.Texture: asset = new AssetTexture(uuid, data); break; default: Logger.Log("[OarFile] Unhandled asset type " + assetType, Helpers.LogLevel.Error); break; } if (asset != null) { assetCallback(asset, bytesRead, totalBytes); return true; } } Logger.Log("[OarFile] Failed to load asset", Helpers.LogLevel.Warning); return false; }
private static bool LoadAsset(string assetPath, byte[] data, AssetLoadedCallback assetCallback, long bytesRead, long totalBytes) { // Right now we're nastily obtaining the UUID from the filename string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR); if (i == -1) { Logger.Log(String.Format( "[OarFile]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR), Helpers.LogLevel.Warning); return(false); } string extension = filename.Substring(i); UUID uuid; UUID.TryParse(filename.Remove(filename.Length - extension.Length), out uuid); if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) { AssetType assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; Asset asset = null; switch (assetType) { case AssetType.Animation: asset = new AssetAnimation(uuid, data); break; case AssetType.Bodypart: asset = new AssetBodypart(uuid, data); break; case AssetType.Clothing: asset = new AssetClothing(uuid, data); break; case AssetType.Gesture: asset = new AssetGesture(uuid, data); break; case AssetType.Landmark: asset = new AssetLandmark(uuid, data); break; case AssetType.LSLBytecode: asset = new AssetScriptBinary(uuid, data); break; case AssetType.LSLText: asset = new AssetScriptText(uuid, data); break; case AssetType.Notecard: asset = new AssetNotecard(uuid, data); break; case AssetType.Object: asset = new AssetPrim(uuid, data); break; case AssetType.Sound: asset = new AssetSound(uuid, data); break; case AssetType.Texture: asset = new AssetTexture(uuid, data); break; default: Logger.Log("[OarFile] Unhandled asset type " + assetType, Helpers.LogLevel.Error); break; } if (asset != null) { assetCallback(asset, bytesRead, totalBytes); return(true); } } Logger.Log("[OarFile] Failed to load asset", Helpers.LogLevel.Warning); return(false); }
private static void LoadObjects(byte[] objectData, AssetLoadedCallback assetCallback) { // TODO: If we can get by without XmlDocument it will fix the memory problems when loading large XML files XmlDocument doc = new XmlDocument(); using (XmlTextReader reader = new XmlTextReader(new MemoryStream(objectData))) { reader.WhitespaceHandling = WhitespaceHandling.None; doc.Load(reader); } XmlNode rootNode = doc.FirstChild; if (rootNode.LocalName.Equals("scene")) { foreach (XmlNode node in rootNode.ChildNodes) { AssetPrim linkset = new AssetPrim(node.OuterXml); if (linkset != null) assetCallback(linkset); } } else { AssetPrim linkset = new AssetPrim(rootNode.OuterXml); if (linkset != null) assetCallback(linkset); } }
private void NullObjectLoadedHandler(AssetPrim linkset, long bytesRead, long totalBytes) { }