public void ApplyStrech(int x, int y, sbyte z) { Map.Map map = World.Map; if (IsStretched || UOFileManager.Textmaps.GetTexture(TileData.TexID) == null || !TestStretched(x, y, z, true)) { IsStretched = false; MinZ = z; } else { IsStretched = true; UpdateZ( map.GetTileZ(x, y + 1), map.GetTileZ(x + 1, y + 1), map.GetTileZ(x + 1, y), z); Vector3[,,] vec = new Vector3[3, 3, 4]; int i; int j; if (Normals == null || Normals.Length != 4) { Normals = new Vector3[4]; } for (i = -1; i < 2; i++) { int curX = x + i; int curI = i + 1; for (j = -1; j < 2; j++) { int curY = y + j; int curJ = j + 1; sbyte currentZ = map.GetTileZ(curX, curY); sbyte leftZ = map.GetTileZ(curX, curY + 1); sbyte rightZ = map.GetTileZ(curX + 1, curY); sbyte bottomZ = map.GetTileZ(curX + 1, curY + 1); if (currentZ == leftZ && currentZ == rightZ && currentZ == bottomZ) { for (int k = 0; k < 4; k++) { ref var v = ref vec[curI, curJ, k]; v.X = 0; v.Y = 0; v.Z = 1; } }
public void ApplyStrech(int x, int y, sbyte z) { Map.Map map = World.Map; if (IsStretched || TexmapsLoader.Instance.GetTexture(TileData.TexID) == null || !TestStretched(x, y, z, true)) { IsStretched = false; MinZ = z; } else { IsStretched = true; UpdateZ ( map.GetTileZ(x, y + 1), map.GetTileZ(x + 1, y + 1), map.GetTileZ(x + 1, y), z ); //Vector3[,,] vec = new Vector3[3, 3, 4]; int i; int j; for (i = -1; i < 2; i++) { int curX = x + i; int curI = i + 1; for (j = -1; j < 2; j++) { int curY = y + j; int curJ = j + 1; sbyte currentZ = map.GetTileZ(curX, curY); sbyte leftZ = map.GetTileZ(curX, curY + 1); sbyte rightZ = map.GetTileZ(curX + 1, curY); sbyte bottomZ = map.GetTileZ(curX + 1, curY + 1); if (currentZ == leftZ && currentZ == rightZ && currentZ == bottomZ) { for (int k = 0; k < 4; k++) { ref Vector3 v = ref _vectCache[curI, curJ, k]; v.X = 0; v.Y = 0; v.Z = 1; } }
public unsafe void ApplyStretch(Map.Map map, int x, int y, sbyte z) { if (IsStretched || TexmapsLoader.Instance.GetTexture(TileData.TexID) == null || !TestStretched(x, y, z, true)) { IsStretched = false; MinZ = z; } else { IsStretched = true; UpdateZ(map.GetTileZ(x, y + 1), map.GetTileZ(x + 1, y + 1), map.GetTileZ(x + 1, y), z); int i; int j; const int SIZE = 3 * 3 * 4; Vector3 * vectBuffer = stackalloc Vector3[SIZE]; for (i = -1; i < 2; ++i) { int curX = x + i; int curI = i + 1; for (j = -1; j < 2; ++j) { int curY = y + j; int curJ = j + 1; sbyte currentZ = map.GetTileZ(curX, curY); sbyte leftZ = map.GetTileZ(curX, curY + 1); sbyte rightZ = map.GetTileZ(curX + 1, curY); sbyte bottomZ = map.GetTileZ(curX + 1, curY + 1); if (currentZ == leftZ && currentZ == rightZ && currentZ == bottomZ) { for (int k = 0; k < 4; ++k) { ref Vector3 v = ref vectBuffer[k + curJ * 3 + curI * 3 * 4]; v.X = 0; v.Y = 0; v.Z = 1; } }
private void UpdateStreched(int x, int y, sbyte z) { Map.Map map = World.Map; if (IsStretched || FileManager.Textmaps.GetTexture(TileData.TexID) == null || !TestStretched(x, y, z, true)) { IsStretched = false; MinZ = z; } else { IsStretched = true; UpdateZ(map.GetTileZ(x, y + 1), map.GetTileZ(x + 1, y + 1), map.GetTileZ(x + 1, y), z); Vector3[,,] vec = new Vector3[3, 3, 4]; int i; int j; for (i = -1; i < 2; i++) { int curX = x + i; int curI = i + 1; for (j = -1; j < 2; j++) { int curY = y + j; int curJ = j + 1; sbyte currentZ = map.GetTileZ(curX, curY); sbyte leftZ = map.GetTileZ(curX, curY + 1); sbyte rightZ = map.GetTileZ(curX + 1, curY); sbyte bottomZ = map.GetTileZ(curX + 1, curY + 1); if (currentZ == leftZ && currentZ == rightZ && currentZ == bottomZ) { for (int k = 0; k < 4; k++) { vec[curI, curJ, k] = new Vector3(0, 0, 1); } } else { vec[curI, curJ, 0] = new Vector3(-22.0f, 22.0f, (currentZ - rightZ) * 4); Merge(ref vec[curI, curJ, 0], -22.0f, -22.0f, (leftZ - currentZ) * 4); vec[curI, curJ, 0].Normalize(); vec[curI, curJ, 1] = new Vector3(22.0f, 22.0f, (rightZ - bottomZ) * 4); Merge(ref vec[curI, curJ, 1], -22.0f, 22.0f, (currentZ - rightZ) * 4); vec[curI, curJ, 1].Normalize(); vec[curI, curJ, 2] = new Vector3(22.0f, -22.0f, (bottomZ - leftZ) * 4); Merge(ref vec[curI, curJ, 2], 22.0f, 22.0f, (rightZ - bottomZ) * 4); vec[curI, curJ, 2].Normalize(); vec[curI, curJ, 3] = new Vector3(-22.0f, -22.0f, (leftZ - currentZ) * 4); Merge(ref vec[curI, curJ, 3], 22.0f, -22.0f, (bottomZ - leftZ) * 4); vec[curI, curJ, 3].Normalize(); } } } i = 1; j = 1; _normals[0] = vec[i - 1, j - 1, 2] + vec[i - 1, j, 1] + vec[i, j - 1, 3] + vec[i, j, 0]; _normals[0].Normalize(); _normals[1] = vec[i, j - 1, 2] + vec[i, j, 1] + vec[i + 1, j - 1, 3] + vec[i + 1, j, 0]; _normals[1].Normalize(); _normals[2] = vec[i, j, 2] + vec[i, j + 1, 1] + vec[i + 1, j, 3] + vec[i + 1, j + 1, 0]; _normals[2].Normalize(); _normals[3] = vec[i - 1, j, 2] + vec[i - 1, j + 1, 1] + vec[i, j, 3] + vec[i, j + 1, 0]; _normals[3].Normalize(); _vertex[0].Normal = _normals[0]; _vertex[1].Normal = _normals[1]; _vertex[3].Normal = _normals[2]; _vertex[2].Normal = _normals[3]; _vertex0_yOffset = new Vector3(22, -Rectangle.Left, 0); _vertex1_yOffset = new Vector3(44, 22 - Rectangle.Bottom, 0); _vertex2_yOffset = new Vector3(0, 22 - Rectangle.Top, 0); _vertex3_yOffset = new Vector3(22, 44 - Rectangle.Right, 0); } Vector3 hue = ShaderHuesTraslator.GetHueVector(Hue); if (_vertex[0].Hue != hue) { _vertex[0].Hue = _vertex[1].Hue = _vertex[2].Hue = _vertex[3].Hue = hue; } }
public void ApplyStretch(Map.Map map, int x, int y, sbyte z) { if (IsStretched || TexmapsLoader.Instance.GetValidRefEntry(TileData.TexID).Length <= 0) { IsStretched = false; AverageZ = z; MinZ = z; return; } /* _____ _____ * | top | rig | * |_____|_____| * | lef | bot | * |_____|_____| */ sbyte zTop = z; sbyte zRight = map.GetTileZ(x + 1, y); sbyte zLeft = map.GetTileZ(x, y + 1); sbyte zBottom = map.GetTileZ(x + 1, y + 1); YOffsets.Top = zTop * 4; YOffsets.Right = zRight * 4; YOffsets.Left = zLeft * 4; YOffsets.Bottom = zBottom * 4; if (Math.Abs(zTop - zBottom) <= Math.Abs(zLeft - zRight)) { AverageZ = (sbyte)((zTop + zBottom) >> 1); } else { AverageZ = (sbyte)((zLeft + zRight) >> 1); } MinZ = Math.Min(zTop, Math.Min(zRight, Math.Min(zLeft, zBottom))); /* _____ _____ _____ _____ * | | t10 | t20 | | * |_____|_____|_____|_____| * | t01 | z | t21 | t31 | * |_____|_____|_____|_____| * | t02 | t12 | t22 | t32 | * |_____|_____|_____|_____| * | | t13 | t23 | | * |_____|_____|_____|_____| */ sbyte t10 = map.GetTileZ(x, y - 1); sbyte t20 = map.GetTileZ(x + 1, y - 1); sbyte t01 = map.GetTileZ(x - 1, y); sbyte t21 = zRight; sbyte t31 = map.GetTileZ(x + 2, y); sbyte t02 = map.GetTileZ(x - 1, y + 1); sbyte t12 = zLeft; sbyte t22 = zBottom; sbyte t32 = map.GetTileZ(x + 2, y + 1); sbyte t13 = map.GetTileZ(x, y + 2); sbyte t23 = map.GetTileZ(x + 1, y + 2); IsStretched |= CalculateNormal(z, t10, t21, t12, t01, out NormalTop); IsStretched |= CalculateNormal(t21, t20, t31, t22, z, out NormalRight); IsStretched |= CalculateNormal(t22, t21, t32, t23, t12, out NormalBottom); IsStretched |= CalculateNormal(t12, z, t22, t13, t02, out NormalLeft); }