public void Save() { B = new VAO(Vertexes.Count); P = new Vector3[Vertexes.Count]; N = new Vector3[Vertexes.Count]; C = new Color4[Vertexes.Count]; T = new Vector2[Vertexes.Count]; for (int i = 0; i < Vertexes.Count; i++) { P[i] = Vertexes[i].Position; N[i] = Vertexes[i].Normal; C[i].R = Vertexes[i].Color.R * Defuse.R; C[i].G = Vertexes[i].Color.G * Defuse.G; C[i].B = Vertexes[i].Color.B * Defuse.B; C[i].A = Vertexes[i].Color.A * Defuse.A; T[i] = Vertexes[i].TextureCoords; } if (AutoNormal) { for (int i = 0; i < Vertexes.Count; i = i + 3) { Vector3 n = EG.GetTriangleNormal(P[i], P[i + 1], P[i + 2]); n.Normalize(); N[i] = n; N[i + 1] = n; N[i + 2] = n; } } BP = new VBO(); BP.SetData(P); B.AttachVBO(0, BP, 3, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0); BN = new VBO(); BN.SetData(N); B.AttachVBO(1, BN, 3, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0); BC = new VBO(); BC.SetData(C); B.AttachVBO(2, BC, 4, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0); BT = new VBO(); BT.SetData(T); B.AttachVBO(3, BT, 2, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0); }
public static void DrawTriangle(Vector3 vec, Vector3 vec1, Vector3 vec2, Color4 color) { P[0] = vec; P[1] = vec1; P[2] = vec2; C[0] = color; C[1] = color; C[2] = color; Vector3 normal = EG.GetTriangleNormal(vec, vec1, vec2); N[0] = normal; N[1] = normal; N[2] = normal; BP.SubData(P); BN.SubData(N); BC.SubData(C); //BT.SubData(T); UpdateStates(new Color4(0.1f, 0.1f, 0.1f, 1.0f), Color4.White); B.Draw(PrimitiveType.Triangles, 3); }