Beispiel #1
0
        public static Mesh MakeWallQuad()
        {
            Vector3 v1 = new Vector3(-0.5f, 0.5f, 0);
            Vector3 v2 = new Vector3(-0.5f, -0.5f, 0);
            Vector3 v3 = new Vector3(0.5f, 0.5f, 0);
            Vector3 v4 = new Vector3(0.5f, -0.5f, 0);

            float[] vertices =
            {
                v1.X, v1.Y, v1.Z,
                v2.X, v2.Y, v2.Z,
                v3.X, v3.Y, v3.Z,
                v4.X, v4.Y, v4.Z
            };

            Vector3 n = Vector3.Cross((v2 - v1), (v3 - v1)).Normalized();

            float[] normals =
            {
                n.X, n.Y, n.Z,
                n.X, n.Y, n.Z,
                n.X, n.Y, n.Z,
                n.X, n.Y, n.Z
            };

            float[] uvs =
            {
                0, 1,
                0, 0,
                1, 1,
                1, 0
            };

            Mesh.VertexData vertexData = new Mesh.VertexData();
            vertexData.Vertices = new List <float>(vertices);
            vertexData.Uvs      = new List <float>(uvs);
            vertexData.Normals  = new List <float>(normals);

            Mesh quad = new Mesh(vertexData, OpenTK.Graphics.OpenGL.PrimitiveType.TriangleStrip);

            return(quad);
        }
Beispiel #2
0
        public static Mesh MakeQuadLineStrip()
        {
            Vector3 v1 = new Vector3(-0.5f, 0.5f, 0);
            Vector3 v2 = new Vector3(-0.5f, -0.5f, 0);
            Vector3 v3 = new Vector3(0.5f, 0.5f, 0);
            Vector3 v4 = new Vector3(0.5f, -0.5f, 0);

            float[] vertices =
            {
                v1.X, v1.Y, v1.Z,
                v2.X, v2.Y, v2.Z,
                v4.X, v4.Y, v4.Z,
                v3.X, v3.Y, v3.Z,
                v1.X, v1.Y, v1.Z
            };

            Mesh.VertexData vertexData = new Mesh.VertexData();
            vertexData.Vertices = new List <float>(vertices);

            Mesh quad = new Mesh(vertexData, OpenTK.Graphics.OpenGL.PrimitiveType.LineStrip);

            return(quad);
        }