Beispiel #1
0
        /// <summary>
        /// Get all the asset uuids associated with a given object.  This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        /// </summary>
        /// <param name="sceneObject"></param>
        /// <param name="assetUuids"></param>
        private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary <UUID, AssetType> assetUuids)
        {
            AssetBase objectAsset = GetAsset(sceneObjectUuid);

            if (null != objectAsset)
            {
                string xml = Utils.BytesToString(objectAsset.Data);

                CoalescedSceneObjects coa;
                if (CoalescedSceneObjectsSerializer.TryFromXml(xml, out coa))
                {
                    foreach (SceneObjectGroup sog in coa.Objects)
                    {
                        GatherAssetUuids(sog, assetUuids);
                    }
                }
                else
                {
                    SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml);

                    if (null != sog)
                    {
                        GatherAssetUuids(sog, assetUuids);
                    }
                }
            }
        }
Beispiel #2
0
        public void TestLoadCoalesecedItem()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password");
            m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream);

            InventoryItemBase coaItem
                = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName);

            Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1");

            string assetXml = AssetHelpers.ReadAssetAsString(m_scene.AssetService, coaItem.AssetID);

            CoalescedSceneObjects coa;
            bool readResult = CoalescedSceneObjectsSerializer.TryFromXml(assetXml, out coa);

            Assert.That(readResult, Is.True);
            Assert.That(coa.Count, Is.EqualTo(2));

            List <SceneObjectGroup> coaObjects = coa.Objects;

            Assert.That(coaObjects[0].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000120")));
            Assert.That(coaObjects[0].AbsolutePosition, Is.EqualTo(new Vector3(15, 30, 45)));

            Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140")));
            Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75)));
        }
        /// <summary>
        /// Get all the asset uuids associated with a given object.  This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        /// </summary>
        /// <param name="sceneObjectAsset"></param>
        private void RecordSceneObjectAssetUuids(AssetBase sceneObjectAsset)
        {
            string xml = Utils.BytesToString(sceneObjectAsset.Data);

            CoalescedSceneObjects coa;

            if (CoalescedSceneObjectsSerializer.TryFromXml(xml, out coa))
            {
                foreach (SceneObjectGroup sog in coa.Objects)
                {
                    AddForInspection(sog);
                }
            }
            else
            {
                SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml);

                if (null != sog)
                {
                    AddForInspection(sog);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Load an asset
        /// </summary>
        /// <param name="assetFilename"></param>
        /// <param name="data"></param>
        /// <returns>true if asset was successfully loaded, false otherwise</returns>
        private bool LoadAsset(string assetPath, byte[] data)
        {
            //IRegionSerialiser serialiser = scene.RequestModuleInterface<IRegionSerialiser>();
            // 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)
            {
                m_log.ErrorFormat(
                    "[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}.  Skipping",
                    assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);

                return(false);
            }

            string extension = filename.Substring(i);
            string rawUuid   = filename.Remove(filename.Length - extension.Length);
            UUID   assetId   = new UUID(rawUuid);

            if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
            {
                sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];

                if (assetType == (sbyte)AssetType.Unknown)
                {
                    m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId);
                }
                else if (assetType == (sbyte)AssetType.Object)
                {
                    if (m_creatorIdForAssetId.ContainsKey(assetId))
                    {
                        string xmlData = Utils.BytesToString(data);
                        List <SceneObjectGroup> sceneObjects = new List <SceneObjectGroup>();

                        CoalescedSceneObjects coa = null;
                        if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa))
                        {
//                            m_log.DebugFormat(
//                                "[INVENTORY ARCHIVER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count);

                            if (coa.Objects.Count == 0)
                            {
                                m_log.WarnFormat(
                                    "[INVENTORY ARCHIVE READ REQUEST]: Aborting load of coalesced object from asset {0} as it has zero loaded components",
                                    assetId);
                                return(false);
                            }

                            sceneObjects.AddRange(coa.Objects);
                        }
                        else
                        {
                            SceneObjectGroup deserializedObject = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);

                            if (deserializedObject != null)
                            {
                                sceneObjects.Add(deserializedObject);
                            }
                            else
                            {
                                m_log.WarnFormat(
                                    "[INVENTORY ARCHIVE READ REQUEST]: Aborting load of object from asset {0} as deserialization failed",
                                    assetId);

                                return(false);
                            }
                        }

                        foreach (SceneObjectGroup sog in sceneObjects)
                        {
                            foreach (SceneObjectPart sop in sog.Parts)
                            {
                                if (string.IsNullOrEmpty(sop.CreatorData))
                                {
                                    sop.CreatorID = m_creatorIdForAssetId[assetId];
                                }
                            }
                        }

                        if (coa != null)
                        {
                            data = Utils.StringToBytes(CoalescedSceneObjectsSerializer.ToXml(coa));
                        }
                        else
                        {
                            data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sceneObjects[0]));
                        }
                    }
                }

                //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);

                AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString());
                asset.Data = data;

                m_AssetService.Store(asset);

                return(true);
            }
            else
            {
                m_log.ErrorFormat(
                    "[INVENTORY ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}",
                    assetPath, extension);

                return(false);
            }
        }