Exemplo n.º 1
0
        static void FindAdjacentPatternTypes()
        {
            CubeModel cubeStartingPoint = Logic.Create(XyzCubeTypes.OrangeWhiteBlue);

            String sqlSelectCommand = "[RBK].[wsp_PatternsWithoutAdjacentRecognitionGet]";
            String sqlUpdateCommand = "[RBK].[wsp_PatternRecognitionAdjacentInsert]";
            Int32  pageSize         = 100000;

            IList <DatabasePatternModel> patterns = FindPatternsWithoutPatternTypes(sqlSelectCommand, pageSize);

            Console.WriteLine($@"Started  EXEC {sqlUpdateCommand}  Rows:{patterns.Count}");

            var patternTypes = new DataTable();

            patternTypes.Columns.Add("PatternId");
            patternTypes.Columns.Add("PatternTypeId");
            patternTypes.Columns.Add("Color");

            Int32 count = 0;

            foreach (DatabasePatternModel pattern in patterns)
            {
                Logic.SetCubeState(cubeStartingPoint, FromDatabase(pattern));

                (StickerColorTypes Color, PatternAdjacentTypes PatternAdjacentType)[] typesForpattern = PatternRecognition.GetCubeAdjacentPatterns(cubeStartingPoint);
        public void Initialize()
        {
            this._cubeModel = new CubeModel(2);
            this._converter = new Converter();

            this._cubeModel.Points.Add(new PointModel(2)
            {
                XY = 0,
                Z  = 0
            });

            this._cubeModel.Points.Add(new PointModel(2)
            {
                XY = 1,
                Z  = 0
            });

            this._cubeModel.Points.Add(new PointModel(2)
            {
                XY = 0,
                Z  = 1
            });

            this._cubeModel.Points.Add(new PointModel(2)
            {
                XY = 1,
                Z  = 1
            });
        }
Exemplo n.º 3
0
        public string Get(double radiusD,
                          double widthF,
                          double heightF,
                          double lengthF)
        {
            string result = $"calculate me {radiusD} {widthF} {heightF} {lengthF}";

            if (DoubleValueVerifier.IsDoubleArrayValid(
                    new double[] { radiusD, widthF, heightF, lengthF }))
            {
                CircleModel door   = new CircleModel(radiusD);
                CubeModel   fridge = new CubeModel(widthF, heightF, lengthF);

                result =
                    CalculatorMain.CubeToCircle(door, fridge)
                        ?
                    $"true, door: {door.ToString()}; fridge: {fridge.ToString()}"
                        :
                    $"false, door: {door.ToString()};fridge: {fridge.ToString()}";
            }
            else
            {
                result += "; Some bad value(s)!";
            }

            return(result);
        }
Exemplo n.º 4
0
        public void Shutdown()
        {
            // Release the light object.
            Light = null;
            // Release the camera object.
            Camera = null;

            // Release the shadow shader object.
            ShadowShader?.ShutDown();
            ShadowShader = null;
            // Release the depth shader object.
            DepthShader?.ShutDown();
            DepthShader = null;
            /// Release the render to texture object.
            RenderTexture?.Shutdown();
            RenderTexture = null;
            // Release the ground model object.
            GroundModel?.Shutdown();
            GroundModel = null;
            // Release the sphere model object.
            SphereModel?.Shutdown();
            SphereModel = null;
            // Release the cube model object.
            CubeModel?.Shutdown();
            CubeModel = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
Exemplo n.º 5
0
    public void SolveTopCross(CubeModel[,,] fullCubeModel)
    {
        //rotate the rest of the cross sides
        //find red, orange, green, blues sides
        //each piece can only be in one of 12 spots.
        //rotate red, orange, green, blue sides to top.

        // top layer                  middle layer            bottom layer
        CubeModel[] cubeArray = { fullCubeModel[1, 0, 0], fullCubeModel[0, 0, 1], fullCubeModel[1, 0, 2],
                                  fullCubeModel[0, 1, 0], fullCubeModel[2, 0, 1], fullCubeModel[0, 1, 2],
                                  fullCubeModel[1, 2, 0], fullCubeModel[0, 2, 1], fullCubeModel[1, 2, 2],
                                  fullCubeModel[2, 1, 0], fullCubeModel[2, 2, 1], fullCubeModel[2, 1, 2] };

        //red, orange, blue, green
        CubeModel[] sidesArray = new CubeModel[4];
        //for every cube we've pulled out of the rubiks cube, we go through them and get their color array for each
        //then we go through color array, and if one of those pieces has white (meaning a top piece)
        //we determine what is the other color is has.
        //then we set the sidesArray properly
        for (int i = 0; i < cubeArray.Length; i++)
        {
            Color[] temp = cubeArray[i].GetColorsArray();

            for (int j = 0; j < temp.Length; j++)
            {
                if (temp[j].Equals(Color.white))
                {
                    for (int k = 0; k < temp.Length; k++)
                    {
                        if (temp[k].Equals(Color.black) && temp[k].Equals(Color.white))
                        {
                            /*switch(temp[i])
                             * {
                             * case Color.red:
                             *      sidesArray[0] = cubeArray[i];
                             *      break;
                             * case Color.magenta:
                             *      sidesArray[1] = cubeArray[i];
                             *      break;
                             * case Color.blue:
                             *      sidesArray[2] = cubeArray[i];
                             *      break;
                             * case Color.green:
                             *      sidesArray[3] = cubeArray[i];
                             *      break;
                             * default:
                             *      break;
                             * }*/
                        }
                    }
                }
            }
        }

        fullCubeController.IncreaseStage();
        return;
    }
Exemplo n.º 6
0
    private void CreateTiles(CubeModel model)
    {
        int widthFace;
        int heightFace;

        for (int faceNumber = 0; faceNumber < 6; faceNumber++)
        {
            GameObject face = new GameObject(faceNumber + "");
            face.transform.SetParent(transform);
            face.transform.localRotation = GetFaceRotation((CubeFace)faceNumber);
            face.transform.localPosition = GetFacePosition((CubeFace)faceNumber);
            switch (faceNumber)
            {
            case (int)CubeFace.X:
            case (int)CubeFace.MX:
                widthFace  = model.Z_SIZE;
                heightFace = model.Y_SIZE;
                break;

            case (int)CubeFace.Y:
            case (int)CubeFace.MY:
                widthFace  = model.X_SIZE;
                heightFace = model.Z_SIZE;
                break;

            case (int)CubeFace.Z:
            case (int)CubeFace.MZ:
                widthFace  = model.X_SIZE;
                heightFace = model.Y_SIZE;
                break;

            default:
                throw new UnhandledSwitchCaseException(faceNumber);
            }
            exterior[faceNumber] = new TileController[widthFace, heightFace];
            for (int x = 0; x < widthFace; x++)
            {
                for (int y = 0; y < heightFace; y++)
                {
                    TileData       tileData = model.faces[faceNumber][x, y];
                    TileController tile     = TileCreator.CreateTile(tileData, GetTilePosition((CubeFace)faceNumber, x, y), SizeRatio);
                    tile.transform.SetParent(face.transform, false);
                    //
                    if (GameObjects.GetGameState().LevelEditor)
                    {
                        EditorTile editorTile = tile.Mesh.AddComponent <EditorTile>();
                        editorTile.Init((CubeFace)faceNumber, x, y);
                        editorTile.GridTileClickEvent += GameObjects.GetLevelCreatorController().OnTileClick;
                    }
                    model.objectivesFilled.TryFillTile(tile);
                    //
                    exterior[faceNumber][x, y] = tile;
                }
            }
        }
    }
Exemplo n.º 7
0
 public void RefreshView(CubeModel model)
 {
     if (currentView != null)
     {
         Destroy(currentView);
     }
     currentView = Instantiate(CubeViewPrefab);
     currentView.transform.SetParent(cubeView.transform, false);
     currentView.GetComponent <CubeView>().RefreshView(model);
 }
Exemplo n.º 8
0
 public static Cube Map(CubeModel model)
 {
     return(new Cube()
     {
         Dimension = model.Dimension,
         Id = model.Id,
         Operaciones = model.Operaciones,
         Queries = model.Queries.Select(q => QueryMapper.Map(q)).ToList()
     });
 }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            // ========================================================================
            //                                         Preprocessing.....
            // ========================================================================
            CubeModel Cube   = new CubeModel();
            Camera    Camera = new Camera(new Vector3(0, 10, 50),
                                          new Vector3(0, 0, 0),
                                          new Vector3(0, 1, 0));

            Matrix WorldMatrix = Matrix.IdentityMatrix(4, 4);

            float rotate = 0.0f;

            while (true)
            {
                // ========================================================================
                //                                         Vertex Processing.....
                // ========================================================================
                // Calculate the position for each vertex.
                // Considering the object matrix, world matrix, view matrix and projection matrix.
                // Rotation and Translation happen here.
                rotate += .06f;
                Cube.RotateYAxis(rotate);
                Cube.ApplyTransformation(WorldMatrix, Camera.ViewMatrix, Camera.PerspectiveProjectionMatrix);


                // ========================================================================
                //                                          Rasterize....
                // ========================================================================
                // Interpolate each vertices, get the line between every vertices pair.
                // Then calculate each pixel's value
                Frame newFrame = new Frame();
                Cube.Rasterize(newFrame);


                // ========================================================================
                //                                     Fragment Processing....
                // ========================================================================
                // Determine the color of each pixel in each fragment
                // Here we do not implement the stage of processing, because I still don't know how
                // to make a console app colorful.


                // ========================================================================
                //                                            Output....
                // ========================================================================
                // Show the 3D model in the screen
                Displayer Displayer = new Displayer();
                Displayer.DisplayFrame(newFrame);

                System.Threading.Thread.Sleep(80);
                System.Console.Clear();
            }
        }
        public static bool CubeToCircle(CircleModel door, CubeModel fridge)
        {
            bool result = false;

            if (fridge.Diagonal < door.Diameter)
            {
                result = true;
            }

            return(result);
        }
Exemplo n.º 11
0
        public string[] GetCubeFacePatterns(CubeModel cube)
        {
            String north = $"{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackNorthWest.StickerNorth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackNorth.StickerNorth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackNorthEast.StickerNorth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.NorthWest.StickerNorth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.North.StickerNorth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.NorthEast.StickerNorth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontNorthWest.StickerNorth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontNorth.StickerNorth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontNorthEast.StickerNorth.StickerColorType)}";
            String south = $"{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontSouthWest.StickerSouth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontSouth.StickerSouth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontSouthEast.StickerSouth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.SouthWest.StickerSouth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.South.StickerSouth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.SouthEast.StickerSouth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackSouthWest.StickerSouth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackSouth.StickerSouth.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackSouthEast.StickerSouth.StickerColorType)}";
            String front = $"{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontNorthWest.StickerFront.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontNorth.StickerFront.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontNorthEast.StickerFront.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontWest.StickerFront.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.Front.StickerFront.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontEast.StickerFront.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontSouthWest.StickerFront.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontSouth.StickerFront.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontSouthEast.StickerFront.StickerColorType)}";
            String back  = $"{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackNorthWest.StickerBack.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackNorth.StickerBack.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackNorthEast.StickerBack.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackWest.StickerBack.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.Back.StickerBack.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackEast.StickerBack.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackSouthWest.StickerBack.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackSouth.StickerBack.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackSouthEast.StickerBack.StickerColorType)}";
            String west  = $"{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackNorthWest.StickerWest.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.NorthWest.StickerWest.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontNorthWest.StickerWest.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackWest.StickerWest.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.West.StickerWest.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontWest.StickerWest.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackSouthWest.StickerWest.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.SouthWest.StickerWest.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontSouthWest.StickerWest.StickerColorType)}";
            String east  = $"{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontNorthEast.StickerEast.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.NorthEast.StickerEast.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackNorthEast.StickerEast.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontEast.StickerEast.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.East.StickerEast.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackEast.StickerEast.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.FrontSouthEast.StickerEast.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.SouthEast.StickerEast.StickerColorType)}{ GetStickerAbbreviation(GetXyzCubeType(cube), cube.BackSouthEast.StickerEast.StickerColorType)}";

            return(new String[] { east, north, front, west, south, back });
        }
Exemplo n.º 12
0
        static void DoStep(PatternHierarchyModel[] nextStepPrimaries)
        {
            var nextSteps = new List <NextStepInfo>();

            for (Int32 isd = 0; isd < nextStepPrimaries.Count(); isd++)
            {
                Console.WriteLine("\tStep {0} {1} of {2}", nextStepPrimaries[0].HerarchyLevel, isd + 1, nextStepPrimaries.Count());

                CubeModel cubeStartingPoint = Logic.Create(XyzCubeTypes.OrangeWhiteBlue);
                Logic.SetCubeState(cubeStartingPoint, nextStepPrimaries[isd].ConnectedPattern);
                String normalizedPattern = PatternLogic.GetCubePattern(cubeStartingPoint);

                Parallel.For(1, 28, (Int32 iMove) =>
                             // for (var iMove = 1; iMove < 28; iMove++)
                {
                    CubeModel cubeClone = Logic.CloneCube(cubeStartingPoint);
                    MoveTypes moveType  = (MoveTypes)iMove;
                    Logic.RunMove(cubeClone, moveType);

                    //Debug.Write("moveType:" + moveType);

                    String cubeCloneRaw         = PatternLogic.GetCubePattern(cubeClone);
                    String cubeClonedNormalized = PatternLogic.GetFirstPatternAlphabetically(cubeCloneRaw);

                    String relationship        = Logic.Convert(moveType);
                    String reverseRelationship = Logic.Convert(Logic.Reverse(moveType));

                    lock (nextSteps)
                    {
                        var nextStep = nextSteps.FirstOrDefault(x => x.PrimaryPatternId == nextStepPrimaries[isd].ConnectedPatternId && x.ConnectedPattern == cubeClonedNormalized);
                        if (nextStep == default)
                        {
                            SqlHierarchyId patternHierarchyHid = SqlHierarchyId.Parse($"{nextStepPrimaries[isd].PatternHierarchyHid}{iMove}/");
                            nextSteps.Add(new NextStepInfo(
                                              patternHierarchyHid,
                                              nextStepPrimaries[isd].ConnectedPatternId,
                                              '|' + relationship + '|',
                                              '|' + reverseRelationship + '|',
                                              cubeClonedNormalized));
                        }
                        else
                        {
                            nextStep.Relationship       += relationship + '|';
                            nextStep.ReverseRelationship = '|' + reverseRelationship + nextStep.ReverseRelationship;
                        }
                    }
                    //Console.WriteLine("\t\tMove {0}", iMove);
                }
                             );
            }

            SaveStep(nextSteps);
        }
Exemplo n.º 13
0
    public void SwipeLeftTest()
    {
        var cube = new CubeModel();

        Assert.IsTrue(cube.Front == Colour.Red);

        cube.Update(MoveInput.SwipeLeft);

        Assert.IsTrue(cube.Front == Colour.Yellow &&
                      cube.Back == Colour.Green &&
                      cube.Right == Colour.Red &&
                      cube.Left == Colour.Red);
    }
Exemplo n.º 14
0
    public void ComplicatedRotationTest()
    {
        var cube = new CubeModel(front: Colour.Red, back: Colour.Green, left: Colour.Yellow, right: Colour.Blue, top: Colour.White, bottom: Colour.Orange);

        var correct = IsShowing(cube, Colour.Red);

        cube.Update(MoveInput.SwipeRight);      correct &= IsShowing(cube, Colour.Yellow);
        cube.Update(MoveInput.SwipeDown);       correct &= IsShowing(cube, Colour.White);
        cube.Update(MoveInput.SwipeLeft);       correct &= IsShowing(cube, Colour.Red);
        cube.Update(MoveInput.SwipeUp);         correct &= IsShowing(cube, Colour.Yellow);

        Assert.IsTrue(correct);
    }
Exemplo n.º 15
0
        public string ConvertToTxt(CubeModel cube, string mode)
        {
            var strBuild = (new StringBuilder(mode)).AppendLine();

            for (var i = 0; i < cube.CubeSize; ++i)
            {
                var layer = cube.Points.Where(item => item.Z == i).Select(item => item.ToString());

                strBuild.AppendLine(this.IEnumToString(layer));
            }

            return(strBuild.ToString());
        }
Exemplo n.º 16
0
    public void SwipeDownTest()
    {
        var cube = new CubeModel();

        Assert.IsTrue(cube.Front == Colour.Red);

        cube.Update(MoveInput.SwipeDown);

        Assert.IsTrue(cube.Front == Colour.Blue &&
                      cube.Back == Colour.White &&
                      cube.Top == Colour.Red &&
                      cube.Bottom == Colour.Red);
    }
Exemplo n.º 17
0
    static public CubeModel Create(ModelInfo info)
    {
        if (info == null)
        {
            return(null);
        }

        GameObject go    = new GameObject("model" + info.ID);
        CubeModel  model = go.AddComponent <CubeModel>();

        model.Data = info;

        return(model);
    }
        public static bool CubeToSquare(SquareModel door, CubeModel fridge)
        {
            bool result = false;

            double[] sortedDoor   = door.SortedArr();
            double[] sortedFridge = fridge.SortedArr();

            if (sortedDoor[0] > sortedFridge [0] && sortedDoor[1] > sortedFridge[1])
            {
                result = true;
            }

            return(result);
        }
Exemplo n.º 19
0
        public ActionResult CreateCube(CreateCubeRequest req)
        {
            CreateCubeResponse response = new CreateCubeResponse();
            CubeModel          model    = new CubeModel()
            {
                name         = req.Name,
                IsActive     = true,
                CreatedDate  = DateTime.Now,
                ModifiedDate = DateTime.Now
            };
            var res = model.CreateCube(model, req.UserId, dbFactory);

            response.name      = req.Name;
            response.id        = res;
            response.userid    = req.UserId;
            response.IsSuccess = true;
            return(Json(response));
        }
Exemplo n.º 20
0
    private void CreateBalls(CubeModel data)
    {
        for (int x = 0; x < data.X_SIZE; x++)
        {
            for (int y = 0; y < data.Y_SIZE; y++)
            {
                for (int z = 0; z < data.Z_SIZE; z++)
                {
                    IBallController ball = BallCreator.GetBall(data.balls[x, y, z], SizeRatio, false);
                    ball.Init(x, y, z, this);



                    interior[x, y, z] = ball;
                }
            }
        }
    }
Exemplo n.º 21
0
        public String GetDetailedCubeState(CubeModel cube)
        {
            //  FNE, NE, BNE, FE, E, BE, FSE, SE, BSW
            //  BNW, BN, BNE, NW, N, NE, FNW, FN, FNE
            //  FNW, FN, FNE, FW, F, FE, FSW, FS, FSE
            //  BNW, NW, FNW, BW, W, FW, BSW, SW, FSW
            //  FSW, FS, FSE, SW, S, SE, BSW, BS, BSE
            //  BNW, BN, BNE, BW, B, BE, BSW, BS, BSE

            String east  = $"{PositionTypes.EFNE}:{ GetStickerAbbreviation(cube.FrontNorthEast.StickerEast) }|{PositionTypes.ENE}:{ GetStickerAbbreviation(cube.NorthEast.StickerEast)  }|{PositionTypes.EBNE}:{ GetStickerAbbreviation(cube.BackNorthEast.StickerEast)  }|{PositionTypes.EFE}:{ GetStickerAbbreviation(cube.FrontEast.StickerEast) }|{PositionTypes.EE}:{ GetStickerAbbreviation(cube.East.StickerEast)  }|{PositionTypes.EBE}:{ GetStickerAbbreviation(cube.BackEast.StickerEast)  }|{PositionTypes.EFSE}:{ GetStickerAbbreviation(cube.FrontSouthEast.StickerEast) }|{PositionTypes.ESE}:{ GetStickerAbbreviation(cube.SouthEast.StickerEast)  }|{PositionTypes.EBSE}:{ GetStickerAbbreviation(cube.BackSouthEast.StickerEast)}";
            String north = $"{PositionTypes.NBNW}:{ GetStickerAbbreviation(cube.BackNorthWest.StickerNorth) }|{PositionTypes.NBN}:{ GetStickerAbbreviation(cube.BackNorth.StickerNorth) }|{PositionTypes.NBNE}:{ GetStickerAbbreviation(cube.BackNorthEast.StickerNorth) }|{PositionTypes.NNW}:{ GetStickerAbbreviation(cube.NorthWest.StickerNorth)}|{PositionTypes.NN}:{ GetStickerAbbreviation(cube.North.StickerNorth)}|{PositionTypes.NNE}:{ GetStickerAbbreviation(cube.NorthEast.StickerNorth)}|{PositionTypes.NFNW}:{ GetStickerAbbreviation(cube.FrontNorthWest.StickerNorth)}|{PositionTypes.NFN}:{ GetStickerAbbreviation(cube.FrontNorth.StickerNorth)}|{PositionTypes.NFNE}:{ GetStickerAbbreviation(cube.FrontNorthEast.StickerNorth)}";
            String front = $"{PositionTypes.FFNW}:{ GetStickerAbbreviation(cube.FrontNorthWest.StickerFront)}|{PositionTypes.FFN}:{ GetStickerAbbreviation(cube.FrontNorth.StickerFront)}|{PositionTypes.FFNE}:{ GetStickerAbbreviation(cube.FrontNorthEast.StickerFront)}|{PositionTypes.FFW}:{ GetStickerAbbreviation(cube.FrontWest.StickerFront)}|{PositionTypes.FF}:{ GetStickerAbbreviation(cube.Front.StickerFront)}|{PositionTypes.FFE}:{ GetStickerAbbreviation(cube.FrontEast.StickerFront)}|{PositionTypes.FFSW}:{ GetStickerAbbreviation(cube.FrontSouthWest.StickerFront)}|{PositionTypes.FFS}:{ GetStickerAbbreviation(cube.FrontSouth.StickerFront)}|{PositionTypes.FFSE}:{ GetStickerAbbreviation(cube.FrontSouthEast.StickerFront)}";
            String west  = $"{PositionTypes.WBNW}:{ GetStickerAbbreviation(cube.BackNorthWest.StickerWest)  }|{PositionTypes.WNW}:{ GetStickerAbbreviation(cube.NorthWest.StickerWest)  }|{PositionTypes.WFNW}:{ GetStickerAbbreviation(cube.FrontNorthWest.StickerWest) }|{PositionTypes.WBW}:{ GetStickerAbbreviation(cube.BackWest.StickerWest)  }|{PositionTypes.WW}:{ GetStickerAbbreviation(cube.West.StickerWest)  }|{PositionTypes.WFW}:{ GetStickerAbbreviation(cube.FrontWest.StickerWest) }|{PositionTypes.WBSW}:{ GetStickerAbbreviation(cube.BackSouthWest.StickerWest)  }|{PositionTypes.WSW}:{ GetStickerAbbreviation(cube.SouthWest.StickerWest)  }|{PositionTypes.WFSW}:{ GetStickerAbbreviation(cube.FrontSouthWest.StickerWest)}";
            String south = $"{PositionTypes.SFSW}:{ GetStickerAbbreviation(cube.FrontSouthWest.StickerSouth)}|{PositionTypes.SFS}:{ GetStickerAbbreviation(cube.FrontSouth.StickerSouth)}|{PositionTypes.SFSE}:{ GetStickerAbbreviation(cube.FrontSouthEast.StickerSouth)}|{PositionTypes.SSW}:{ GetStickerAbbreviation(cube.SouthWest.StickerSouth)}|{PositionTypes.SS}:{ GetStickerAbbreviation(cube.South.StickerSouth)}|{PositionTypes.SSE}:{ GetStickerAbbreviation(cube.SouthEast.StickerSouth)}|{PositionTypes.SBSW}:{ GetStickerAbbreviation(cube.BackSouthWest.StickerSouth) }|{PositionTypes.SBS}:{ GetStickerAbbreviation(cube.BackSouth.StickerSouth) }|{PositionTypes.SBSE}:{ GetStickerAbbreviation(cube.BackSouthEast.StickerSouth)}";
            String back  = $"{PositionTypes.BBNE}:{ GetStickerAbbreviation(cube.BackNorthEast.StickerBack)  }|{PositionTypes.BBN}:{ GetStickerAbbreviation(cube.BackNorth.StickerBack)  }|{PositionTypes.BBNW}:{ GetStickerAbbreviation(cube.BackNorthWest.StickerBack)  }|{PositionTypes.BBE}:{ GetStickerAbbreviation(cube.BackEast.StickerBack)  }|{PositionTypes.BB}:{ GetStickerAbbreviation(cube.Back.StickerBack)  }|{PositionTypes.BBW}:{ GetStickerAbbreviation(cube.BackWest.StickerBack)  }|{PositionTypes.BBSE}:{ GetStickerAbbreviation(cube.BackSouthEast.StickerBack)  }|{PositionTypes.BBS}:{ GetStickerAbbreviation(cube.BackSouth.StickerBack)  }|{PositionTypes.BBSW}:{ GetStickerAbbreviation(cube.BackSouthWest.StickerBack)}";

            return($"{east},{north},{front},{west},{south},{back}");
        }
        private bool Render()
        {
            // Clear the buffers to begin the scene.
            D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Get the world, view, and projection matrices from the camera and d3d objects.
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix viewMatrix       = Camera.ViewMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Get the view and projection matrices from the view point object.
            Matrix viewMatrix2       = ViewPoint.ViewMatrix;
            Matrix projectionMatrix2 = ViewPoint.ProjectionMatrix;

            // Setup the translation for the ground model.
            Matrix.Translation(0.0f, 1.0f, 0.0f, out worldMatrix);

            // Render the ground model using the projection shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!ProjectionShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, GroundModel.Texture.TextureResource, Light.AmbientColor, Light.DiffuseColour, Light.Position, viewMatrix2, projectionMatrix2, ProjectionTexture.TextureResource))
            {
                return(false);
            }

            // Reset the world matrix and setup the translation for the cube model.
            worldMatrix = D3D.WorldMatrix;
            Matrix.Translation(0.0f, 2.0f, 0.0f, out worldMatrix);

            // Render the cube model using the projection shader.
            CubeModel.Render(D3D.DeviceContext);
            if (!ProjectionShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, CubeModel.Texture.TextureResource, Light.AmbientColor, Light.DiffuseColour, Light.Position, viewMatrix2, projectionMatrix2, ProjectionTexture.TextureResource))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
Exemplo n.º 23
0
    public void HLockedCubeRotationTest()
    {
        var cube = new CubeModel(front: Colour.Red, back: Colour.White, left: Colour.White,
                                 right: Colour.White, top: Colour.White, bottom: Colour.White);

        cube.Lock(MoveInput.SwipeLeft, MoveInput.SwipeRight);

        cube.Update(MoveInput.SwipeLeft);

        Assert.IsTrue(IsShowing(cube, Colour.Red));

        cube.Update(MoveInput.SwipeRight);

        Assert.IsTrue(IsShowing(cube, Colour.Red));

        cube.UnLock(MoveInput.SwipeLeft);
        cube.Update(MoveInput.SwipeLeft);

        Assert.IsTrue(IsShowing(cube, Colour.White));
    }
Exemplo n.º 24
0
    public static void Main(string[] args)
    {
        // Create shaders:
        Shader solidRed  = new UnlitColorShader("red");
        Shader solidBlue = new UnlitColorShader("blue");
        Shader glass     = new GlassShader();

        // Create the models:
        Model cube   = new CubeModel(solidRed);
        Model monkey = new Suzanne(glass);

        // Draw the two models:
        cube.Draw();   // "Rendering Cube with a red color."
        monkey.Draw(); // "Rendering Suzanne to look like glass."

        // Switch out the shader on suzanne:
        monkey.SetShader(solidBlue);

        monkey.Draw(); // "Rendering Suzanne with a blue color."
    }
Exemplo n.º 25
0
    public int[] GetCubeCoordinates(CubeModel tempCube)
    {
        int[] coords = new int[3];

        for (int x = 0; x < 3; x++)
        {
            for (int y = 0; y < 3; y++)
            {
                for (int z = 0; z < 3; z++)
                {
                    if (fullCube[x, y, z].Equals(tempCube))
                    {
                        coords[0] = x;
                        coords[1] = y;
                        coords[2] = z;
                    }
                }
            }
        }

        return(coords);
    }
Exemplo n.º 26
0
    private void StartEditor()
    {
        ModelInfo info = new ModelInfo();

        info.ID = 1;

        CubeModelData cube = new CubeModelData();

        cube.ID = 0;

        info.Cubes.Add(cube);

        CubeModel model = CubeModel.Create(info);

        if (model != null)
        {
            model.transform.parent = Container;
            model.Editable         = true;

            InputMgr.Instance.Status = GameStatus.Editor;
            InputMgr.Instance.Target = model;
        }
    }
Exemplo n.º 27
0
 private bool IsShowing(CubeModel cube, Colour colour)
 {
     return(cube.Front == colour);
 }
        private bool RenderSceneToTexture2()
        {
            // Set the render target to be the render to texture.
            RenderTexture2.SetRenderTarget(D3D.DeviceContext);

            // Clear the render to texture.
            RenderTexture2.ClearRenderTarget(D3D.DeviceContext, 0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the light view matrix based on the light's position.
            Light2.GenerateViewMatrix();

            // Get the world matrix from the d3d object.
            Matrix worldMareix = D3D.WorldMatrix;

            // Get the view and orthographic matrices from the light object.
            Matrix lightViewMatrix  = Light2.ViewMatrix;
            Matrix lightOrthoMatrix = Light2.ProjectionMatrix;

            // Setup the translation matrix for the cube model.
            Vector3 cubePosition = CubeModel.GetPosition();

            Matrix.Translation(cubePosition.X, cubePosition.Y, cubePosition.Z, out worldMareix);

            // Render the cube model with the depth shader.
            CubeModel.Render(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMareix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMareix = D3D.WorldMatrix;

            // Setup the translation matrix for the sphere model.
            Vector3 spherePosition = SphereModel.GetPosition();

            Matrix.Translation(spherePosition.X, spherePosition.Y, spherePosition.Z, out worldMareix);

            // Render the sphere model with the depth shader.
            SphereModel.Render(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, SphereModel.IndexCount, worldMareix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMareix = D3D.WorldMatrix;

            // Setup the translation matrix for the ground model.
            Vector3 groundPosition = GroundModel.GetPosition();

            Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMareix);

            // Render the ground model with the depth shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMareix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Reset the render target back to the original back buffer and not the render to texture anymore.
            D3D.SetBackBufferRenderTarget();

            // Reset the viewport back to the original.
            D3D.ResetViewPort();

            return(true);
        }
Exemplo n.º 29
0
 public CubeService(sbyte cubeSize, IConverter converter, IFileCreator fileCreator)
 {
     this._cubeModel   = new CubeModel(cubeSize);
     this._converter   = converter;
     this._fileCreator = fileCreator;
 }
        public bool Render()
        {
            // First render the scene to a texture.
            if (!RenderSceneToTexture())
            {
                return(false);
            }

            // Render the scene to texture again but use the second light's view point.
            if (!RenderSceneToTexture2())
            {
                return(false);
            }

            // Clear the buffers to begin the scene.
            D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Generate the light view matrix based on the light's position.
            Light.GenerateViewMatrix();

            // Do the same for the second light.
            Light2.GenerateViewMatrix();

            // Get the world, view, and projection matrices from the camera and d3d objects.
            Matrix viewMatrix       = Camera.ViewMatrix;
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Get the light's view and projection matrices from the light object.
            Matrix lightViewMatrix       = Light.ViewMatrix;
            Matrix lightProjectionMatrix = Light.ProjectionMatrix;

            // Do the same for the second light.
            Matrix lightViewMatrix2       = Light2.ViewMatrix;
            Matrix lightProjectionMatrix2 = Light2.ProjectionMatrix;

            // Setup the translation matrix for the cube model.
            Vector3 cubePosition = CubeModel.GetPosition();

            Matrix.Translation(cubePosition.X, cubePosition.Y, cubePosition.Z, out worldMatrix);

            // Put the cube model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            CubeModel.Render(D3D.DeviceContext);

            // Render the model using the shadow shader.
            if (!ShadowShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, CubeModel.Texture.TextureResource, RenderTexture.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour, lightViewMatrix2, lightProjectionMatrix2, RenderTexture2.ShaderResourceView, Light2.Position, Light2.DiffuseColour))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Setup the translation matrix for the sphere model.
            Vector3 spherePosition = SphereModel.GetPosition();

            Matrix.Translation(spherePosition.X, spherePosition.Y, spherePosition.Z, out worldMatrix);

            // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            SphereModel.Render(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, SphereModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, SphereModel.Texture.TextureResource, RenderTexture.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour, lightViewMatrix2, lightProjectionMatrix2, RenderTexture2.ShaderResourceView, Light2.Position, Light2.DiffuseColour))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Setup the translation matrix for the ground model.
            Vector3 groundPosition = GroundModel.GetPosition();

            Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMatrix);

            // Render the ground model using the shadow shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, GroundModel.Texture.TextureResource, RenderTexture.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour, lightViewMatrix2, lightProjectionMatrix2, RenderTexture2.ShaderResourceView, Light2.Position, Light2.DiffuseColour))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }