AddRestoredSceneObject() public method

Add an object into the scene that has come from storage
public AddRestoredSceneObject ( SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted ) : bool
sceneObject SceneObjectGroup
attachToBackup bool /// If true, changes to the object will be reflected in its persisted data /// If false, the persisted data will not be changed even if the object in the scene is changed ///
alreadyPersisted bool /// If true, we won't persist this object until it changes /// If false, we'll persist this object immediately ///
return bool
コード例 #1
0
ファイル: ArchiveReadRequest.cs プロジェクト: CCIR/opensim
        /// <summary>
        /// Load serialized scene objects.
        /// </summary>
        protected void LoadObjects(Scene scene, List<string> serialisedSceneObjects, List<SceneObjectGroup> sceneObjects)
        {
            // Reload serialized prims
            m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects.  Please wait.", serialisedSceneObjects.Count);

            UUID oldTelehubUUID = scene.RegionInfo.RegionSettings.TelehubObject;

            IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>();
            int sceneObjectsLoadedCount = 0;

            foreach (string serialisedSceneObject in serialisedSceneObjects)
            {
                /*
                m_log.DebugFormat("[ARCHIVER]: Loading xml with raw size {0}", serialisedSceneObject.Length);

                // Really large xml files (multi megabyte) appear to cause
                // memory problems
                // when loading the xml.  But don't enable this check yet
                
                if (serialisedSceneObject.Length > 5000000)
                {
                    m_log.Error("[ARCHIVER]: Ignoring xml since size > 5000000);");
                    continue;
                }
                */

                SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject);

                bool isTelehub = (sceneObject.UUID == oldTelehubUUID) && (oldTelehubUUID != UUID.Zero);

                // For now, give all incoming scene objects new uuids.  This will allow scenes to be cloned
                // on the same region server and multiple examples a single object archive to be imported
                // to the same scene (when this is possible).
                sceneObject.ResetIDs();

                if (isTelehub)
                {
                    // Change the Telehub Object to the new UUID
                    scene.RegionInfo.RegionSettings.TelehubObject = sceneObject.UUID;
                    scene.RegionInfo.RegionSettings.Save();
                    oldTelehubUUID = UUID.Zero;
                }

                // Try to retain the original creator/owner/lastowner if their uuid is present on this grid
                // or creator data is present.  Otherwise, use the estate owner instead.
                foreach (SceneObjectPart part in sceneObject.Parts)
                {
                    if (part.CreatorData == null || part.CreatorData == string.Empty)
                    {
                        if (!ResolveUserUuid(scene, part.CreatorID))
                            part.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner;
                    }
                    if (UserManager != null)
                        UserManager.AddUser(part.CreatorID, part.CreatorData);

                    if (!ResolveUserUuid(scene, part.OwnerID))
                        part.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner;

                    if (!ResolveUserUuid(scene, part.LastOwnerID))
                        part.LastOwnerID = scene.RegionInfo.EstateSettings.EstateOwner;

                    if (!ResolveGroupUuid(part.GroupID))
                        part.GroupID = UUID.Zero;

                    // And zap any troublesome sit target information
//                    part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
//                    part.SitTargetPosition    = new Vector3(0, 0, 0);

                    // Fix ownership/creator of inventory items
                    // Not doing so results in inventory items
                    // being no copy/no mod for everyone
                    lock (part.TaskInventory)
                    {
                        TaskInventoryDictionary inv = part.TaskInventory;
                        foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
                        {
                            if (!ResolveUserUuid(scene, kvp.Value.OwnerID))
                            {
                                kvp.Value.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner;
                            }

                            if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty)
                            {
                                if (!ResolveUserUuid(scene, kvp.Value.CreatorID))
                                    kvp.Value.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner;
                            }

                            if (UserManager != null)
                                UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData);

                            if (!ResolveGroupUuid(kvp.Value.GroupID))
                                kvp.Value.GroupID = UUID.Zero;
                        }
                    }
                }

                if (scene.AddRestoredSceneObject(sceneObject, true, false))
                {
                    sceneObjectsLoadedCount++;
                    sceneObject.CreateScriptInstances(0, false, scene.DefaultScriptEngine, 0);
                    sceneObject.ResumeScripts();
                }
            }

            m_log.InfoFormat("[ARCHIVER]: Restored {0} scene objects to the scene", sceneObjectsLoadedCount);

            int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount;

            if (ignoredObjects > 0)
                m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects);

            if (oldTelehubUUID != UUID.Zero)
            {
                m_log.WarnFormat("Telehub object not found: {0}", oldTelehubUUID);
                scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
                scene.RegionInfo.RegionSettings.ClearSpawnPoints();
            }
        }
