public OSDMap PackRegionInfoData(bool secure) { OSDMap args = new OSDMap(); args["region_id"] = OSD.FromUUID(RegionID); if ((RegionName != null) && !RegionName.Equals("")) { args["region_name"] = OSD.FromString(RegionName); } args["region_xloc"] = OSD.FromString(RegionLocX.ToString()); args["region_yloc"] = OSD.FromString(RegionLocY.ToString()); args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); if (RegionType != String.Empty) { args["region_type"] = OSD.FromString(RegionType); } args["password"] = OSD.FromUUID(Password); args["region_size_x"] = OSD.FromInteger(RegionSizeX); args["region_size_y"] = OSD.FromInteger(RegionSizeY); args["region_size_z"] = OSD.FromInteger(RegionSizeZ); #if (!ISWIN) OSDArray ports = new OSDArray(UDPPorts.ConvertAll <OSD>(delegate(int a) { return(a); })); #else OSDArray ports = new OSDArray(UDPPorts.ConvertAll <OSD>(a => a)); #endif args["UDPPorts"] = ports; args["InfiniteRegion"] = OSD.FromBoolean(InfiniteRegion); if (secure) { args["disabled"] = OSD.FromBoolean(Disabled); args["scope_id"] = OSD.FromUUID(ScopeID); args["object_capacity"] = OSD.FromInteger(m_objectCapacity); args["region_type"] = OSD.FromString(RegionType); args["see_into_this_sim_from_neighbor"] = OSD.FromBoolean(SeeIntoThisSimFromNeighbor); args["trust_binaries_from_foreign_sims"] = OSD.FromBoolean(TrustBinariesFromForeignSims); args["allow_script_crossing"] = OSD.FromBoolean(AllowScriptCrossing); args["allow_physical_prims"] = OSD.FromBoolean(AllowPhysicalPrims); args["number_startup"] = OSD.FromInteger(NumberStartup); args["startupType"] = OSD.FromInteger((int)Startup); args["RegionSettings"] = RegionSettings.ToOSD(); } return(args); }
public void StoreRegionSettings(RegionSettings rs) { QueryFilter filter = new QueryFilter(); filter.andFilters["regionUUID"] = rs.RegionUUID; //Delete the original GD.Delete (m_regionSettingsRealm, filter); //Now replace with the new GD.Insert (m_regionSettingsRealm, new object[] { rs.RegionUUID, rs.BlockTerraform ? 1 : 0, rs.BlockFly ? 1 : 0, rs.AllowDamage ? 1 : 0, rs.RestrictPushing ? 1 : 0, rs.AllowLandResell ? 1 : 0, rs.AllowLandJoinDivide ? 1 : 0, rs.BlockShowInSearch ? 1 : 0, rs.AgentLimit, rs.ObjectBonus, rs.Maturity, rs.DisableScripts ? 1 : 0, rs.DisableCollisions ? 1 : 0, rs.DisablePhysics ? 1 : 0, rs.TerrainTexture1, rs.TerrainTexture2, rs.TerrainTexture3, rs.TerrainTexture4, rs.Elevation1NW, rs.Elevation2NW, rs.Elevation1NE, rs.Elevation2NE, rs.Elevation1SE, rs.Elevation2SE, rs.Elevation1SW, rs.Elevation2SW, rs.WaterHeight, rs.TerrainRaiseLimit, rs.TerrainLowerLimit, rs.UseEstateSun ? 1 : 0, rs.FixedSun ? 1 : 0, rs.SunPosition, rs.Covenant, rs.Sandbox ? 1 : 0, rs.SunVector.X, rs.SunVector.Y, rs.SunVector.Z, (rs.LoadedCreationID ?? ""), rs.LoadedCreationDateTime, rs.TerrainMapImageID, rs.TerrainImageID, rs.MinimumAge, rs.CovenantLastUpdated, OSDParser.SerializeJsonString(rs.Generic), Util.ToUnixTime(rs.TerrainMapLastRegenerated) }); }
public RegionSettings LoadRegionSettings(UUID regionUUID) { RegionSettings settings = new RegionSettings (); Dictionary<string, List<string>> query = GD.QueryNames (new[] { "regionUUID" }, new object[] { regionUUID }, m_regionSettingsRealm, "*"); if (query.Count == 0) { settings.RegionUUID = regionUUID; StoreRegionSettings (settings); } else { for (int i = 0; i < query.ElementAt (0).Value.Count; i++) { settings.RegionUUID = UUID.Parse (query["regionUUID"][i]); settings.BlockTerraform = int.Parse (query["block_terraform"][i]) == 1; settings.BlockFly = int.Parse (query["block_fly"][i]) == 1; settings.AllowDamage = int.Parse (query["allow_damage"][i]) == 1; settings.RestrictPushing = int.Parse (query["restrict_pushing"][i]) == 1; settings.AllowLandResell = int.Parse (query["allow_land_resell"][i]) == 1; settings.AllowLandJoinDivide = int.Parse (query["allow_land_join_divide"][i]) == 1; settings.BlockShowInSearch = int.Parse (query["block_show_in_search"][i]) == 1; settings.AgentLimit = int.Parse (query["agent_limit"][i]); settings.ObjectBonus = double.Parse (query["object_bonus"][i]); settings.Maturity = int.Parse (query["maturity"][i]); settings.DisableScripts = int.Parse (query["disable_scripts"][i]) == 1; settings.DisableCollisions = int.Parse (query["disable_collisions"][i]) == 1; settings.DisablePhysics = int.Parse (query["disable_physics"][i]) == 1; settings.TerrainTexture1 = UUID.Parse (query["terrain_texture_1"][i]); settings.TerrainTexture2 = UUID.Parse (query["terrain_texture_2"][i]); settings.TerrainTexture3 = UUID.Parse (query["terrain_texture_3"][i]); settings.TerrainTexture4 = UUID.Parse (query["terrain_texture_4"][i]); settings.Elevation1NW = double.Parse (query["elevation_1_nw"][i]); settings.Elevation2NW = double.Parse (query["elevation_2_nw"][i]); settings.Elevation1NE = double.Parse (query["elevation_1_ne"][i]); settings.Elevation2NE = double.Parse (query["elevation_2_ne"][i]); settings.Elevation1SE = double.Parse (query["elevation_1_se"][i]); settings.Elevation2SE = double.Parse (query["elevation_2_se"][i]); settings.Elevation1SW = double.Parse (query["elevation_1_sw"][i]); settings.Elevation2SW = double.Parse (query["elevation_2_sw"][i]); settings.WaterHeight = double.Parse (query["water_height"][i]); settings.TerrainRaiseLimit = double.Parse (query["terrain_raise_limit"][i]); settings.TerrainLowerLimit = double.Parse (query["terrain_lower_limit"][i]); settings.UseEstateSun = int.Parse (query["use_estate_sun"][i]) == 1; settings.FixedSun = int.Parse (query["fixed_sun"][i]) == 1; settings.SunPosition = double.Parse (query["sun_position"][i]); settings.Covenant = UUID.Parse (query["covenant"][i]); if(query.ContainsKey("Sandbox")) if(query["Sandbox"][i] != null) settings.Sandbox = int.Parse (query["Sandbox"][i]) == 1; settings.SunVector = new Vector3 (float.Parse (query["sunvectorx"][i]), float.Parse (query["sunvectory"][i]), float.Parse (query["sunvectorz"][i])); settings.LoadedCreationID = query["loaded_creation_id"][i]; settings.LoadedCreationDateTime = int.Parse (query["loaded_creation_datetime"][i]); settings.TerrainMapImageID = UUID.Parse (query["map_tile_ID"][i]); settings.TerrainImageID = UUID.Parse (query["terrain_tile_ID"][i]); if (query["minimum_age"][i] != null) settings.MinimumAge = int.Parse (query["minimum_age"][i]); if(query["covenantlastupdated"][i] != null) settings.CovenantLastUpdated = int.Parse (query["covenantlastupdated"][i]); if (query.ContainsKey ("generic") && query["generic"].Count > i && query["generic"][i] != null) { OSD o = OSDParser.DeserializeJson (query["generic"][i]); if (o.Type == OSDType.Map) settings.Generic = (OSDMap)o; } if (query["terrainmaplastregenerated"][i] != null) settings.TerrainMapLastRegenerated = Util.ToDateTime(int.Parse(query["terrainmaplastregenerated"][i])); } } settings.OnSave += StoreRegionSettings; return settings; }
public void UnpackRegionInfoData(OSDMap args) { if (args.ContainsKey("region_id")) RegionID = args["region_id"].AsUUID(); if (args.ContainsKey("region_name")) RegionName = args["region_name"].AsString(); if (args.ContainsKey("http_port")) UInt32.TryParse(args["http_port"].AsString(), out m_httpPort); if (args.ContainsKey("region_xloc")) { int locx; Int32.TryParse(args["region_xloc"].AsString(), out locx); RegionLocX = locx; } if (args.ContainsKey("region_yloc")) { int locy; Int32.TryParse(args["region_yloc"].AsString(), out locy); RegionLocY = locy; } IPAddress ip_addr = null; if (args.ContainsKey("internal_ep_address")) { IPAddress.TryParse(args["internal_ep_address"].AsString(), out ip_addr); } int port = 0; if (args.ContainsKey("internal_ep_port")) { Int32.TryParse(args["internal_ep_port"].AsString(), out port); } InternalEndPoint = new IPEndPoint(ip_addr, port); if (args.ContainsKey("region_type")) m_regionType = args["region_type"].AsString(); if (args.ContainsKey("password")) Password = args["password"].AsUUID(); if (args.ContainsKey("disabled")) Disabled = args["disabled"].AsBoolean(); if (args.ContainsKey("scope_id")) ScopeID = args["scope_id"].AsUUID(); if (args.ContainsKey("all_scope_ids")) AllScopeIDs = ((OSDArray)args["all_scope_ids"]).ConvertAll<UUID>(o => o); if (args.ContainsKey("region_size_x")) RegionSizeX = args["region_size_x"].AsInteger(); if (args.ContainsKey("region_size_y")) RegionSizeY = args["region_size_y"].AsInteger(); if (args.ContainsKey("region_size_z")) RegionSizeZ = args["region_size_z"].AsInteger(); if (args.ContainsKey("object_capacity")) m_objectCapacity = args["object_capacity"].AsInteger(); if (args.ContainsKey("region_type")) RegionType = args["region_type"].AsString(); if (args.ContainsKey("see_into_this_sim_from_neighbor")) SeeIntoThisSimFromNeighbor = args["see_into_this_sim_from_neighbor"].AsBoolean(); if (args.ContainsKey("trust_binaries_from_foreign_sims")) TrustBinariesFromForeignSims = args["trust_binaries_from_foreign_sims"].AsBoolean(); if (args.ContainsKey("allow_script_crossing")) AllowScriptCrossing = args["allow_script_crossing"].AsBoolean(); if (args.ContainsKey("allow_physical_prims")) AllowPhysicalPrims = args["allow_physical_prims"].AsBoolean(); if (args.ContainsKey ("startupType")) Startup = (StartupType)args["startupType"].AsInteger(); if(args.ContainsKey("InfiniteRegion")) InfiniteRegion = args["InfiniteRegion"].AsBoolean(); if (args.ContainsKey("RegionSettings")) { RegionSettings = new RegionSettings(); RegionSettings.FromOSD((OSDMap)args["RegionSettings"]); } if (args.ContainsKey ("UDPPorts")) { OSDArray ports = (OSDArray)args["UDPPorts"]; foreach (OSD p in ports) m_UDPPorts.Add (p.AsInteger ()); } if (!m_UDPPorts.Contains (InternalEndPoint.Port)) m_UDPPorts.Add (InternalEndPoint.Port); }
public void UnpackRegionInfoData(OSDMap args) { if (args.ContainsKey("region_id")) { RegionID = args["region_id"].AsUUID(); } if (args.ContainsKey("region_name")) { RegionName = args["region_name"].AsString(); } if (args.ContainsKey("http_port")) { UInt32.TryParse(args["http_port"].AsString(), out m_httpPort); } if (args.ContainsKey("region_xloc")) { int locx; Int32.TryParse(args["region_xloc"].AsString(), out locx); RegionLocX = locx; } if (args.ContainsKey("region_yloc")) { int locy; Int32.TryParse(args["region_yloc"].AsString(), out locy); RegionLocY = locy; } IPAddress ip_addr = null; if (args.ContainsKey("internal_ep_address")) { IPAddress.TryParse(args["internal_ep_address"].AsString(), out ip_addr); } int port = 0; if (args.ContainsKey("internal_ep_port")) { Int32.TryParse(args["internal_ep_port"].AsString(), out port); } InternalEndPoint = new IPEndPoint(ip_addr, port); if (args.ContainsKey("region_type")) { m_regionType = args["region_type"].AsString(); } if (args.ContainsKey("password")) { Password = args["password"].AsUUID(); } if (args.ContainsKey("disabled")) { Disabled = args["disabled"].AsBoolean(); } if (args.ContainsKey("scope_id")) { ScopeID = args["scope_id"].AsUUID(); } if (args.ContainsKey("region_size_x")) { RegionSizeX = args["region_size_x"].AsInteger(); } if (args.ContainsKey("region_size_y")) { RegionSizeY = args["region_size_y"].AsInteger(); } if (args.ContainsKey("region_size_z")) { RegionSizeZ = args["region_size_z"].AsInteger(); } if (args.ContainsKey("object_capacity")) { m_objectCapacity = args["object_capacity"].AsInteger(); } if (args.ContainsKey("region_type")) { RegionType = args["region_type"].AsString(); } if (args.ContainsKey("see_into_this_sim_from_neighbor")) { SeeIntoThisSimFromNeighbor = args["see_into_this_sim_from_neighbor"].AsBoolean(); } if (args.ContainsKey("trust_binaries_from_foreign_sims")) { TrustBinariesFromForeignSims = args["trust_binaries_from_foreign_sims"].AsBoolean(); } if (args.ContainsKey("allow_script_crossing")) { AllowScriptCrossing = args["allow_script_crossing"].AsBoolean(); } if (args.ContainsKey("allow_physical_prims")) { AllowPhysicalPrims = args["allow_physical_prims"].AsBoolean(); } if (args.ContainsKey("number_startup")) { NumberStartup = args["number_startup"].AsInteger(); } if (args.ContainsKey("startupType")) { Startup = (StartupType)args["startupType"].AsInteger(); } if (args.ContainsKey("InfiniteRegion")) { InfiniteRegion = args["InfiniteRegion"].AsBoolean(); } if (args.ContainsKey("RegionSettings")) { RegionSettings = new RegionSettings(); RegionSettings.FromOSD((OSDMap)args["RegionSettings"]); } if (args.ContainsKey("UDPPorts")) { OSDArray ports = (OSDArray)args["UDPPorts"]; foreach (OSD p in ports) { m_UDPPorts.Add(p.AsInteger()); } } if (!m_UDPPorts.Contains(InternalEndPoint.Port)) { m_UDPPorts.Add(InternalEndPoint.Port); } }
/// <summary> /// Builds the region settings from a datarecod. /// </summary> /// <param name = "row">datarecord with regionsettings.</param> /// <returns></returns> private static RegionSettings BuildRegionSettings(IDataRecord row) { //TODO change this is some more generic code so we doesnt have to change it every time a new field is added? RegionSettings newSettings = new RegionSettings { RegionUUID = new UUID((Guid) row["regionUUID"]), BlockTerraform = Convert.ToBoolean(row["block_terraform"]), AllowDamage = Convert.ToBoolean(row["allow_damage"]), BlockFly = Convert.ToBoolean(row["block_fly"]), RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]), AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]), AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]), BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]), AgentLimit = Convert.ToInt32(row["agent_limit"]), ObjectBonus = Convert.ToDouble(row["object_bonus"]), Maturity = Convert.ToInt32(row["maturity"]), DisableScripts = Convert.ToBoolean(row["disable_scripts"]), DisableCollisions = Convert.ToBoolean(row["disable_collisions"]), DisablePhysics = Convert.ToBoolean(row["disable_physics"]), TerrainTexture1 = new UUID((Guid) row["terrain_texture_1"]), TerrainTexture2 = new UUID((Guid) row["terrain_texture_2"]), TerrainTexture3 = new UUID((Guid) row["terrain_texture_3"]), TerrainTexture4 = new UUID((Guid) row["terrain_texture_4"]), Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]), Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]), Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]), Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]), Elevation1SE = Convert.ToDouble(row["elevation_1_se"]), Elevation2SE = Convert.ToDouble(row["elevation_2_se"]), Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]), Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]), WaterHeight = Convert.ToDouble(row["water_height"]), TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]), TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]), UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]), Sandbox = Convert.ToBoolean(row["sandbox"]), FixedSun = Convert.ToBoolean(row["fixed_sun"]), SunPosition = Convert.ToDouble(row["sun_position"]), SunVector = new Vector3( Convert.ToSingle(row["sunvectorx"]), Convert.ToSingle(row["sunvectory"]), Convert.ToSingle(row["sunvectorz"]) ), Covenant = new UUID((Guid) row["covenant"]), CovenantLastUpdated = Convert.ToInt32(row["covenantlastupdated"]), MinimumAge = Convert.ToInt32(row["minimum_age"]), LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]) }; if (row["loaded_creation_id"] is DBNull) newSettings.LoadedCreationID = ""; else newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; OSD o = OSDParser.DeserializeJson((String) row["generic"]); if (o.Type == OSDType.Map) newSettings.Generic = (OSDMap) o; return newSettings; }
private warp_Object CreateTerrain(WarpRenderer renderer, bool textureTerrain) { ITerrainChannel terrain = m_scene.RequestModuleInterface <ITerrainChannel>(); int diff = m_scene.RegionInfo.RegionSizeY / Constants.RegionSize; warp_Object obj = new warp_Object((m_scene.RegionInfo.RegionSizeX / diff) * (m_scene.RegionInfo.RegionSizeY / diff), ((m_scene.RegionInfo.RegionSizeX / diff) - 1) * ((m_scene.RegionInfo.RegionSizeY / diff) - 1) * 2); for (int y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diff) { for (int x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diff) { warp_Vector pos = ConvertVector(x, y, terrain[x, y]); obj.addVertex(new warp_Vertex(pos, (float)x / (m_scene.RegionInfo.RegionSizeX), (float)((m_scene.RegionInfo.RegionSizeX) - y) / (m_scene.RegionInfo.RegionSizeX))); } } for (int y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diff) { for (int x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diff) { int newX = x / diff; int newY = y / diff; if (newX < Constants.RegionSize - 1 && newY < Constants.RegionSize - 1) { int v = newY * Constants.RegionSize + newX; // Normal Vector3 v1 = new Vector3(newX, newY, (terrain[x, y]) / Constants.TerrainCompression); Vector3 v2 = new Vector3(newX + 1, newY, (terrain[x + 1, y]) / Constants.TerrainCompression); Vector3 v3 = new Vector3(newX, newY + 1, (terrain[x, (y + 1)]) / Constants.TerrainCompression); warp_Vector norm = ConvertVector(SurfaceNormal(v1, v2, v3)); norm = norm.reverse(); obj.vertex(v).n = norm; // Triangle 1 obj.addTriangle( v, v + 1, v + Constants.RegionSize); // Triangle 2 obj.addTriangle( v + Constants.RegionSize + 1, v + Constants.RegionSize, v + 1); } } } renderer.Scene.addObject("Terrain", obj); UUID[] textureIDs = new UUID[4]; float[] startHeights = new float[4]; float[] heightRanges = new float[4]; RegionSettings regionInfo = m_scene.RegionInfo.RegionSettings; textureIDs[0] = regionInfo.TerrainTexture1; textureIDs[1] = regionInfo.TerrainTexture2; textureIDs[2] = regionInfo.TerrainTexture3; textureIDs[3] = regionInfo.TerrainTexture4; startHeights[0] = (float)regionInfo.Elevation1SW; startHeights[1] = (float)regionInfo.Elevation1NW; startHeights[2] = (float)regionInfo.Elevation1SE; startHeights[3] = (float)regionInfo.Elevation1NE; heightRanges[0] = (float)regionInfo.Elevation2SW; heightRanges[1] = (float)regionInfo.Elevation2NW; heightRanges[2] = (float)regionInfo.Elevation2SE; heightRanges[3] = (float)regionInfo.Elevation2NE; uint globalX, globalY; Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out globalX, out globalY); Bitmap image = TerrainSplat.Splat(terrain, textureIDs, startHeights, heightRanges, new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain); warp_Texture texture = new warp_Texture(image); warp_Material material = new warp_Material(texture); material.setReflectivity(0); // reduces tile seams a bit thanks lkalif renderer.Scene.addMaterial("TerrainColor", material); renderer.SetObjectMaterial("Terrain", "TerrainColor"); return(obj); }