/// <summary> /// Block constructor /// </summary> /// <param name="BlockNo">Block number (0 to 26)</param> public Block3D ( int BlockNo ) { // for the hidden center block there is no more initialization if (BlockNo == 13) { return; } // block origin OrigX = -Cube3D.HalfCubeWidth + (BlockNo % 3) * (Cube3D.BlockWidth + Cube3D.BlockSpacing); OrigY = -Cube3D.HalfCubeWidth + ((BlockNo / 3) % 3) * (Cube3D.BlockWidth + Cube3D.BlockSpacing); OrigZ = -Cube3D.HalfCubeWidth + (BlockNo / 9) * (Cube3D.BlockWidth + Cube3D.BlockSpacing); // array of the 6 faces of this block BlockFaceArray = new BlockFace3D[6]; // loop for all 6 faces for (int FaceColor = 0; FaceColor < Cube.FaceColors; FaceColor++) { // create 6 faces for each block // translate block number and face to face number BlockFaceArray[FaceColor] = new BlockFace3D(this, Cube.BlockFace[BlockNo, FaceColor], FaceColor); } return; }
/// <summary> /// Constructor /// </summary> /// <param name="BlockFace">Block face</param> /// <param name="GeometryModel">Geometry model</param> public ModelVisual3DCube ( BlockFace3D BlockFace, GeometryModel3D GeometryModel ) { this.BlockFace = BlockFace; Content = GeometryModel; return; }
/// <summary> /// Hit test call back method /// </summary> /// <param name="Result"></param> /// <returns></returns> private HitTestResultBehavior ResultCallBack(HitTestResult Result) { // test for hit on movable face if (Result.VisualHit.GetType() == typeof(ModelVisual3DCube)) { ModelVisual3DCube Model = (ModelVisual3DCube)Result.VisualHit; BlockFace3D Hit = Model.BlockFace; if (Hit.FaceNo >= 0) { // save the hit and stop further action HitList.Add(Hit); return(HitTestResultBehavior.Stop); } } // keep looking for movable face return(HitTestResultBehavior.Continue); }