コード例 #2
0
        /// <summary>
        /// Load serialized scene objects.
        /// </summary>
        protected void LoadObjects(Scene scene, List<string> serialisedSceneObjects, List<SceneObjectGroup> sceneObjects)
        {
            // Reload serialized prims
            m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects.  Please wait.", serialisedSceneObjects.Count);

            OpenMetaverse.Quaternion rot = OpenMetaverse.Quaternion.CreateFromAxisAngle(0, 0, 1, m_rotation);

            UUID oldTelehubUUID = scene.RegionInfo.RegionSettings.TelehubObject;

            IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>();
            int sceneObjectsLoadedCount = 0;

            foreach (string serialisedSceneObject in serialisedSceneObjects)
            {
                /*
                m_log.DebugFormat("[ARCHIVER]: Loading xml with raw size {0}", serialisedSceneObject.Length);

                // Really large xml files (multi megabyte) appear to cause
                // memory problems
                // when loading the xml.  But don't enable this check yet
                
                if (serialisedSceneObject.Length > 5000000)
                {
                    m_log.Error("[ARCHIVER]: Ignoring xml since size > 5000000);");
                    continue;
                }
                */

                SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject);

                // Happily this does not do much to the object since it hasn't been added to the scene yet
                if (!sceneObject.IsAttachment)
                {
                    if (m_displacement != Vector3.Zero || m_rotation != 0f)
                    {
                        Vector3 pos = sceneObject.AbsolutePosition;
                        if (m_rotation != 0f)
                        {
                            // Rotate the object
                            sceneObject.RootPart.RotationOffset = rot * sceneObject.GroupRotation;
                            // Get object position relative to rotation axis
                            Vector3 offset = pos - m_rotationCenter;
                            // Rotate the object position
                            offset *= rot;
                            // Restore the object position back to relative to the region
                            pos = m_rotationCenter + offset;
                        }
                        if (m_displacement != Vector3.Zero)
                        {
                            pos += m_displacement;
                        }
                        sceneObject.AbsolutePosition = pos;
                    }
                }


                bool isTelehub = (sceneObject.UUID == oldTelehubUUID) && (oldTelehubUUID != UUID.Zero);

                // For now, give all incoming scene objects new uuids.  This will allow scenes to be cloned
                // on the same region server and multiple examples a single object archive to be imported
                // to the same scene (when this is possible).
                sceneObject.ResetIDs();

                if (isTelehub)
                {
                    // Change the Telehub Object to the new UUID
                    scene.RegionInfo.RegionSettings.TelehubObject = sceneObject.UUID;
                    scene.RegionInfo.RegionSettings.Save();
                    oldTelehubUUID = UUID.Zero;
                }

                ModifySceneObject(scene, sceneObject);

                if (scene.AddRestoredSceneObject(sceneObject, true, false))
                {
                    sceneObjectsLoadedCount++;
                    sceneObject.CreateScriptInstances(0, false, scene.DefaultScriptEngine, 0);
                    sceneObject.ResumeScripts();
                }
            }

            m_log.InfoFormat("[ARCHIVER]: Restored {0} scene objects to the scene", sceneObjectsLoadedCount);

            int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount;

            if (ignoredObjects > 0)
                m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects);

            if (oldTelehubUUID != UUID.Zero)
            {
                m_log.WarnFormat("Telehub object not found: {0}", oldTelehubUUID);
                scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
                scene.RegionInfo.RegionSettings.ClearSpawnPoints();
            }
        }
コード例 #3
0
        /// <summary>
        /// Create a prim from the xml2 representation.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="xmlData"></param>
        /// <returns>The scene object created.  null if the scene object already existed</returns>
        protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData)
        {
            //SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);
            using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData)))
            {
                SceneObjectGroup obj = new SceneObjectGroup();
                SceneObjectSerializer.Xml2ToSOG(reader, obj);

                if (scene.AddRestoredSceneObject(obj, true, false))
                    return obj;
                else
                    return null;
            }
        }
コード例 #4
0
ファイル: SceneXmlLoader.cs プロジェクト: AlphaStaxLLC/taiga
        /// <summary>
        /// Create a prim from the xml2 representation.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="xmlData"></param>
        /// <returns>The scene object created.  null if the scene object already existed</returns>
        protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData)
        {
            SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);

            if (scene.AddRestoredSceneObject(obj, true, false))
                return obj;
            else
                return null;
        }