/// <summary>
        ///     Create a scene and its initial base structures.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="configSource"></param>
        /// <returns></returns>
        public IScene CreateScene(ISimulationDataStore dataStore, RegionInfo regionInfo)
        {
            AgentCircuitManager circuitManager = new AgentCircuitManager();
            List<IClientNetworkServer> clientServers = AuroraModuleLoader.PickupModules<IClientNetworkServer>();
            List<IClientNetworkServer> allClientServers = new List<IClientNetworkServer>();
            foreach (IClientNetworkServer clientServer in clientServers)
            {
                clientServer.Initialise((uint)regionInfo.RegionPort, m_configSource, circuitManager);
                allClientServers.Add(clientServer);
            }

            AsyncScene scene = new AsyncScene();
            scene.AddModuleInterfaces(m_simBase.ApplicationRegistry.GetInterfaces());
            scene.Initialize(regionInfo, dataStore, circuitManager, allClientServers);

            return scene;
        }
        /// <summary>
        ///     Use the asset set information at path to load assets
        /// </summary>
        /// <param name="iarFileName"></param>
        protected void LoadLibraries(string iarFileName)
        {
            RegionInfo regInfo = new RegionInfo();
            IScene m_MockScene = null;
            //Make the scene for the IAR loader
            if (m_registry is IScene)
                m_MockScene = (IScene) m_registry;
            else
            {
                m_MockScene = new Scene();
                m_MockScene.Initialize(regInfo);
                m_MockScene.AddModuleInterfaces(m_registry.GetInterfaces());
            }

            UserAccount uinfo = m_MockScene.UserAccountService.GetUserAccount(null, m_service.LibraryOwner);
            //Make the user account for the default IAR
            if (uinfo == null)
            {
                MainConsole.Instance.Warn("Creating user " + m_service.LibraryOwnerName);
                m_MockScene.UserAccountService.CreateUser(m_service.LibraryOwner, UUID.Zero, m_service.LibraryOwnerName,
                                                          "", "");
                uinfo = m_MockScene.UserAccountService.GetUserAccount(null, m_service.LibraryOwner);
                m_MockScene.InventoryService.CreateUserInventory(uinfo.PrincipalID, false);
            }
            if (m_MockScene.InventoryService.GetRootFolder(m_service.LibraryOwner) == null)
                m_MockScene.InventoryService.CreateUserInventory(uinfo.PrincipalID, false);

            List<InventoryFolderBase> rootFolders = m_MockScene.InventoryService.GetFolderFolders(uinfo.PrincipalID,
                                                                                                  UUID.Zero);
            bool alreadyExists = rootFolders.Any(folder => folder.Name == iarFileName);

            if (alreadyExists)
            {
                MainConsole.Instance.InfoFormat("[LIBRARY INVENTORY]: Found previously loaded iar file {0}, ignoring.",
                                                iarFileName);
                return;
            }

            MainConsole.Instance.InfoFormat("[LIBRARY INVENTORY]: Loading iar file {0}", iarFileName);
            InventoryFolderBase rootFolder = m_MockScene.InventoryService.GetRootFolder(uinfo.PrincipalID);

            if (null == rootFolder)
            {
                //We need to create the root folder, otherwise the IAR freaks
                m_MockScene.InventoryService.CreateUserInventory(uinfo.PrincipalID, false);
            }

            InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName,
                                                                                   false, m_service.LibraryOwner);

            try
            {
                archread.ReplaceAssets = true; //Replace any old assets
                List<InventoryNodeBase> nodes = new List<InventoryNodeBase>(archread.Execute(true));
                if (nodes.Count == 0)
                    return;
                InventoryFolderBase f = (InventoryFolderBase) nodes[0];
                UUID IARRootID = f.ID;

                TraverseFolders(IARRootID, m_MockScene);
                FixParent(IARRootID, m_MockScene, m_service.LibraryRootFolderID);
                f.Name = iarFileName;
                f.ParentID = UUID.Zero;
                f.ID = m_service.LibraryRootFolderID;
                f.Type = (int) AssetType.RootFolder;
                f.Version = 1;
                m_MockScene.InventoryService.UpdateFolder(f);
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}",
                                                 iarFileName,
                                                 e.StackTrace);
            }
            finally
            {
                archread.Close();
            }
        }
