当前位置: 首页>>代码示例>>C#>>正文


C# Scene.AddRestoredSceneObject方法代码示例

本文整理汇总了C#中OpenSim.Region.Framework.Scenes.Scene.AddRestoredSceneObject方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.AddRestoredSceneObject方法的具体用法?C# Scene.AddRestoredSceneObject怎么用?C# Scene.AddRestoredSceneObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSim.Region.Framework.Scenes.Scene的用法示例。


在下文中一共展示了Scene.AddRestoredSceneObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadObjects

        /// <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))
//.........这里部分代码省略.........
开发者ID:CCIR,项目名称:opensim,代码行数:101,代码来源:ArchiveReadRequest.cs

示例2: LoadObjects

        /// <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();
            }
        }
开发者ID:RutgersUniversityVirtualWorlds,项目名称:opensim,代码行数:98,代码来源:ArchiveReadRequest.cs

示例3: CreatePrimFromXml2

        /// <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;
            }
        }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:20,代码来源:SceneXmlLoader.cs

示例4: CreatePrimFromXml2

        /// <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;
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:15,代码来源:SceneXmlLoader.cs


注:本文中的OpenSim.Region.Framework.Scenes.Scene.AddRestoredSceneObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。