public CubeSelection Select(Cubicle cubicle, Axis axis, out string basicOp) { CubeSelection cs = new CubeSelection(); basicOp = string.Empty; //if (cubicle.Name.Length > 1) {//not center piece, select cubies cs.SelectMode = SelectMode.Cubies; basicOp = CubeOperation.GetBasicOp(cubicle.Name, axis).Op; cs.SelectedCubies = CubeOperation.BasicOps[basicOp].CubicleGroup.Select(c => _cubicles[c].Cubie); } /* * else //center piece * { * cs.SelectMode = SelectMode.Cube; * } */ return(cs); }
private bool BeforeOp(AnimContext animContext) { string op = animContext.Op; if (op == CubeOperation.UndoOp) { //undo if (string.IsNullOrEmpty(_sequence)) { return(false); } op = CubeOperation.GetOp(ref _sequence, true, true); op = CubeOperation.GetReverseOp(op); if (!string.IsNullOrEmpty(op)) { animContext.Op = op; } } CubeSize size = CubeSize; double edgeX = CubieSize * size.Width / 2; double edgeY = CubieSize * size.Height / 2; double edgeZ = CubieSize * size.Depth / 2; if (op == CubeOperation.FoldOp || op == CubeOperation.UnFoldOp) { bool unfold = (op == CubeOperation.UnFoldOp); FaceTransform f = new FaceTransform("F", Axis.X, false, new Vector3D(0, edgeY, edgeZ), new Vector3D(), face => GetFaces(face)) { Silent = true, ChangeAngle = unfold ? -CubeOperation.PiOver2 : CubeOperation.PiOver2, Begin = 0, /* * Face = "F", * AxisTranslationFromOrigin = new Vector3D(0, edgeY, edgeZ), * Axis = Axis.X, * IsAxisMoving = false */ }; FaceTransform b = new FaceTransform("B", Axis.X, false, new Vector3D(0, edgeY, -edgeZ), new Vector3D(), face => GetFaces(face)) { Silent = true, ChangeAngle = unfold ? CubeOperation.PiOver2 : -CubeOperation.PiOver2, Begin = 0 /* * Face = "B", * AxisTranslationFromOrigin = new Vector3D(0, edgeY, -edgeZ), * Axis = Axis.X, * IsAxisMoving = false */ }; FaceTransform l = new FaceTransform("L", Axis.Z, false, new Vector3D(-edgeX, edgeY, 0), new Vector3D(), face => GetFaces(face)) { Silent = true, ChangeAngle = unfold ? -CubeOperation.PiOver2 : CubeOperation.PiOver2, Begin = 0, /* * Face = "L", * AxisTranslationFromOrigin = new Vector3D(-edgeX, edgeY, 0), * Axis = Axis.Z, * IsAxisMoving = false */ }; FaceTransform r = new FaceTransform("R", Axis.Z, false, new Vector3D(edgeX, edgeY, 0), new Vector3D(), face => GetFaces(face)) { Silent = true, ChangeAngle = unfold ? CubeOperation.PiOver2 : -CubeOperation.PiOver2, Begin = 0 /* * Face = "R", * AxisTranslationFromOrigin = new Vector3D(edgeX, edgeY, 0), * Axis = Axis.Z, * IsAxisMoving = false */ }; FaceTransform d; //if (unfold) { d = new FaceTransform("D", Axis.Z, true, new Vector3D(edgeX, -edgeY, 0), new Vector3D(edgeX, edgeY, 0), face => GetFaces(face)) { Silent = true, ChangeAngle = unfold ? CubeOperation.PiOver2 : -CubeOperation.PiOver2, Begin = 0 /* * Face = "D", * AxisTranslationFromOrigin = new Vector3D(edgeX, -edgeY, 0), * Axis2TranslationFromOrigin = new Vector3D(edgeX, edgeY, 0), * Axis = Axis.Z, * IsAxisMoving = true */ }; } animContext.TransformParams.Add(f); animContext.TransformParams.Add(b); animContext.TransformParams.Add(l); animContext.TransformParams.Add(r); animContext.TransformParams.Add(d); } else { if (!CubeOperation.IsValidOp(op)) { return(false); } BasicOp basicOp; bool isReverse; CubeOperation.GetBasicOp(op, out basicOp, out isReverse); CubieTransform transform = new CubieTransform(op, isReverse, basicOp, cn => Cubicles[cn]) { Silent = animContext.Silent }; transform.ChangeAngle = transform.RotateAngle - animContext.RotatedAngle; animContext.TransformParams.Add(transform); } return(true); }