示例#3
0
 public override void Initialise(IMesher meshmerizer, IScene scene)
 {
     m_region = scene.RegionInfo;
 }
        private void ReadOpenRegionSettings(IConfig instanceSettings, ref RegionInfo region)
        {
            if (instanceSettings == null)
                return;
            region.OpenRegionSettings.MaxDragDistance = instanceSettings.GetFloat("MaxDragDistance",
                                                                                  region.OpenRegionSettings
                                                                                        .MaxDragDistance);
            region.OpenRegionSettings.DefaultDrawDistance = instanceSettings.GetFloat("DefaultDrawDistance",
                                                                                      region.OpenRegionSettings
                                                                                            .DefaultDrawDistance);

            region.OpenRegionSettings.MaximumPrimScale = instanceSettings.GetFloat("MaximumPrimScale",
                                                                                   region.OpenRegionSettings
                                                                                         .MaximumPrimScale);
            region.OpenRegionSettings.MinimumPrimScale = instanceSettings.GetFloat("MinimumPrimScale",
                                                                                   region.OpenRegionSettings
                                                                                         .MinimumPrimScale);
            region.OpenRegionSettings.MaximumPhysPrimScale = instanceSettings.GetFloat("MaximumPhysPrimScale",
                                                                                       region.OpenRegionSettings
                                                                                             .MaximumPhysPrimScale);

            region.OpenRegionSettings.MaximumHollowSize = instanceSettings.GetFloat("MaximumHollowSize",
                                                                                    region.OpenRegionSettings
                                                                                          .MaximumHollowSize);
            region.OpenRegionSettings.MinimumHoleSize = instanceSettings.GetFloat("MinimumHoleSize",
                                                                                  region.OpenRegionSettings
                                                                                        .MinimumHoleSize);

            region.OpenRegionSettings.MaximumLinkCount = instanceSettings.GetInt("MaximumLinkCount",
                                                                                 region.OpenRegionSettings
                                                                                       .MaximumLinkCount);
            region.OpenRegionSettings.MaximumLinkCountPhys = instanceSettings.GetInt("MaximumLinkCountPhys",
                                                                                     region.OpenRegionSettings
                                                                                           .MaximumLinkCountPhys);

            region.OpenRegionSettings.RenderWater = instanceSettings.GetBoolean("RenderWater",
                                                                                region.OpenRegionSettings.RenderWater);
            region.OpenRegionSettings.MaximumInventoryItemsTransfer =
                instanceSettings.GetInt("MaximumInventoryItemsTransfer",
                                        region.OpenRegionSettings.MaximumInventoryItemsTransfer);
            region.OpenRegionSettings.DisplayMinimap = instanceSettings.GetBoolean("DisplayMinimap",
                                                                                   region.OpenRegionSettings
                                                                                         .DisplayMinimap);
            region.OpenRegionSettings.AllowPhysicalPrims = instanceSettings.GetBoolean("AllowPhysicalPrims",
                                                                                       region.OpenRegionSettings
                                                                                             .AllowPhysicalPrims);
            region.OpenRegionSettings.ForceDrawDistance = instanceSettings.GetBoolean("ForceDrawDistance",
                                                                                      region.OpenRegionSettings
                                                                                            .ForceDrawDistance);

            string offset = instanceSettings.GetString("OffsetOfUTC", region.OpenRegionSettings.OffsetOfUTC.ToString());
            int off;
            if (!int.TryParse(offset, out off))
            {
                if (offset == "SLT" || offset == "PST" || offset == "PDT")
                    off = -8;
                else if (offset == "UTC" || offset == "GMT")
                    off = 0;
            }
            region.OpenRegionSettings.OffsetOfUTC = off;
            region.OpenRegionSettings.OffsetOfUTCDST = instanceSettings.GetBoolean("OffsetOfUTCDST",
                                                                                   region.OpenRegionSettings
                                                                                         .OffsetOfUTCDST);
            region.OpenRegionSettings.EnableTeenMode = instanceSettings.GetBoolean("EnableTeenMode",
                                                                                   region.OpenRegionSettings
                                                                                         .EnableTeenMode);
            region.OpenRegionSettings.ShowTags = instanceSettings.GetInt("ShowTags", region.OpenRegionSettings.ShowTags);
            region.OpenRegionSettings.MaxGroups = instanceSettings.GetInt("MaxGroups",
                                                                          region.OpenRegionSettings.MaxGroups);

            string defaultunderpants = instanceSettings.GetString("DefaultUnderpants",
                                                                  region.OpenRegionSettings.DefaultUnderpants.ToString());
            UUID.TryParse(defaultunderpants, out region.OpenRegionSettings.m_DefaultUnderpants);
            string defaultundershirt = instanceSettings.GetString("DefaultUndershirt",
                                                                  region.OpenRegionSettings.DefaultUndershirt.ToString());
            UUID.TryParse(defaultundershirt, out region.OpenRegionSettings.m_DefaultUndershirt);
        }
