protected void RotateModel(IPlayer byPlayer, bool clockwise) { List <uint> rotatedCuboids = new List <uint>(); CuboidWithMaterial cwm = tmpCuboid; foreach (var val in VoxelCuboids) { FromUint(val, cwm); Cuboidi rotated = cwm.RotatedCopy(0, clockwise ? 90 : -90, 0, new Vec3d(8, 8, 8)); cwm.Set(rotated.X1, rotated.Y1, rotated.Z1, rotated.X2, rotated.Y2, rotated.Z2); rotatedCuboids.Add(ToCuboid(cwm)); } VoxelCuboids = rotatedCuboids; rotatedCuboids = new List <uint>(); foreach (var val in SnowCuboids) { FromUint(val, cwm); Cuboidi rotated = cwm.RotatedCopy(0, clockwise ? 90 : -90, 0, new Vec3d(8, 8, 8)); cwm.Set(rotated.X1, rotated.Y1, rotated.Z1, rotated.X2, rotated.Y2, rotated.Z2); rotatedCuboids.Add(ToCuboid(cwm)); } SnowCuboids = rotatedCuboids; }
private void RotateModel(IPlayer byPlayer, bool clockwise) { List <uint> rotatedCuboids = new List <uint>(); foreach (var val in this.VoxelCuboids) { FromUint(val, ref tmpCuboid); Cuboidi rotated = tmpCuboid.RotatedCopy(0, clockwise ? 90 : -90, 0, new Vec3d(8, 8, 8)); tmpCuboid.Set(rotated.X1, rotated.Y1, rotated.Z1, rotated.X2, rotated.Y2, rotated.Z2); rotatedCuboids.Add(ToCuboid(tmpCuboid)); } VoxelCuboids = rotatedCuboids; }
public void OnTransformed(ITreeAttribute tree, int byDegrees, EnumAxis?aroundAxis) { List <uint> rotatedCuboids = new List <uint>(); VoxelCuboids = new List <uint>((tree["cuboids"] as IntArrayAttribute).AsUint); CuboidWithMaterial cwm = tmpCuboid; foreach (var val in VoxelCuboids) { FromUint(val, cwm); Cuboidi rotated = cwm.Clone(); if (aroundAxis == EnumAxis.X) { rotated.X1 = 16 - rotated.X1; rotated.X2 = 16 - rotated.X2; } if (aroundAxis == EnumAxis.Y) { rotated.Y1 = 16 - rotated.Y1; rotated.Y2 = 16 - rotated.Y2; } if (aroundAxis == EnumAxis.Z) { rotated.Z1 = 16 - rotated.Z1; rotated.Z2 = 16 - rotated.Z2; } rotated = rotated.RotatedCopy(0, byDegrees, 0, new Vec3d(8, 8, 8)); cwm.Set(rotated.X1, rotated.Y1, rotated.Z1, rotated.X2, rotated.Y2, rotated.Z2); rotatedCuboids.Add(ToCuboid(cwm)); } tree["cuboids"] = new IntArrayAttribute(rotatedCuboids.ToArray()); }