/// <summary> /// Draw shape to buffer using VertexFormat /// </summary> /// <param name="buffer"></param> /// <param name="vertexFormat"></param> public virtual void DrawBufer(VertexFloatBuffer buffer, VertexFormat vertexFormat) { switch (vertexFormat) { case VertexFormat.XY: break; case VertexFormat.XY_COLOR: break; case VertexFormat.XY_UV: break; case VertexFormat.XY_UV_COLOR: break; case VertexFormat.XYZ: break; case VertexFormat.XYZ_COLOR: break; case VertexFormat.XYZ_UV: break; case VertexFormat.XYZ_UV_COLOR: break; case VertexFormat.XYZ_NORMAL_COLOR: #region xyz_normal_color foreach (Vertex vertex in VertexsIndicesData.Vertexs) { buffer.AddVertex(vertex.Position.X, vertex.Position.Y, vertex.Position.Z, vertex.Normal.X, vertex.Normal.Y, vertex.Normal.Z, vertex.Color.R, vertex.Color.G, vertex.Color.B, vertex.Color.A); } #endregion break; case VertexFormat.XYZ_NORMAL_UV: #region xyz_normal_uv foreach (Vertex vertex in VertexsIndicesData.Vertexs) { buffer.AddVertex(vertex.Position.X, vertex.Position.Y, vertex.Position.Z, vertex.Normal.X, vertex.Normal.Y, vertex.Normal.Z, vertex.TexCoord.X, vertex.TexCoord.Y); } #endregion break; case VertexFormat.XYZ_NORMAL: #region xyz_normal foreach (Vertex vertex in VertexsIndicesData.Vertexs) { buffer.AddVertex(vertex.Position.X, vertex.Position.Y, vertex.Position.Z, new Vector3(vertex.Normal.X, vertex.Normal.Y, vertex.Normal.Z)); } #endregion break; case VertexFormat.XYZ_NORMAL_UV_COLOR: #region xyz_normal_uv_color foreach (Vertex vertex in VertexsIndicesData.Vertexs) { buffer.AddVertex(vertex.Position.X, vertex.Position.Y, vertex.Position.Z, vertex.Normal.X, vertex.Normal.Y, vertex.Normal.Z, vertex.TexCoord.X, vertex.TexCoord.Y, vertex.Color.R, vertex.Color.G, vertex.Color.B, vertex.Color.A); } #endregion break; default: break; } }
/// <summary> /// Draws buffer. /// </summary> /// <param name="buffer"></param> /// <param name="vertexFormat"></param> public override void DrawBufer(VertexFloatBuffer buffer, VertexFormat vertexFormat) { switch (vertexFormat) { case VertexFormat.XY: break; case VertexFormat.XY_COLOR: break; case VertexFormat.XY_UV: break; case VertexFormat.XY_UV_COLOR: break; case VertexFormat.XYZ: break; case VertexFormat.XYZ_COLOR: break; case VertexFormat.XYZ_UV: break; case VertexFormat.XYZ_UV_COLOR: break; case VertexFormat.XYZ_NORMAL_COLOR: #region xyz_normal_color int count = 0; Vector4 color = Vector4.Zero; foreach (Matrix4 matrix4 in ShapeMesh) { switch (count) { case 0: color = Tools.ColorToVector4(frontFaceColor); break; case 2: color = Tools.ColorToVector4(rightFaceColor); break; case 4: color = Tools.ColorToVector4(topFaceColor); break; case 6: color = Tools.ColorToVector4(bottomFaceColor); break; case 8: color = Tools.ColorToVector4(leftFaceColor); break; case 10: color = Tools.ColorToVector4(backFaceColor); break; default: break; } buffer.AddVertex(matrix4.Row0.X, matrix4.Row0.Y, matrix4.Row0.Z, matrix4.Row3.X, matrix4.Row3.Y, matrix4.Row3.Z, color.X, color.Y, color.Z, color.W); buffer.AddVertex(matrix4.Row1.X, matrix4.Row1.Y, matrix4.Row1.Z, matrix4.Row3.X, matrix4.Row3.Y, matrix4.Row3.Z, color.X, color.Y, color.Z, color.W); buffer.AddVertex(matrix4.Row2.X, matrix4.Row2.Y, matrix4.Row2.Z, matrix4.Row3.X, matrix4.Row3.Y, matrix4.Row3.Z, color.X, color.Y, color.Z, color.W); count++; } #endregion break; case VertexFormat.XYZ_NORMAL_UV: #region xyz_normal_uv_color if (useTexture == false) { throw new ApplicationException("Use texture must be true."); } int count1 = 0; foreach (Matrix4 matrix4 in ShapeMesh) { buffer.AddVertex(matrix4.Row0.X, matrix4.Row0.Y, matrix4.Row0.Z, matrix4.Row3.X, matrix4.Row3.Y, matrix4.Row3.Z, TexCoords[count1].Row0.X, 1 - TexCoords[count1].Row0.Y); buffer.AddVertex(matrix4.Row1.X, matrix4.Row1.Y, matrix4.Row1.Z, matrix4.Row3.X, matrix4.Row3.Y, matrix4.Row3.Z, TexCoords[count1].Row1.X, 1 - TexCoords[count1].Row1.Y); buffer.AddVertex(matrix4.Row2.X, matrix4.Row2.Y, matrix4.Row2.Z, matrix4.Row3.X, matrix4.Row3.Y, matrix4.Row3.Z, TexCoords[count1].Row2.X, 1 - TexCoords[count1].Row2.Y); count1++; } #endregion break; case VertexFormat.XYZ_NORMAL_UV_COLOR: #region xyz_normal_uv_color if (useTexture == false) { throw new ApplicationException("Use texture must be true."); } int count2 = 0; Vector4 color1 = Vector4.Zero; foreach (Matrix4 matrix4 in ShapeMesh) { switch (count2) { case 0: color1 = Tools.ColorToVector4(frontFaceColor); break; case 2: color1 = Tools.ColorToVector4(rightFaceColor); break; case 4: color1 = Tools.ColorToVector4(topFaceColor); break; case 6: color = Tools.ColorToVector4(bottomFaceColor); break; case 8: color1 = Tools.ColorToVector4(leftFaceColor); break; case 10: color1 = Tools.ColorToVector4(backFaceColor); break; default: break; } buffer.AddVertex(matrix4.Row0.X, matrix4.Row0.Y, matrix4.Row0.Z, matrix4.Row3.X, matrix4.Row3.Y, matrix4.Row3.Z, TexCoords[count2].Row0.X, TexCoords[count2].Row0.Y, color1.X, color1.Y, color1.Z, color1.W); buffer.AddVertex(matrix4.Row1.X, matrix4.Row1.Y, matrix4.Row1.Z, matrix4.Row3.X, matrix4.Row3.Y, matrix4.Row3.Z, TexCoords[count2].Row1.X, TexCoords[count2].Row1.Y, color1.X, color1.Y, color1.Z, color1.W); buffer.AddVertex(matrix4.Row2.X, matrix4.Row2.Y, matrix4.Row2.Z, matrix4.Row3.X, matrix4.Row3.Y, matrix4.Row3.Z, TexCoords[count2].Row2.X, TexCoords[count2].Row2.Y, color1.X, color1.Y, color1.Z, color1.W); count2++; } #endregion break; default: break; } }