private Vertex[] CreateSquare(Vector3 topLeftCorner, Vector3 topRightCorner, Vector3 bottomLeftCorner, Vector3 bottomRightCorner)
 {
     Vertex topLeft = new Vertex(topLeftCorner);
     Vertex topRight = new Vertex(topRightCorner);
     Vertex bottomLeft = new Vertex(bottomLeftCorner);
     Vertex bottomRight = new Vertex(bottomRightCorner);
     List<Vertex> square = new List<Vertex>(6);
     Vertex[] sq1 = new Vertex[] { topLeft, topRight, bottomLeft };
     Vertex[] sq2 = new Vertex[] { topRight, bottomRight, bottomLeft };
     square.AddRange(CreateTriangle(sq1));
     square.AddRange(CreateTriangle(sq2));
     return square.ToArray();
 }
Example #2
0
 protected virtual void Regenerate()
 {
     float t = 0.5f;
     float l = -0.5f;
     float b = -0.5f;
     float r = 0.5f;
     Vertex v0 = new Vertex(new Vector3(l, t, 0), new Vector3(0, 1, 0));
     v0.TextureCoordinates = new Vector2(1, 0);
     Vertex v1 = new Vertex(new Vector3(r, t, 0), new Vector3(0, 1, 0));
     v1.TextureCoordinates = new Vector2(0, 0);
     Vertex v2 = new Vertex(new Vector3(l, b, 0), new Vector3(0, 1, 0));
     v2.TextureCoordinates = new Vector2(1, 1);
     Vertex v3 = new Vertex(new Vector3(r, b, 0), new Vector3(0, 1, 0));
     v3.TextureCoordinates = new Vector2(0, 1);
     this.Vertices.AddRange(new Vertex[] { v2, v1, v0, v2, v3, v1 });
 }
Example #3
0
 public Square(RectangleF bounds)
     : base()
 {
     float t = bounds.Top;
     float l = bounds.Left;
     float b = bounds.Bottom;
     float r = bounds.Right;
     Vertex v0 = new Vertex(new Vector3(l, 0, t), new Vector3(0, 1, 0));
     v0.TextureCoordinates = new Vector2(1, 0);
     Vertex v1 = new Vertex(new Vector3(r, 0, t), new Vector3(0, 1, 0));
     v1.TextureCoordinates = new Vector2(0, 0);
     Vertex v2 = new Vertex(new Vector3(l, 0, b), new Vector3(0, 1, 0));
     v2.TextureCoordinates = new Vector2(1, 1);
     Vertex v3 = new Vertex(new Vector3(r, 0, b), new Vector3(0, 1, 0));
     v3.TextureCoordinates = new Vector2(0, 1);
     this.Vertices.AddRange(new Vertex[] { v2, v1, v0, v2, v3, v1 });
 }
Example #4
0
 public static Vertex[] TransformTriangle(Vertex[] v, Matrix m)
 {
     Vector3 v0 = Vector3.TransformCoordinate(v[0].Position, m);
     Vector3 v1 = Vector3.TransformCoordinate(v[1].Position, m);
     Vector3 v2 = Vector3.TransformCoordinate(v[2].Position, m);
     Vector3 norm = new Plane(v0, v1, v2).Normal;
     return new Vertex[] { new Vertex(v0, v[0].Color, norm), new Vertex(v1, v[1].Color, norm), new Vertex(v2, v[2].Color, norm) };
 }
Example #5
0
 public static Vertex TransformCoordinate(Vertex v, Matrix m)
 {
     Vector3 pos = Vector3.TransformCoordinate(v.Position, m);
     Vector3 norm = Vector3.TransformCoordinate(v.Normal, m);
     return new Vertex(pos, v.Color, norm);
 }
Example #6
0
 public static Vertex[] CreateTriangle(Vector3 corner0, Vector3 corner1, Vector3 corner2, Color color)
 {
     Vector3 norm = new Plane(corner0, corner1, corner2).Normal;
     Vertex[] ret = new Vertex[3];
     ret[0] = new Vertex(corner0, color, norm);
     ret[1] = new Vertex(corner1, color, norm);
     ret[2] = new Vertex(corner2, color, norm);
     return ret;
 }
        private Color4 GetColorFromVertex(Vertex vertex)
        {
            float rScale = 1.0f / (shapeWidth);
            float gScale = 1.0f / (shapeHeight);

            Color4 col = new Color4(1 - vertex.Position.X * rScale, vertex.Position.Z * gScale, 1.0f);
            return col;
        }
 private Vertex[] CreateTriangle(Vertex[] corners)
 {
     Vertex[] triangle = new Vertex[3];
     Vector3 norm = new Plane(corners[0].Position, corners[1].Position, corners[2].Position).Normal;
     for (int i = 0; i < 3; i++)
     {
         Color4 col = GetColorFromVertex(corners[i]);
         Vertex v = new Vertex(new Vector4(corners[i].Position, 1.0f), col, new Vector4(norm, 1.0f));
         triangle[i] = v;
     }
     return triangle;
 }
Example #9
0
 public Shape(Vertex[] vertices)
     : this()
 {
     Vertices = new VertexList(vertices);
 }
 private Color4 GetColorFromVertex(Vertex vertex)
 {
     float xScale = 1 / ((nColumnsToRead+1) * horizontalScale);
     float yScale = 1 / 1000.0f;
     float zScale = 1 / ((nRowsToRead+1) * horizontalScale);
     Color4 col = new Color4(1-vertex.Position.X * xScale, vertex.Position.Z * zScale, vertex.Position.Y*yScale);
     return col;
 }
 private Vertex[] CreateSquare(int topLeftHeight, int topRightHeight, int bottomLeftHeight, int bottomRightHeight)
 {
     float row = (float)(nRowsToRead - currentRow + 1);
     float col = (float)currentColumn;
     float[] z = new float[] { (row) * horizontalScale, (row+1) * horizontalScale };
     float[] x = new float[] { (col) * horizontalScale, (col+1) * horizontalScale };
     Vertex topLeft = new Vertex(x[0], (float)topLeftHeight*verticalScale, z[1]);
     Vertex topRight = new Vertex(x[1], (float)topRightHeight * verticalScale, z[1]);
     Vertex bottomLeft = new Vertex(x[0], (float)bottomLeftHeight * verticalScale, z[0]);
     Vertex bottomRight = new Vertex(x[1], (float)bottomRightHeight * verticalScale, z[0]);
     List<Vertex> square = new List<Vertex>(6);
     Vertex[] sq1 = new Vertex[] { topLeft, topRight, bottomLeft };
     Vertex[] sq2 = new Vertex[] { topRight, bottomRight, bottomLeft };
     square.AddRange(CreateTriangle(sq1));
     square.AddRange(CreateTriangle(sq2));
     return square.ToArray();
 }