public static void unpackConfig(StreamLoader streamLoader) { ByteBuffer buffer = ByteBuffer.Wrap(streamLoader.getDataForName("flo2.dat")); int count = buffer.GetShort(); overLayFlo317s = new OverLayFlo317[count]; for (int i = 0; i < count; i++) { if (overLayFlo317s[i] == null) { overLayFlo317s[i] = new OverLayFlo317(); } overLayFlo317s[i].parse(buffer); } Debug.Log("530 Overlay Floors amount: " + count); }
public RSTerrain(Region region) { this.region = region; textureMap = NetDrawingTools.CreateDoubleIntArray(105, 105); colourMap = NetDrawingTools.CreateDoubleColor32Array(105, 105); heightMap = NetDrawingTools.CreateDoubleIntArray(104, 104); byte[][] underlays = region.tile_layer0_type [heightLevel]; sbyte[][] overlays = region.tile_layer1_type [heightLevel]; int[][] underlaysRgb = region.tile_layer0_colour [heightLevel]; int[][][] tileH = MapManager.getTileHeight(region.myRegionX, region.myRegionY); if (tileH == null) { tileH = NetDrawingTools.CreateTrippleIntArray(4, 104, 104); } int[][] heightmap = tileH [heightLevel]; for (int x = 0; x < 104; x++) { for (int z = 0; z < 104; z++) { if (underlays [x] [z] == 0) { underlays [x] [z] = 1; } OverLayFlo317 underlay = OverLayFlo317.overLayFlo317s [underlays [x] [z] - 1]; //Floor underlay = Floor.floors[underlays [x] [z] - 1]; OverLayFlo317 overLay = null; int overLayId = overlays [x] [z] & 0xff; if (overLayId >= 1 && overLayId - 1 < OverLayFlo317.overLayFlo317s.Length) { overLay = OverLayFlo317.overLayFlo317s [overLayId - 1]; } int underlayRgb = underlaysRgb [x] [z]; colourMap [x] [z] = fromRgb(underlayRgb, 255); //new Color32(underlayRgb >> 16,underlayRgb >> 8,underlayRgb & 0xFF,255); textureMap [x] [z] = underlay.textureId; //texture; heightMap [x] [z] = (((!(region.tile_layer1_type [heightLevel] [x] [z] == 6 && region.tile_layer1_shape [heightLevel] [x] [z] != 1)) || heightmap [x] [z] != 0) ? -heightmap [x] [z] : -200) - 9; if (overLay != null) { overlayTextures [x, z] = overLay.textureId; } } } }
private void InitializeRune() { anIntArray1232 = new int[32]; int a = 2; for (int k = 0; k < 32; k++) { anIntArray1232 [k] = a - 1; a += a; } signlink.storeid = 0; signlink.run(); for (int i = 0; i < 5; i++) { decompressors [i] = new Decompressor(signlink.cache_dat, signlink.cache_idx [i], i + 1); } StreamLoader streamLoader_6 = streamLoaderForName(5, "update list", "versionlist"); onDemandFetcher = new OnDemandFetcher(); onDemandFetcher.start(streamLoader_6); StreamLoader streamLoader = streamLoaderForName(2, "config", "config"); RS2Sharp.Animation.unpackConfig(streamLoader); //RS2Sharp.Texture.method368(streamLoader_3); RS2Sharp.Texture.method372(0.80000000000000004D); RS2Sharp.Texture.method367(); ItemDef.unpackConfig(streamLoader); EntityDef.unpackConfig(streamLoader); IDK.unpackConfig(streamLoader); SpotAnim.unpackConfig(streamLoader); Varp.unpackConfig(streamLoader); VarBit.unpackConfig(streamLoader); ObjectDef.unpackConfig(streamLoader); Flo.unpackConfig(streamLoader); OverLayFlo317.unpackConfig(streamLoader); Model.initialize(65535, onDemandFetcher); initialized = true; }
static void GetRuneTextures() { int lowerRegion = 0; int upperRegion = 100; for (int regionX = lowerRegion; regionX < upperRegion; regionX++) { for (int regionZ = lowerRegion; regionZ < upperRegion; regionZ++) { Region region = MapManager.GetRegion(regionX, regionZ); Color32[][] colourMap = NetDrawingTools.CreateDoubleColor32Array(105, 105); int[][] underlaysRgb = region.tile_layer0_colour [0]; int[,] overlayTextures = new int[105, 105]; int[][] textureMap = new int[105][]; //104]; byte[][] underlays = region.tile_layer0_type [0]; sbyte[][] overlays = region.tile_layer1_type [0]; textureMap = NetDrawingTools.CreateDoubleIntArray(105, 105); for (int x = 0; x < 104; x++) { for (int z = 0; z < 104; z++) { if (underlays [x] [z] == 0) { underlays [x] [z] = 1; } OverLayFlo317 underlay = OverLayFlo317.overLayFlo317s [underlays [x] [z] - 1]; //Floor underlay = Floor.floors[underlays [x] [z] - 1]; OverLayFlo317 overLay = null; int overLayId = overlays [x] [z] & 0xff; if (overLayId >= 1 && overLayId - 1 < OverLayFlo317.overLayFlo317s.Length) { overLay = OverLayFlo317.overLayFlo317s [overLayId - 1]; } int underlayRgb = underlaysRgb [x] [z]; colourMap [x] [z] = fromRgb(underlayRgb, 255); //new Color32(underlayRgb >> 16,underlayRgb >> 8,underlayRgb & 0xFF,255); textureMap [x] [z] = underlay.textureId; //texture; if (overLay != null) { overlayTextures [x, z] = overLay.textureId; } } } List <int> texIds = new List <int>(); for (int x = 0; x < 64; ++x) { for (int y = 0; y < 64; ++y) { int overlayTexture = overlayTextures [x, y]; int underlayTexture = textureMap [x] [y]; if (overlayTexture > 0) { if (!texIds.Contains(overlayTexture)) { texIds.Add(overlayTexture); } } if (underlayTexture > 0) { if (!texIds.Contains(underlayTexture)) { texIds.Add(underlayTexture); } } } } foreach (int tex in texIds) { Texture2D alreadyThere = Resources.Load("Textures/Rune Textures/" + tex) as Texture2D; if (alreadyThere == null) { Texture2D textureToGrab = UnityClient.LoadTexture(tex); Color32[] colorbytes = textureToGrab.GetPixels32(); for (int i = 0; i < colorbytes.Length; ++i) { colorbytes[i] = new Color32((byte)(colorbytes[i].r * 0.5f), (byte)(colorbytes[i].g * 0.5f), (byte)(colorbytes[i].b * 0.5f), (byte)(colorbytes[i].a)); } textureToGrab.SetPixels32(colorbytes); textureToGrab.Apply(); byte[] bytes = textureToGrab.EncodeToPNG(); File.WriteAllBytes(Application.dataPath + "/../Assets/Resources/Textures/Rune Textures/" + tex + ".png", bytes); File.WriteAllBytes(Application.dataPath + "/../Assets/Resources/Textures/Rune Textures/" + tex + " Bump.png", bytes); } } } } }
static void GenTerrainData() { int lowerRegion = 0; int upperRegion = 96; for (int regionX = 32; regionX < 65; regionX++) { for (int regionZ = lowerRegion; regionZ < upperRegion; regionZ++) { Region region = MapManager.GetRegion(regionX, regionZ); int[][] textureMap = new int[105][]; //104]; Color32[][] colourMap = new Color32[105][]; //[104]; int[][] heightMap = new int[105][]; //[104]; int heightLevel = 0; int[,] overlayTextures = new int[105, 105]; Vector3[][] normalMap; textureMap = NetDrawingTools.CreateDoubleIntArray(105, 105); colourMap = NetDrawingTools.CreateDoubleColor32Array(105, 105); heightMap = NetDrawingTools.CreateDoubleIntArray(104, 104); byte[][] underlays = region.tile_layer0_type [heightLevel]; sbyte[][] overlays = region.tile_layer1_type [heightLevel]; int[][] underlaysRgb = region.tile_layer0_colour [heightLevel]; int[][][] tileH = MapManager.getTileHeight(region.myRegionX, region.myRegionY); if (tileH == null) { tileH = NetDrawingTools.CreateTrippleIntArray(4, 104, 104); } int[][] heightmap = tileH [heightLevel]; for (int x = 0; x < 104; x++) { for (int z = 0; z < 104; z++) { if (underlays [x] [z] == 0) { underlays [x] [z] = 1; } OverLayFlo317 underlay = OverLayFlo317.overLayFlo317s [underlays [x] [z] - 1]; //Floor underlay = Floor.floors[underlays [x] [z] - 1]; OverLayFlo317 overLay = null; int overLayId = overlays [x] [z] & 0xff; if (overLayId >= 1 && overLayId - 1 < OverLayFlo317.overLayFlo317s.Length) { overLay = OverLayFlo317.overLayFlo317s [overLayId - 1]; } int underlayRgb = underlaysRgb [x] [z]; colourMap [x] [z] = fromRgb(underlayRgb, 255); //new Color32(underlayRgb >> 16,underlayRgb >> 8,underlayRgb & 0xFF,255); textureMap [x] [z] = underlay.textureId; //texture; heightMap [x] [z] = (((!(region.tile_layer1_type [heightLevel] [x] [z] == 6 && region.tile_layer1_shape [heightLevel] [x] [z] != 1)) || heightmap [x] [z] != 0) ? -heightmap [x] [z] : -200) - 9; if (overLay != null) { overlayTextures [x, z] = overLay.textureId; } } } float[,] heights = new float[65, 65]; for (int x = 0; x < 65; ++x) { for (int y = 0; y < 65; ++y) { int localX = Mathf.FloorToInt((x / 1f)); int localY = Mathf.FloorToInt((y / 1f)); heights [x, y] = heightMap [localY] [localX] / 2048.0f; } } List <SplatPrototype> splatPrototypes = new List <SplatPrototype> (); List <int> splatPrototypeIds = new List <int> (); TerrainData terrainData = new TerrainData(); terrainData.heightmapResolution = 64; terrainData.SetHeights(0, 0, heights); terrainData.alphamapResolution = 64; terrainData.baseMapResolution = 64; // File.WriteAllBytes(Application.dataPath + "/../Assets/Resources/Maps/Colormaps/"+ "Regions X-" + xOffset + "-" + (xOffset+32) + " Y-" + yOffset + "-" + (yOffset + 32) +".png", bytes); int xOff = Mathf.FloorToInt(region.myRegionX / 32) * 32; int yOff = Mathf.FloorToInt(region.myRegionY / 32) * 32; string colormapId = "Regions X-" + xOff + "-" + (Mathf.FloorToInt(region.myRegionX / 32) == 0 ? 32 : Mathf.FloorToInt(region.myRegionX / 32) == 1 ? 64 : Mathf.FloorToInt(region.myRegionX / 32) == 2 ? 96 : 0) + " Y-" + yOff + "-" + (Mathf.FloorToInt(region.myRegionY / 32) == 0 ? 32 : Mathf.FloorToInt(region.myRegionY / 32) == 1 ? 64 : Mathf.FloorToInt(region.myRegionY / 32) == 2 ? 96 : 0); Debug.Log(colormapId); Texture2D overlaySplat = Resources.Load("Maps/Colormaps/" + colormapId) as Texture2D; //new Texture2D (64, 64); for (int x = 0; x < 64; ++x) { for (int y = 0; y < 64; ++y) { Color32 color = colourMap [x] [y]; Color newColor = new Color(color.r / 255f, color.g / 255f, color.b / 255f, color.a / 255f); //overlaySplat.SetPixel (x, y, newColor); int overlayTexture = overlayTextures [x, y]; int underlayTexture = textureMap [x] [y]; if (overlayTexture > 0 && overlayTexture != 669 && overlayTexture != 651) { if (!splatPrototypeIds.Contains(overlayTexture)) { SplatPrototype splatToAdd = new SplatPrototype(); Texture2D colorTexture = UnityClient.LoadTexture(overlayTexture); Texture2D normal = UnityClient.CreateDOT3(colorTexture, 40f, 0f, overlayTexture); splatToAdd.texture = colorTexture; splatToAdd.normalMap = normal; splatToAdd.tileSize = new Vector2(1, 1); splatToAdd.smoothness = 0.5f; splatToAdd.metallic = 0f; splatPrototypes.Add(splatToAdd); splatPrototypeIds.Add(overlayTexture); } } if (underlayTexture > 0 && underlayTexture != 669 && underlayTexture != 651) { if (!splatPrototypeIds.Contains(underlayTexture)) { SplatPrototype splatToAdd = new SplatPrototype(); Texture2D colorTexture = UnityClient.LoadTexture(underlayTexture); Texture2D normal = normal = UnityClient.CreateDOT3(colorTexture, 40f, 0f, underlayTexture); splatToAdd.texture = colorTexture; splatToAdd.normalMap = normal; splatToAdd.tileSize = new Vector2(1, 1); splatToAdd.smoothness = 0.5f; splatToAdd.metallic = 0f; splatPrototypes.Add(splatToAdd); splatPrototypeIds.Add(underlayTexture); } } } } //overlaySplat.filterMode = FilterMode.Point; //overlaySplat.Apply (); //overlaySplat = FastBlur (overlaySplat, 4, 1); //overlaySplat.Apply (); SplatPrototype aSplat = new SplatPrototype(); string regionName = "Region " + region.myRegionX + " " + region.myRegionY; int myRegionX = region.myRegionX; int myRegionY = region.myRegionY; int offsetX = (myRegionX - xOff) * 64; int offsetY = (myRegionY - yOff) * 64; aSplat.texture = overlaySplat; aSplat.tileSize = new Vector2(2048, 2048); aSplat.tileOffset = new Vector2(offsetX, offsetY); aSplat.smoothness = 0f; splatPrototypes.Insert(0, aSplat); splatPrototypeIds.Insert(0, 0); terrainData.splatPrototypes = splatPrototypes.ToArray(); float[, ,] splatmapData = new float[terrainData.alphamapWidth, terrainData.alphamapHeight, terrainData.alphamapLayers]; for (int x = 0; x < terrainData.alphamapWidth; ++x) { for (int y = 0; y < terrainData.alphamapHeight; ++y) { splatmapData[x, y, 0] = 1; //1; } } for (int x = 0; x < terrainData.alphamapWidth; ++x) { for (int y = 0; y < terrainData.alphamapHeight; ++y) { int overlayTexture = overlayTextures [y, x]; int underlayTexture = textureMap [y] [x]; if (underlayTexture > 0) { splatmapData[x, y, 0] = 0.5f; int idx = 0; for (int i = 0; i < terrainData.splatPrototypes.Length; ++i) { SplatPrototype item = terrainData.splatPrototypes[i]; if (item.texture.name == "" + underlayTexture) { idx = i; break; } } splatmapData[x, y, idx] = 0.5f; } if (overlayTexture > 0) { for (int i = 0; i < terrainData.alphamapLayers; ++i) { splatmapData[x, y, i] = 0f; } int idx = 0; for (int i = 0; i < terrainData.splatPrototypes.Length; ++i) { SplatPrototype item = terrainData.splatPrototypes[i]; if (item.texture.name == "" + overlayTexture) { idx = i; break; } } splatmapData[x, y, idx] = 1f; } } } terrainData.SetAlphamaps(0, 0, splatmapData); terrainData.size = new Vector3(64, 16.54f, 64); //4.14 //GameObject terrain = Terrain.CreateTerrainGameObject (terrainData); //terrain.GetComponent<Terrain> ().basemapDistance = 35; //terrain.GetComponent<Terrain> ().materialType = Terrain.MaterialType.Custom; // terrain.GetComponent<Terrain> ().materialTemplate = GameObject.Find ("ClientCamera").GetComponent<UnityClient>().terrainMatToApply; //terrain.GetComponent<Terrain> ().reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Simple; terrainData.wavingGrassSpeed = 0.219f; terrainData.wavingGrassStrength = 0.686f; terrainData.wavingGrassAmount = 0.106f; terrainData.SetDetailResolution(64, 8); //terrain.layer = LayerMask.NameToLayer ("Terrain"); //Save Terrain string baseFolder = "Assets/Resources/Maps/TerrainData/"; TerrainData dataToSave = terrainData; SplatPrototype[] splat = dataToSave.splatPrototypes; float[,,] alphaMaps = dataToSave.GetAlphamaps(0, 0, 64, 64); AssetDatabase.CreateAsset(dataToSave, baseFolder + "TerrainData " + region.myRegionX + " " + region.myRegionY + ".asset"); AssetDatabase.SaveAssets(); TerrainData dataLoaded = (TerrainData)AssetDatabase.LoadAssetAtPath(baseFolder + "TerrainData " + region.myRegionX + " " + region.myRegionY + ".asset", typeof(TerrainData)); dataLoaded.splatPrototypes = splat; dataLoaded.SetAlphamaps(0, 0, alphaMaps); dataLoaded.RefreshPrototypes(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } } Debug.Log("Finished Generating " + ((upperRegion - lowerRegion) * (upperRegion - lowerRegion)) + " TerrainData's"); }
private void loadData(Region region) { triangleCount = 6 * 104 * 104; //Maximal triangle count vertexCount = 6 * 104 * 104; //Maximal triangle count textureTriangles = new int[triangleCount]; textureTypes = new int[triangleCount]; texcoord = new Vector3[vertexCount]; vertexes = new Vector3[vertexCount]; triangleA = new int[triangleCount]; isWater = new bool[triangleCount]; triangleB = new int[triangleCount]; triangleC = new int[triangleCount]; triangleHslA = new int[triangleCount]; triangleHslB = new int[triangleCount]; triangleHslC = new int[triangleCount]; triangleAlphaA = new int[triangleCount]; triangleAlphaB = new int[triangleCount]; triangleAlphaC = new int[triangleCount]; int[] triangleTex = new int[triangleCount]; triangleCount = 0; vertexCount = 0; for (int x = 0; x < 104; x++) { for (int z = 0; z < 104; z++) { int shapeA = region.tile_layer1_shape[heightLevel][x][z] + 1; int shapeB = region.tile_layer1_orientation[heightLevel][x][z]; int overlay = region.tile_layer1_type[heightLevel][x][z] & 0xff; int[][][] tileH = MapManager.getTileHeight(region.myRegionX, region.myRegionY); if (tileH == null) { return; } int yA = /*-*/ tileH[heightLevel][x][z]; int yB = /*-*/ tileH[heightLevel][x + 1][z]; int yD = /*-*/ tileH[heightLevel][x + 1][z + 1]; int yC = /*-*/ tileH[heightLevel][x][z + 1]; int underlayRgb = region.tile_layer0_colour [heightLevel][x][z]; if (overlay >= 1) { if (overlay >= /*Floor.cache*/ OverLayFlo317.overLayFlo317s.Length) { overlay = 184; //Debug.Log ("Error, " + overlay + " is greater than length = >" + /*Floor.cache*/OverLayFlo317.overLayFlo317s.Length); } //else //{ OverLayFlo317 overlayFloor = /*Floor.cache*/ OverLayFlo317.overLayFlo317s[overlay - 1]; //Debug.Log (overlayFloor.rgb); int waterColor = 6321818; if /*(overlayFloor.textureId != 669)//*/ (overlayFloor.rgb != 0xFF00FF && overlayFloor.rgb != waterColor) // && overlayFloor.rgb != 0xFFFFFF && overlayFloor.rgb != 7509687) //if(overlayFloor.textureId != 669 && overlayFloor.textureId != 651) { generateDataForTile(x, z, yA + 1, yB + 1, yC + 1, yD + 1, overlayFloor.rgb, overlayFloor.rgb, overlayFloor.rgb, overlayFloor.rgb, overlayFloor.textureId, shapeA, shapeB, overlayFloor.alpha, false, overlayFloor.textureId, triangleTex); } if /*(overlayFloor.textureId == 669)//*/ (overlayFloor.rgb == 0xFFFFFF || overlayFloor.rgb == waterColor) //7509687) //Water //{ //else { generateDataForTile(x, z, yA + 1, yB + 1, yC + 1, yD + 1, overlayFloor.rgb, overlayFloor.rgb, overlayFloor.rgb, overlayFloor.rgb, overlayFloor.textureId, shapeA, shapeB, overlayFloor.alpha, true, overlayFloor.textureId, triangleTex); } //} //} } } } calculateNormals508(); for (int triPtr = 0; triPtr < triangleCount; triPtr++) { addTriangle(triPtr, triangleTex[triPtr]); } }