Ejemplo n.º 1
0
        /// <summary>
        /// Compares the current instance to a specified object.
        /// </summary>
        /// <param name="obj">
        /// Object with which to make the comparison.
        /// </param>
        /// <returns>
        /// Returns a value that indicates whether the current instance is equal to a specified object.
        /// </returns>
        public override bool Equals(object obj)
        {
            PositionTexture equal = (PositionTexture)obj;

            return(this.Tu == equal.Tu && this.Tv == equal.Tv && this.X == equal.X && this.Y == equal.Y && this.Z == equal.Z);
        }
Ejemplo n.º 2
0
        private void InitGrid()
        {
            Collection<PositionTexture> vertexList = null;
            Collection<Triangle> triangleList = null;
            vertexList = new Collection<PositionTexture>();
            triangleList = new Collection<Triangle>();

            vertexList.Add(new PositionTexture(this.bounds[0, 0], 0, 0));
            vertexList.Add(new PositionTexture(this.bounds[1, 0], .5f, 0));
            vertexList.Add(new PositionTexture(this.bounds[2, 0], 1, 0));
            vertexList.Add(new PositionTexture(this.bounds[0, 1], 0, .5f));
            vertexList.Add(new PositionTexture(this.bounds[1, 1], .5f, .5f));
            vertexList.Add(new PositionTexture(this.bounds[2, 1], 1, .5f));
            vertexList.Add(new PositionTexture(this.bounds[0, 2], 0, 1));
            vertexList.Add(new PositionTexture(this.bounds[1, 2], .5f, 1));
            vertexList.Add(new PositionTexture(this.bounds[2, 2], 1, 1));

            if (this.Level == 0)
            {
                triangleList.Add(new Triangle(3, 7, 4));
                triangleList.Add(new Triangle(3, 6, 7));
                triangleList.Add(new Triangle(7, 5, 4));
                triangleList.Add(new Triangle(7, 8, 5));
                triangleList.Add(new Triangle(5, 1, 4));
                triangleList.Add(new Triangle(5, 2, 1));
                triangleList.Add(new Triangle(1, 3, 4));
                triangleList.Add(new Triangle(1, 0, 3));
            }
            else
            {
                if (this.backslash)
                {
                    triangleList.Add(new Triangle(4, 0, 3));
                    triangleList.Add(new Triangle(4, 1, 0));
                    triangleList.Add(new Triangle(5, 1, 4));
                    triangleList.Add(new Triangle(5, 2, 1));
                    triangleList.Add(new Triangle(3, 7, 4));
                    triangleList.Add(new Triangle(3, 6, 7));
                    triangleList.Add(new Triangle(8, 4, 7));
                    triangleList.Add(new Triangle(8, 5, 4));
                }
                else
                {
                    triangleList.Add(new Triangle(1, 0, 3));
                    triangleList.Add(new Triangle(1, 3, 4));
                    triangleList.Add(new Triangle(2, 1, 4));
                    triangleList.Add(new Triangle(2, 4, 5));
                    triangleList.Add(new Triangle(6, 4, 3));
                    triangleList.Add(new Triangle(6, 7, 4));
                    triangleList.Add(new Triangle(7, 5, 4));
                    triangleList.Add(new Triangle(8, 5, 7));
                }
            }

            int count = this.subDivisions;
            this.subDivSize = 1.0f / (float)Math.Pow(2, this.subDivisions);
            while (count-- > 1)
            {
                Collection<Triangle> newList = new Collection<Triangle>();
                foreach (Triangle tri in triangleList)
                {
                    tri.SubDivide(newList, vertexList);
                }

                triangleList = newList;
            }

            int countX = 1 + (int)Math.Pow(2, this.subDivisions);
            int countY = 1 + (int)Math.Pow(2, this.subDivisions);

            PositionTexture[,] points = new PositionTexture[countX, countY];
            this.mapRaDec = new Vector2d[countX, countY];
            foreach (PositionTexture vertex in vertexList)
            {
                int indexX = (int)((vertex.Tu / this.subDivSize) + .1);
                int indexY = (int)((vertex.Tv / this.subDivSize) + .1);

                points[indexX, indexY] = vertex;
            }

            for (int y = 0; y < countY; y++)
            {
                for (int x = 0; x < countX; x++)
                {
                    this.mapRaDec[x, y] = points[x, y].Position.ToRaDec();
                }
            }

            if (this.Level == 0)
            {
                this.minimumRa = 0;
                this.maximumRa = 360;
                this.decMin = -90;
                this.decMax = 90;
            }
            else
            {
                this.minimumRa = Math.Min(Math.Min(this.mapRaDec[0, 0].X, this.mapRaDec[0, countY - 1].X), Math.Min(this.mapRaDec[countX - 1, 0].X, this.mapRaDec[countX - 1, countY - 1].X));
                this.maximumRa = Math.Max(Math.Max(this.mapRaDec[0, 0].X, this.mapRaDec[0, countY - 1].X), Math.Max(this.mapRaDec[countX - 1, 0].X, this.mapRaDec[countX - 1, countY - 1].X));
                this.decMin = Math.Min(Math.Min(this.mapRaDec[0, 0].Y, this.mapRaDec[0, countY - 1].Y), Math.Min(this.mapRaDec[countX - 1, 0].Y, this.mapRaDec[countX - 1, countY - 1].Y));
                this.decMax = Math.Max(Math.Max(this.mapRaDec[0, 0].Y, this.mapRaDec[0, countY - 1].Y), Math.Max(this.mapRaDec[countX - 1, 0].Y, this.mapRaDec[countX - 1, countY - 1].Y));
            }
        }
