/// <summary> /// Initializes a new instance of the <see cref="Flocking.Bird"/> class. /// </summary> /// <param name='l'> /// L. the initial position of this bird /// </param> /// <param name='ms'> /// Ms. max speed this bird can attain /// </param> /// <param name='mf'> /// Mf. max force / acceleration this bird can extert /// </param> public Bird (string id, FlockingModel model, FlowMap flowMap) { m_id = id; m_acc = Vector3.Zero; m_vel = new Vector3 (m_rndnums.Next (-1, 1), m_rndnums.Next (-1, 1), m_rndnums.Next (-1, 1)); m_model = model; m_flowMap = flowMap; m_regionX = m_flowMap.LengthX; m_regionY = m_flowMap.LengthY; m_regionZ = m_flowMap.LengthZ; m_regionBorder = m_flowMap.Border; }
/// <summary> /// Initializes a new instance of the <see cref="Flocking.Bird"/> class. /// </summary> /// <param name='l'> /// L. the initial position of this bird /// </param> /// <param name='ms'> /// Ms. max speed this bird can attain /// </param> /// <param name='mf'> /// Mf. max force / acceleration this bird can extert /// </param> public Bird(string id, FlockingModel model, FlowMap flowMap) { m_id = id; m_acc = Vector3.Zero; m_vel = new Vector3 (m_rndnums.Next (-1, 1), m_rndnums.Next (-1, 1), m_rndnums.Next (-1, 1)); m_model = model; m_flowMap = flowMap; m_regionX = m_flowMap.LengthX; m_regionY = m_flowMap.LengthY; m_regionZ = m_flowMap.LengthZ; m_regionBorder = m_flowMap.Border; }
public void AddRegion(Scene scene) { IConfig cnf; m_log.InfoFormat("[{0}]: Adding region {1} to this module", m_name, scene.RegionInfo.RegionName); cnf = m_config.Configs["Startup"]; m_regionConfigDir = cnf.GetString("regionload_regionsdir", Path.Combine(Util.configDir(), "bin/Regions/")); cnf = m_config.Configs[scene.RegionInfo.RegionName]; if (cnf == null) { m_log.InfoFormat("[{0}]: No region section [{1}] found in {2} configuration file.", m_name, scene.RegionInfo.RegionName, m_regionConfigDir); //string moduleConfigFile = Path.Combine(Util.configDir(),m_name + ".ini"); string moduleConfigFile = Path.Combine(m_regionConfigDir, "Regions.ini"); try { m_log.InfoFormat("[{0}]: Checking {1} for [{2}] section", m_name, moduleConfigFile, scene.RegionInfo.RegionName); m_config = new IniConfigSource(moduleConfigFile); cnf = m_config.Configs[scene.RegionInfo.RegionName]; } catch (Exception) { cnf = null; } if (cnf == null) { m_log.InfoFormat("[{0}]: No region section [{1}] found in configuration {2}.", m_name, scene.RegionInfo.RegionName, moduleConfigFile); cnf = m_config.Configs[scene.RegionInfo.RegionName]; if (cnf == null) { m_log.InfoFormat("[{0}]: No region section [{1}] found in main configuration. Module is disabled.", m_name, scene.RegionInfo.RegionName); return; } } } m_enabled = cnf.GetBoolean("BirdsModuleEnabled", false); if (m_enabled) { m_scene = scene; m_startup = cnf.GetBoolean("BirdsShowOnStartup", false); m_chatChannel = cnf.GetInt("BirdsChatChannel", 118); m_birdPrim = cnf.GetString("BirdsPrim", "birdPrim"); m_flockSize = cnf.GetInt("BirdsFlockSize", 20); m_maxFlockSize = cnf.GetInt("BirdsMaxFlockSize", 100); m_maxSpeed = cnf.GetFloat("BirdsMaxSpeed", 1.5f); m_maxForce = cnf.GetFloat("BirdsMaxForce", 0.2f); m_neighbourDistance = cnf.GetFloat("BirdsNeighbourDistance", 25f); m_desiredSeparation = cnf.GetFloat("BirdsDesiredSeparation", 10f); m_tolerance = cnf.GetFloat("BirdsTolerance", 5f); m_borderSize = cnf.GetFloat("BirdsRegionBorderSize", 5f); m_maxHeight = cnf.GetInt("BirdsMaxHeight", 75); m_frameUpdateRate = cnf.GetInt("BirdsUpdateEveryNFrames", 1); string allowedControllers = cnf.GetString("BirdsAllowedControllers", UUID.Zero.ToString()); if (allowedControllers != UUID.Zero.ToString()) { string[] ac = allowedControllers.Split(new char[] { ',' }); UUID acUUID; for (int i = 0; i < ac.Length; i++) { string value = ac[i].Trim(); if (value == "ESTATE_OWNER") { UUID eoUUID = m_scene.RegionInfo.EstateSettings.EstateOwner; m_allowedControllers.Add(eoUUID); m_log.InfoFormat("[{0}] Added Estate Owner UUID: {1} to list of allowed users", m_name, eoUUID.ToString()); continue; } if (value == "ESTATE_MANAGER") { foreach (UUID emUUID in m_scene.RegionInfo.EstateSettings.EstateManagers) { m_allowedControllers.Add(emUUID); m_log.InfoFormat("[{0}] Added Estate Manager UUID: {1} to list of allowed users", m_name, emUUID.ToString()); } continue; } if (UUID.TryParse(ac[i].Trim(), out acUUID)) { m_allowedControllers.Add(acUUID); m_log.InfoFormat("[{0}] Added UUID: {1} to list of allowed users", m_name, acUUID.ToString()); } } } else { m_log.InfoFormat("[{0}] No command security was defined in the config. Any user may possibly configure this module from a script!", m_name); } m_log.InfoFormat("[{0}] Module is {1} listening for commands on channel {2} with Flock Size {3}", m_name, m_startup ? "enabled and" : "disabled, but still", m_chatChannel, m_flockSize); m_console = MainConsole.Instance; //register commands with the scene RegisterCommands(); //register handlers m_scene.EventManager.OnFrame += FlockUpdate; m_scene.EventManager.OnChatFromClient += SimChatSent; //listen for commands sent from the client m_scene.EventManager.OnChatFromWorld += SimChatSent; m_scene.EventManager.OnPrimsLoaded += PrimsLoaded; // init module m_model = new FlockingModel(m_name, m_maxSpeed, m_maxForce, m_neighbourDistance, m_desiredSeparation, m_tolerance, m_borderSize); m_view = new FlockingView(m_name, m_scene); m_view.BirdPrim = m_birdPrim; m_frame = 0; m_shoutPos = new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 30f); FlockInitialise(); } else { m_log.InfoFormat("[{0}] Module is disabled in region {1}", m_name, scene.RegionInfo.RegionName); } }
public void AddRegion(Scene scene) { IConfig cnf; m_log.InfoFormat("[{0}]: Adding region {1} to this module", m_name, scene.RegionInfo.RegionName); cnf = m_config.Configs["Startup"]; m_regionConfigDir = cnf.GetString("regionload_regionsdir", Path.Combine(Util.configDir(), "bin/Regions/")); cnf = m_config.Configs[scene.RegionInfo.RegionName]; if (cnf == null) { m_log.InfoFormat("[{0}]: No region section [{1}] found in addon-modules/{2}/config/*.ini configuration files.", m_name, scene.RegionInfo.RegionName, m_name); //string moduleConfigFile = Path.Combine(Util.configDir(),m_name + ".ini"); string moduleConfigFile = Path.Combine(m_regionConfigDir, "Regions.ini"); try { m_log.InfoFormat("[{0}]: Checking {1} for [{2}] section containing valid config keys", m_name, moduleConfigFile, scene.RegionInfo.RegionName); m_config = new IniConfigSource(moduleConfigFile); cnf = m_config.Configs[scene.RegionInfo.RegionName]; } catch (Exception) { cnf = null; } if (cnf == null) { m_log.InfoFormat("[{0}]: No region section [{1}] found in configuration {2}. Birds in this region are set to Disabled", m_name, scene.RegionInfo.RegionName, moduleConfigFile); m_enabled = false; return; } } m_startup = cnf.GetBoolean("BirdsModuleStartup", true); if (m_startup) { m_scene = scene; m_enabled = cnf.GetBoolean("BirdsEnabled", false); m_chatChannel = cnf.GetInt("BirdsChatChannel", 118); m_birdPrim = cnf.GetString("BirdsPrim", "birdPrim"); m_flockSize = cnf.GetInt("BirdsFlockSize", 20); m_maxFlockSize = cnf.GetInt("BirdsMaxFlockSize", 100); m_maxSpeed = cnf.GetFloat("BirdsMaxSpeed", 1.5f); m_maxForce = cnf.GetFloat("BirdsMaxForce", 0.2f); m_neighbourDistance = cnf.GetFloat("BirdsNeighbourDistance", 25f); m_desiredSeparation = cnf.GetFloat("BirdsDesiredSeparation", 10f); m_tolerance = cnf.GetFloat("BirdsTolerance", 5f); m_borderSize = cnf.GetFloat("BirdsRegionBorderSize", 5f); m_maxHeight = cnf.GetInt("BirdsMaxHeight", 75); m_frameUpdateRate = cnf.GetInt("BirdsUpdateEveryNFrames", 1); string allowedControllers = cnf.GetString("BirdsAllowedControllers", UUID.Zero.ToString()); if (allowedControllers != UUID.Zero.ToString()) { string[] ac = allowedControllers.Split(new char[] { ',' }); UUID acUUID; for (int i = 0; i < ac.Length; i++) { string value = ac[i].Trim(); if (value == "ESTATE_OWNER") { UUID eoUUID = m_scene.RegionInfo.EstateSettings.EstateOwner; m_allowedControllers.Add(eoUUID); m_log.InfoFormat("[{0}] Added Estate Owner UUID: {1} to list of allowed users", m_name, eoUUID.ToString()); continue; } if (value == "ESTATE_MANAGER") { foreach (UUID emUUID in m_scene.RegionInfo.EstateSettings.EstateManagers) { m_allowedControllers.Add(emUUID); m_log.InfoFormat("[{0}] Added Estate Manager UUID: {1} to list of allowed users", m_name, emUUID.ToString()); } continue; } if (UUID.TryParse(ac[i].Trim(), out acUUID)) { m_allowedControllers.Add(acUUID); m_log.InfoFormat("[{0}] Added UUID: {1} to list of allowed users", m_name, acUUID.ToString()); } } } else { m_log.InfoFormat("[{0}] No command security was defined in the config. Any user may possibly configure this module from a script!", m_name); } m_log.InfoFormat("[{0}] Module is {1} listening for commands on channel {2} with Flock Size {3}", m_name, m_enabled ? "enabled and" : "disabled, but still", m_chatChannel, m_flockSize); m_console = MainConsole.Instance; //register commands with the scene RegisterCommands(); //register handlers m_scene.EventManager.OnFrame += FlockUpdate; m_scene.EventManager.OnChatFromClient += SimChatSent; //listen for commands sent from the client m_scene.EventManager.OnChatFromWorld += SimChatSent; m_scene.EventManager.OnPrimsLoaded += PrimsLoaded; // init module m_model = new FlockingModel(m_name, m_maxSpeed, m_maxForce, m_neighbourDistance, m_desiredSeparation, m_tolerance, m_borderSize); m_view = new FlockingView(m_name, m_scene); m_view.BirdPrim = m_birdPrim; m_frame = 0; m_shoutPos = new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 30f); FlockInitialise(); } else m_log.InfoFormat("[{0}] Module is disabled in Region {1}", m_name, scene.RegionInfo.RegionName); }