static DeformationTable CreateTable(Vector3I normal) { DeformationTable result = new DeformationTable(); result.Normal = normal; Vector3I centerBone = new Vector3I(1, 1, 1); var absNormal = Vector3I.Abs(normal); var mask = new Vector3I(1, 1, 1) - absNormal; mask *= 2; for (int x = -mask.X; x <= mask.X; x++) { for (int y = -mask.Y; y <= mask.Y; y++) { for (int z = -mask.Z; z <= mask.Z; z++) { var offset = new Vector3I(x, y, z); float maxOffset = Math.Max(Math.Abs(z), Math.Max(Math.Abs(x), Math.Abs(y))); float ratio = 1; if (maxOffset > 1) ratio = 0.3f; float moveDist = ratio * MyGridConstants.DEFORMATION_TABLE_BASE_MOVE_DIST; Vector3I offsetA = centerBone + new Vector3I(x, y, z) + normal; result.OffsetTable.Add(offsetA, -normal * moveDist); result.MinOffset = Vector3I.Min(result.MinOffset, offset); result.MaxOffset = Vector3I.Max(result.MaxOffset, offset); } } } return result; }
private static DeformationTable CreateTable(Vector3I normal) { DeformationTable table = new DeformationTable { Normal = normal }; Vector3I vectori = new Vector3I(1, 1, 1); Vector3I vectori2 = Vector3I.Abs(normal); Vector3I vectori3 = (new Vector3I(1, 1, 1) - vectori2) * 2; int x = -vectori3.X; while (x <= vectori3.X) { int y = -vectori3.Y; while (true) { if (y > vectori3.Y) { x++; break; } int z = -vectori3.Z; while (true) { if (z > vectori3.Z) { y++; break; } Vector3I vectori4 = new Vector3I(x, y, z); float num4 = 1f; if (Math.Max(Math.Abs(z), Math.Max(Math.Abs(x), Math.Abs(y))) > 1f) { num4 = 0.3f; } float num5 = num4 * 0.25f; Vector3I key = (Vector3I)((vectori + new Vector3I(x, y, z)) + normal); table.OffsetTable.Add(key, Matrix.CreateFromDir((Vector3)(-normal * num5))); Vector3I item = key >> 1; Vector3I vectori7 = (key - Vector3I.One) >> 1; table.CubeOffsets.Add(item); table.CubeOffsets.Add(vectori7); table.MinOffset = Vector3I.Min(table.MinOffset, vectori4); table.MaxOffset = Vector3I.Max(table.MaxOffset, vectori4); z++; } } } return(table); }
static DeformationTable CreateTable(Vector3I normal) { DeformationTable result = new DeformationTable(); result.Normal = normal; Vector3I centerBone = new Vector3I(1, 1, 1); var absNormal = Vector3I.Abs(normal); var mask = new Vector3I(1, 1, 1) - absNormal; mask *= 2; for (int x = -mask.X; x <= mask.X; x++) { for (int y = -mask.Y; y <= mask.Y; y++) { for (int z = -mask.Z; z <= mask.Z; z++) { var offset = new Vector3I(x, y, z); float maxOffset = Math.Max(Math.Abs(z), Math.Max(Math.Abs(x), Math.Abs(y))); float ratio = 1; if (maxOffset > 1) { ratio = 0.3f; } float moveDist = ratio * MyGridConstants.DEFORMATION_TABLE_BASE_MOVE_DIST; Vector3I offsetA = centerBone + new Vector3I(x, y, z) + normal; result.OffsetTable.Add(offsetA, -normal * moveDist); result.MinOffset = Vector3I.Min(result.MinOffset, offset); result.MaxOffset = Vector3I.Max(result.MaxOffset, offset); } } } return(result); }