Ejemplo n.º 3
0
        private void InitGrid()
        {
            Collection <PositionTexture> vertexList   = null;
            Collection <Triangle>        triangleList = null;

            vertexList   = new Collection <PositionTexture>();
            triangleList = new Collection <Triangle>();

            vertexList.Add(new PositionTexture(this.bounds[0, 0], 0, 0));
            vertexList.Add(new PositionTexture(this.bounds[1, 0], .5f, 0));
            vertexList.Add(new PositionTexture(this.bounds[2, 0], 1, 0));
            vertexList.Add(new PositionTexture(this.bounds[0, 1], 0, .5f));
            vertexList.Add(new PositionTexture(this.bounds[1, 1], .5f, .5f));
            vertexList.Add(new PositionTexture(this.bounds[2, 1], 1, .5f));
            vertexList.Add(new PositionTexture(this.bounds[0, 2], 0, 1));
            vertexList.Add(new PositionTexture(this.bounds[1, 2], .5f, 1));
            vertexList.Add(new PositionTexture(this.bounds[2, 2], 1, 1));

            if (this.Level == 0)
            {
                triangleList.Add(new Triangle(3, 7, 4));
                triangleList.Add(new Triangle(3, 6, 7));
                triangleList.Add(new Triangle(7, 5, 4));
                triangleList.Add(new Triangle(7, 8, 5));
                triangleList.Add(new Triangle(5, 1, 4));
                triangleList.Add(new Triangle(5, 2, 1));
                triangleList.Add(new Triangle(1, 3, 4));
                triangleList.Add(new Triangle(1, 0, 3));
            }
            else
            {
                if (this.backslash)
                {
                    triangleList.Add(new Triangle(4, 0, 3));
                    triangleList.Add(new Triangle(4, 1, 0));
                    triangleList.Add(new Triangle(5, 1, 4));
                    triangleList.Add(new Triangle(5, 2, 1));
                    triangleList.Add(new Triangle(3, 7, 4));
                    triangleList.Add(new Triangle(3, 6, 7));
                    triangleList.Add(new Triangle(8, 4, 7));
                    triangleList.Add(new Triangle(8, 5, 4));
                }
                else
                {
                    triangleList.Add(new Triangle(1, 0, 3));
                    triangleList.Add(new Triangle(1, 3, 4));
                    triangleList.Add(new Triangle(2, 1, 4));
                    triangleList.Add(new Triangle(2, 4, 5));
                    triangleList.Add(new Triangle(6, 4, 3));
                    triangleList.Add(new Triangle(6, 7, 4));
                    triangleList.Add(new Triangle(7, 5, 4));
                    triangleList.Add(new Triangle(8, 5, 7));
                }
            }

            int count = this.subDivisions;

            this.subDivSize = 1.0f / (float)Math.Pow(2, this.subDivisions);
            while (count-- > 1)
            {
                Collection <Triangle> newList = new Collection <Triangle>();
                foreach (Triangle tri in triangleList)
                {
                    tri.SubDivide(newList, vertexList);
                }

                triangleList = newList;
            }

            int countX = 1 + (int)Math.Pow(2, this.subDivisions);
            int countY = 1 + (int)Math.Pow(2, this.subDivisions);

            PositionTexture[,] points = new PositionTexture[countX, countY];
            this.mapRaDec             = new Vector2d[countX, countY];
            foreach (PositionTexture vertex in vertexList)
            {
                int indexX = (int)((vertex.Tu / this.subDivSize) + .1);
                int indexY = (int)((vertex.Tv / this.subDivSize) + .1);

                points[indexX, indexY] = vertex;
            }

            for (int y = 0; y < countY; y++)
            {
                for (int x = 0; x < countX; x++)
                {
                    this.mapRaDec[x, y] = points[x, y].Position.ToRaDec();
                }
            }

            if (this.Level == 0)
            {
                this.minimumRa = 0;
                this.maximumRa = 360;
                this.decMin    = -90;
                this.decMax    = 90;
            }
            else
            {
                this.minimumRa = Math.Min(Math.Min(this.mapRaDec[0, 0].X, this.mapRaDec[0, countY - 1].X), Math.Min(this.mapRaDec[countX - 1, 0].X, this.mapRaDec[countX - 1, countY - 1].X));
                this.maximumRa = Math.Max(Math.Max(this.mapRaDec[0, 0].X, this.mapRaDec[0, countY - 1].X), Math.Max(this.mapRaDec[countX - 1, 0].X, this.mapRaDec[countX - 1, countY - 1].X));
                this.decMin    = Math.Min(Math.Min(this.mapRaDec[0, 0].Y, this.mapRaDec[0, countY - 1].Y), Math.Min(this.mapRaDec[countX - 1, 0].Y, this.mapRaDec[countX - 1, countY - 1].Y));
                this.decMax    = Math.Max(Math.Max(this.mapRaDec[0, 0].Y, this.mapRaDec[0, countY - 1].Y), Math.Max(this.mapRaDec[countX - 1, 0].Y, this.mapRaDec[countX - 1, countY - 1].Y));
            }
        }