Exemple #1
0
        private void SetUpVerticesCylinder()
        {
            //double dx = PatchWidth / HorizontalPatches;
            //double dy = PatchHeight / VerticalPatches;
            //double alpha = (Math.PI * 2.0f) / (3 * HorizontalPatches + 1);
            //if (Vertices.Any())
            //{
            //    Vertices.Clear();
            //}
            //for (int i = 0; i < (3 * VerticalPatches + 1); i++)
            //{
            //    for (int j = 0; j < (3 * HorizontalPatches + 1); j++)
            //    {
            //        //patchwidth is radius when cylinder is set
            //        var point = new Point(PatchWidth * Math.Cos(alpha * j), StartPoint.Y + (i * dy), PatchWidth * Math.Sin(alpha * j));
            //        Vertices.Add(point);
            //    }
            //}



            double alpha = (Math.PI * 2.0f) / (3 * HorizontalPatches);
            double dx    = PatchWidth / (3 * HorizontalPatches);

            double dy = PatchHeight / (3 * VerticalPatches);



            var temp = new Point[4, 4];


            for (int i = 0; i < VerticalPatches; i++)
            {     //i pionowe płatki :
                for (int j = 0; j < HorizontalPatches; j++)
                { //j iteracja pozioma, poziome płatki ..
                    temp = new Point[4, 4];



                    for (int k = 0; k < 4; k++)
                    {
                        for (int l = 0; l < 4; l++)
                        {
                            //Wstawianie tych samych punktów na łączeniach
                            if ((i != 0) && (k == 0))
                            {
                                temp[k, l] = Surface[j, i - 1].PatchPoints[3, l];
                            }

                            else if ((j != 0) && (l == 0))
                            {
                                temp[k, l] = Surface[j - 1, i].PatchPoints[k, 3];
                            }
                            else
                            {
                                temp[k, l] = new Point(StartPoint.X + PatchWidth * Math.Cos(alpha * (3 * j + l)), StartPoint.Y + (k + i * 3) * dy, StartPoint.Z + PatchWidth * Math.Sin(alpha * (3 * j + l)));
                                // temp[k, l] = new Point(LocalStartPoint.X + l * dx, LocalStartPoint.Y + k * dy, LocalStartPoint.Z);
                            }


                            if ((j == (HorizontalPatches - 1)) && (l == 3) && (HorizontalPatches > 1))
                            {
                                temp[k, l] = Surface[0, i].PatchPoints[k, 0];
                            }
                            if ((j == (HorizontalPatches - 1)) && (l == 3) && (HorizontalPatches == 1))
                            {
                                temp[k, l] = temp[k, 0];
                            }
                        }
                    }

                    Surface[j, i] = new Patch(temp, _patchVerticalDivision, _patchHorizontalDivision);
                }
            }
        }
Exemple #2
0
        public void PlaceVerticesToPatches4x4()
        {//TODO: ujednolic placeverticestoPatches i placepoints-> tu jest połączone wersja teraz
            if (PatchesAreCylinder)
            {
                var PointsArray = PatchPoints;
                Point[,] temp;
                for (int i = 0; i < VerticalPatches; i++)
                {     //i pionowe płatki :
                    for (int j = 0; j < HorizontalPatches; j++)
                    { //j iteracja pozioma, poziome płatki ..
                        temp = new Point[4, 4];



                        for (int k = 0; k < 4; k++)
                        {
                            for (int l = 0; l < 4; l++)
                            {
                                //Wstawianie tych samych punktów na łączeniach
                                if ((i != 0) && (k == 0))
                                {
                                    temp[k, l] = Surface[j, i - 1].PatchPoints[3, l];
                                }

                                else if ((j != 0) && (l == 0))
                                {
                                    temp[k, l] = Surface[j - 1, i].PatchPoints[k, 3];
                                }
                                else
                                {
                                    temp[k, l] = PointsArray[3 * i + k, 3 * j + l];
                                    // temp[k, l] = new Point(LocalStartPoint.X + l * dx, LocalStartPoint.Y + k * dy, LocalStartPoint.Z);
                                }


                                //Sklejanie końców
                                if ((j == (HorizontalPatches - 1)) && (l == 3) && (HorizontalPatches > 1))
                                {
                                    temp[k, l] = Surface[0, i].PatchPoints[k, 0];
                                }
                                if ((j == (HorizontalPatches - 1)) && (l == 3) && (HorizontalPatches == 1))
                                {
                                    temp[k, l] = temp[k, 0];
                                }
                            }
                        }

                        Surface[j, i] = new Patch(temp, _patchVerticalDivision, _patchHorizontalDivision);
                    }
                }
            }
            else
            {
                var temp = new Point[4, 4];
                int k    = 0;
                int h    = 0;
                for (int PatchesI = 0; PatchesI < VerticalPatches; PatchesI++)
                {
                    h = 0;
                    for (int PatchesJ = 0; PatchesJ < HorizontalPatches; PatchesJ++)
                    {
                        temp = new Point[4, 4];
                        for (int i = 0; i < 4; i++)
                        {
                            for (int j = 0; j < 4; j++)
                            {
                                if ((PatchesI != 0) && (i == 0))
                                {
                                    temp[i, j] = PatchPoints[i + 4 * PatchesI - k, j + 4 * PatchesJ - h];
                                }

                                else if ((PatchesJ != 0) && (j == 0))
                                {
                                    temp[i, j] = PatchPoints[i + 4 * PatchesI - k, j + 4 * PatchesJ - h];
                                }
                                else
                                {
                                    temp[i, j] = PatchPoints[i + 4 * PatchesI - k, j + 4 * PatchesJ - h];
                                }
                            }
                        }
                        h++;

                        Surface[PatchesJ, PatchesI] = new Patch(temp, _patchVerticalDivision, _patchHorizontalDivision);
                    }
                    k++;
                }
            }
        }