示例#5
0
 // Initialize the mesh plugin
 public override void Initialise(IMesher meshmerizer, IScene scene)
 {
     mesher = meshmerizer;
     m_region = scene.RegionInfo;
     m_scene = scene;
     WorldExtents = new Vector2(m_region.RegionSizeX, m_region.RegionSizeY);
 }
示例#6
0
 public GridRegion(RegionInfo ConvertFrom)
 {
     Flags = 0;
     RegionName = ConvertFrom.RegionName;
     RegionType = ConvertFrom.RegionType;
     RegionLocX = ConvertFrom.RegionLocX;
     RegionLocY = ConvertFrom.RegionLocY;
     RegionLocZ = ConvertFrom.RegionLocZ;
     InternalPort = (int)MainServer.Instance.Port;
     ExternalHostName = MainServer.Instance.HostName.Replace("https://", "").Replace("http://", "");
     HttpPort = MainServer.Instance.Port;
     RegionID = ConvertFrom.RegionID;
     TerrainImage = ConvertFrom.RegionSettings.TerrainImageID;
     TerrainMapImage = ConvertFrom.RegionSettings.TerrainMapImageID;
     ParcelMapImage = ConvertFrom.RegionSettings.ParcelMapImageID;
     Access = ConvertFrom.AccessLevel;
     if (ConvertFrom.EstateSettings != null)
         EstateOwner = ConvertFrom.EstateSettings.EstateOwner;
     RegionSizeX = ConvertFrom.RegionSizeX;
     RegionSizeY = ConvertFrom.RegionSizeY;
     RegionSizeZ = ConvertFrom.RegionSizeZ;
     ScopeID = ConvertFrom.ScopeID;
     AllScopeIDs = ConvertFrom.AllScopeIDs;
     SessionID = ConvertFrom.GridSecureSessionID;
     Flags |= (int) RegionFlags.RegionOnline;
 }
        public RegionData LoadBackup(string file)
        {
            if (!File.Exists(file))
                return null;

            var stream = ArchiveHelpers.GetStream(file);
            if (stream == null)
                return null;

            GZipStream m_loadStream = new GZipStream(stream, CompressionMode.Decompress);
            TarArchiveReader reader = new TarArchiveReader(m_loadStream);
            List<uint> foundLocalIDs = new List<uint>();
            RegionData regiondata = new RegionData();
            regiondata.Init();

            byte[] data;
            string filePath;
            TarArchiveReader.TarEntryType entryType;
            System.Collections.Concurrent.ConcurrentQueue<byte[]> groups =
                new System.Collections.Concurrent.ConcurrentQueue<byte[]>();
            //Load the archive data that we need
            while ((data = reader.ReadEntry(out filePath, out entryType)) != null)
            {
                if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
                    continue;

                if (filePath.StartsWith("parcels/"))
                {
                    //Only use if we are not merging
                    LandData parcel = new LandData();
                    OSD parcelData = OSDParser.DeserializeLLSDBinary(data);
                    parcel.FromOSD((OSDMap) parcelData);
                    if (parcel.OwnerID != UUID.Parse("05948863-b678-433e-87a4-e44d17678d1d"))
                        //The default owner of the 'default' region
                        regiondata.Parcels.Add(parcel);
                }
                else if (filePath.StartsWith("newstyleterrain/"))
                {
                    regiondata.Terrain = data;
                }
                else if (filePath.StartsWith("newstylerevertterrain/"))
                {
                    regiondata.RevertTerrain = data;
                }
                else if (filePath.StartsWith("newstylewater/"))
                {
                    regiondata.Water = data;
                }
                else if (filePath.StartsWith("newstylerevertwater/"))
                {
                    regiondata.RevertWater = data;
                }
                else if (filePath.StartsWith("entities/"))
                {
                    groups.Enqueue(data);
                }
                else if (filePath.StartsWith("regioninfo/"))
                {
                    RegionInfo info = new RegionInfo();
                    info.FromOSD((OSDMap) OSDParser.DeserializeLLSDBinary(data));
                    regiondata.RegionInfo = info;
                }
                data = null;
            }
            m_loadStream.Close();
            m_loadStream = null;

            int threadCount = groups.Count > 16 ? 16 : groups.Count;
            System.Threading.Thread[] threads = new System.Threading.Thread[threadCount];
            for (int i = 0; i < threadCount; i++)
            {
                threads[i] = new System.Threading.Thread(() =>
                                                             {
                                                                 byte[] groupData;
                                                                 while (groups.TryDequeue(out groupData))
                                                                 {
                                                                     MemoryStream ms = new MemoryStream(groupData);
                                                                     ISceneEntity sceneObject =
                                                                         SceneEntitySerializer.SceneObjectSerializer
                                                                                              .FromXml2Format(ref ms,
                                                                                                              null);
                                                                     ms.Close();
                                                                     ms = null;
                                                                     data = null;
                                                                     if (sceneObject != null)
                                                                     {
                                                                         foreach (
                                                                             ISceneChildEntity part in
                                                                                 sceneObject.ChildrenEntities())
                                                                         {
                                                                             lock (foundLocalIDs)
                                                                             {
                                                                                 if (
                                                                                     !foundLocalIDs.Contains(
                                                                                         part.LocalId))
                                                                                     foundLocalIDs.Add(part.LocalId);
                                                                                 else
                                                                                     part.LocalId = 0;
                                                                                         //Reset it! Only use it once!
                                                                             }
                                                                         }
                                                                         regiondata.Groups.Add(
                                                                             sceneObject as SceneObjectGroup);
                                                                     }
                                                                 }
                                                             });
                threads[i].Start();
            }
            for (int i = 0; i < threadCount; i++)
                threads[i].Join();

            foundLocalIDs.Clear();

            return regiondata;
        }
示例#8
0
        public void Initialize(RegionInfo regionInfo, ISimulationDataStore dataStore,
            AgentCircuitManager authen, List<IClientNetworkServer> clientServers)
        {
            Initialize(regionInfo);

            //Set up the clientServer
            m_clientServers = clientServers;
            foreach (IClientNetworkServer clientServer in clientServers)
                clientServer.AddScene(this);

            m_sceneManager = RequestModuleInterface<ISceneManager>();
            m_simDataStore = dataStore;

            m_config = m_sceneManager.ConfigSource;
            m_authenticateHandler = authen;

            m_AuroraEventManager = new AuroraEventManager();
            m_eventManager = new EventManager();
            m_permissions = new ScenePermissions(this);

            m_sceneGraph = new SceneGraph(this, m_regInfo);

            #region Region Config

            IConfig packetConfig = m_config.Configs["PacketPool"];
            if (packetConfig != null)
            {
                PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
                PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
            }

            #endregion Region Config

            m_basesimfps = 45f;
            m_basesimphysfps = 45f;

            m_basesimphysfps = Config.Configs["Physics"].GetFloat("BasePhysicsFPS", 45f);
            m_basesimfps = Config.Configs["Protection"].GetFloat("BaseRateFramesPerSecond", 45f);
            if (m_basesimphysfps > 45f)
                m_basesimphysfps = 45f;
            if (m_basesimfps > 45f)
                m_basesimfps = 45f;

            if (m_basesimphysfps > m_basesimfps)
                m_basesimphysfps = m_basesimfps;

            m_updatetimespan = 1000/m_basesimfps;
            m_physicstimespan = 1000/m_basesimphysfps;

            #region Startup Complete config

            EventManager.OnAddToStartupQueue += AddToStartupQueue;
            EventManager.OnModuleFinishedStartup += FinishedStartup;
            //EventManager.OnStartupComplete += StartupComplete;

            AddToStartupQueue("Startup");

            #endregion
        }
示例#9
0
 public void Initialize(RegionInfo regionInfo)
 {
     m_regInfo = regionInfo;
 }
        public void StartRegion(ISimulationDataStore simData, RegionInfo regionInfo)
        {
            MainConsole.Instance.InfoFormat("[SceneManager]: Starting region \"{0}\" at @ {1},{2}",
                                            regionInfo.RegionName,
                                            regionInfo.RegionLocX/256, regionInfo.RegionLocY/256);
            ISceneLoader sceneLoader = m_OpenSimBase.ApplicationRegistry.RequestModuleInterface<ISceneLoader>();
            if (sceneLoader == null)
                throw new Exception("No Scene Loader Interface!");

            //Get the new scene from the interface
            IScene scene = sceneLoader.CreateScene(simData, regionInfo);
            m_scenes.Add(scene);

            MainConsole.Instance.ConsoleScenes = m_scenes;
            simData.SetRegion(scene);
            m_simulationDataServices.Add(simData);

            if (OnAddedScene != null)
                OnAddedScene(scene);

            StartModules(scene);

            if (OnFinishedAddingScene != null)
                OnFinishedAddingScene(scene);

            //Start the heartbeats
            scene.StartHeartbeat();
            //Tell the scene that the startup is complete
            // Note: this event is added in the scene constructor
            scene.FinishedStartup("Startup", new List<string>());
        }
        protected internal SceneGraph(IScene parent, RegionInfo regInfo)
        {
            Random random = new Random();
            m_lastAllocatedLocalId = (uint) (random.NextDouble()*(uint.MaxValue/2)) + uint.MaxValue/4;
            m_parentScene = parent;
            m_regInfo = regInfo;

            //Subscript to the scene events
            m_parentScene.EventManager.OnNewClient += SubscribeToClientEvents;
            m_parentScene.EventManager.OnClosingClient += UnSubscribeToClientEvents;

            IConfig aurorastartupConfig = parent.Config.Configs["AuroraStartup"];
            if (aurorastartupConfig != null)
            {
                m_DefaultObjectName = aurorastartupConfig.GetString("DefaultObjectName", m_DefaultObjectName);
                EnableFakeRaycasting = aurorastartupConfig.GetBoolean("EnableFakeRaycasting", false);
            }
        }
 public void LoadModuleFromArchive(byte[] data, string filePath, TarArchiveReader.TarEntryType type, IScene scene)
 {
     if (filePath.StartsWith("estatesettings/"))
     {
         EstateSettings settings = new EstateSettings();
         settings.FromOSD((OSDMap) OSDParser.DeserializeLLSDBinary(data));
         scene.RegionInfo.EstateSettings = settings;
     }
     else if (filePath.StartsWith("regioninfo/"))
     {
         string m_merge =
             MainConsole.Instance.Prompt(
                 "Should we load the region information from the archive (region name, region position, etc)?",
                 "false");
         RegionInfo settings = new RegionInfo();
         settings.UnpackRegionInfoData((OSDMap) OSDParser.DeserializeLLSDBinary(data));
         if (m_merge == "false")
         {
             //Still load the region settings though
             scene.RegionInfo.RegionSettings = settings.RegionSettings;
             return;
         }
         settings.RegionSettings = scene.RegionInfo.RegionSettings;
         settings.EstateSettings = scene.RegionInfo.EstateSettings;
         scene.RegionInfo = settings;
     }
 }