示例#1
0
        public TriangleMesh(Point position, int width, int height, int pointsHeight, int pointsWidth)
        {
            cols = pointsWidth;
            rows = pointsHeight;
            mesh = new ReferencePoint[rows, cols];

            int dx = width / (cols - 1);
            int dy = height / (rows - 1);

            for (int row = 0; row < rows; ++row)
            {
                for (int col = 0; col < cols; ++col)
                {
                    mesh[row, col] = new ReferencePoint(position.X + col * dx, position.Y + row * dy);
                }
            }

            List <Triangle> ts = new List <Triangle>();

            for (int row = 0; row < rows - 1; ++row)
            {
                for (int col = 0; col < cols - 1; ++col)
                {
                    ts.Add(new Triangle(mesh[row, col], mesh[row + 1, col], mesh[row, col + 1]));
                    ts.Add(new Triangle(mesh[row + 1, col + 1], mesh[row, col + 1], mesh[row + 1, col]));
                }
            }

            triangles = ts.ToArray();
            BitmapOperator.Instance.RegisterTriangleMesh(this);
        }
示例#2
0
        public bool Collides(Point p, out ReferencePoint point)
        {
            for (int row = 0; row < rows; ++row)
            {
                for (int col = 0; col < cols; ++col)
                {
                    if (mesh[row, col].Collide(p))
                    {
                        point = mesh[row, col];
                        return(true);
                    }
                }
            }

            point = null;
            return(false);
        }
示例#3
0
 public Triangle(ReferencePoint p1, ReferencePoint p2, ReferencePoint p3)
 {
     points[0] = p1;
     points[1] = p2;
     points[2] = p3;
 }