Example #1
0
        public Vertex Clone()
        {
            Vertex v = new Vertex();

            v.Position = this.Position;
            v.Normal = this.Normal;
            v.UV = this.UV;
            v.Colour = this.Colour;

            return v;
        }
Example #2
0
 public int AddVertex(Vertex v)
 {
     data.Add(v);
     return data.Count - 1;
 }
Example #3
0
        public void AddFace(Vector3[] positions, Vector3[] normals, Vector2[] texcoords)
        {
            for (int i = 0; i < 3; i++)
            {
                var v = new Vertex();
                v.Position = positions[i];
                v.Normal = normals[i];
                v.UV = new Vector4(texcoords[i].X, texcoords[i].Y, 0, 1);

                int index = vertexBuffer.Data.FindIndex(vert =>
                    vert.Position.X.GetHashCode() == v.Position.X.GetHashCode() &&
                    vert.Position.Y.GetHashCode() == v.Position.Y.GetHashCode() &&
                    vert.Position.Z.GetHashCode() == v.Position.Z.GetHashCode() &&
                    vert.Normal.X.GetHashCode() == v.Normal.X.GetHashCode() &&
                    vert.Normal.Y.GetHashCode() == v.Normal.Y.GetHashCode() &&
                    vert.Normal.Z.GetHashCode() == v.Normal.Z.GetHashCode() &&
                    vert.UV.X.GetHashCode() == v.UV.X.GetHashCode() &&
                    vert.UV.Y.GetHashCode() == v.UV.Y.GetHashCode() &&
                    vert.UV.Z.GetHashCode() == v.UV.Z.GetHashCode() &&
                    vert.UV.W.GetHashCode() == v.UV.W.GetHashCode() &&
                    vert.Colour == v.Colour
                );

                if (index == -1) { index = vertexBuffer.AddVertex(v); }

                indexBuffer.AddIndex(index);
            }
        }
Example #4
0
        public int AddVertex(Vector3 position, Vector3 normal, Vector4 texcoords, OpenTK.Graphics.Color4 colour, bool bAddIndex = true)
        {
            var v = new Vertex {
                Position = position,
                Normal = normal,
                UV = texcoords,
                Colour = colour
            };

            int index = vertexBuffer.AddVertex(v);
            if (bAddIndex) { indexBuffer.AddIndex(index); }

            return index;
        }