Vicente Penades 3 years ago
parent
commit
ee0c77596b

+ 74 - 0
src/SharpGLTF.Core/Runtime/MeshDecoder.cs

@@ -19,9 +19,24 @@ namespace SharpGLTF.Runtime
     public interface IMeshDecoder<TMaterial>
     public interface IMeshDecoder<TMaterial>
         where TMaterial : class
         where TMaterial : class
     {
     {
+        /// <summary>
+        /// Mesh Name
+        /// </summary>
         string Name { get; }
         string Name { get; }
+
+        /// <summary>
+        /// Mesh Extras
+        /// </summary>
         Object Extras { get; }
         Object Extras { get; }
+
+        /// <summary>
+        /// Mesh Logical index in the original glTF model.
+        /// </summary>
         int LogicalIndex { get; }
         int LogicalIndex { get; }
+
+        /// <summary>
+        /// Collection of mesh primitives
+        /// </summary>
         IReadOnlyList<IMeshPrimitiveDecoder<TMaterial>> Primitives { get; }
         IReadOnlyList<IMeshPrimitiveDecoder<TMaterial>> Primitives { get; }
     }
     }
 
 
@@ -77,26 +92,85 @@ namespace SharpGLTF.Runtime
 
 
         #region API
         #region API
 
 
+        /// <summary>
+        /// Gets the position for the given vertex.
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <returns>A vertex relative position.</returns>
         XYZ GetPosition(int vertexIndex);
         XYZ GetPosition(int vertexIndex);
 
 
+        /// <summary>
+        /// Gets the normal for the given vertex.
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <returns></returns>
         XYZ GetNormal(int vertexIndex);
         XYZ GetNormal(int vertexIndex);
 
 
+        /// <summary>
+        /// Gets the tangent for the given vertex.
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <returns></returns>
         XYZW GetTangent(int vertexIndex);
         XYZW GetTangent(int vertexIndex);
 
 
+        /// <summary>
+        /// Gets the UV coordinate for the given vertex.
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <param name="textureSetIndex">The texture set index.</param>
+        /// <returns></returns>
         XY GetTextureCoord(int vertexIndex, int textureSetIndex);
         XY GetTextureCoord(int vertexIndex, int textureSetIndex);
 
 
+        /// <summary>
+        /// Gets the color for the given vertex.
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <param name="colorSetIndex">The color set index.</param>
+        /// <returns></returns>
         XYZW GetColor(int vertexIndex, int colorSetIndex);
         XYZW GetColor(int vertexIndex, int colorSetIndex);
 
 
+        /// <summary>
+        /// Gets the skin weights for the given vertex.
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <returns></returns>
         SparseWeight8 GetSkinWeights(int vertexIndex);
         SparseWeight8 GetSkinWeights(int vertexIndex);
 
 
+        /// <summary>
+        /// Gets the sequence of position deltas for the given vertex. (morph targets)
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <returns>A collection of position deltas, one delta per morph target.</returns>
         IReadOnlyList<XYZ> GetPositionDeltas(int vertexIndex);
         IReadOnlyList<XYZ> GetPositionDeltas(int vertexIndex);
 
 
+        /// <summary>
+        /// Gets the sequence of normals deltas for the given vertex. (morph targets)
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <returns>A collection of normal deltas, one delta per morph target.</returns>
         IReadOnlyList<XYZ> GetNormalDeltas(int vertexIndex);
         IReadOnlyList<XYZ> GetNormalDeltas(int vertexIndex);
 
 
+        /// <summary>
+        /// Gets the sequence of tangent deltas for the given vertex. (morph targets)
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <returns>A collection of tangent deltas, one delta per morph target.</returns>
         IReadOnlyList<XYZ> GetTangentDeltas(int vertexIndex);
         IReadOnlyList<XYZ> GetTangentDeltas(int vertexIndex);
 
 
+        /// <summary>
+        /// Gets the sequence of texture coordinate deltas for the given vertex. (morph targets)
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <param name="textureSetIndex">The texture set index.</param>
+        /// <returns>A collection of texture coordinate deltas, one delta per morph target.</returns>
         IReadOnlyList<XY> GetTextureCoordDeltas(int vertexIndex, int textureSetIndex);
         IReadOnlyList<XY> GetTextureCoordDeltas(int vertexIndex, int textureSetIndex);
 
 
+        /// <summary>
+        /// Gets the sequence of color deltas for the given vertex. (morph targets)
+        /// </summary>
+        /// <param name="vertexIndex">The vertex index.</param>
+        /// <param name="colorSetIndex">The color set index.</param>
+        /// <returns>A collection of color deltas, one delta per morph target.</returns>
         IReadOnlyList<XYZW> GetColorDeltas(int vertexIndex, int colorSetIndex);
         IReadOnlyList<XYZW> GetColorDeltas(int vertexIndex, int colorSetIndex);
 
 
         #endregion
         #endregion

+ 24 - 0
src/SharpGLTF.Core/Runtime/VertexNormalsFactory.cs

@@ -6,18 +6,42 @@ using System.Text;
 
 
 namespace SharpGLTF.Runtime
 namespace SharpGLTF.Runtime
 {
 {
+    /// <summary>
+    /// Factory used to calculate the normals of a mesh which implements <see cref="IMeshPrimitive"/>
+    /// </summary>
     static class VertexNormalsFactory
     static class VertexNormalsFactory
     {
     {
+        /// <summary>
+        /// This interface must be implemented by a mesh, or a proxy of a mesh,
+        /// in order to calculate its normals
+        /// </summary>
         #pragma warning disable CA1034 // Nested types should not be visible
         #pragma warning disable CA1034 // Nested types should not be visible
         public interface IMeshPrimitive
         public interface IMeshPrimitive
         #pragma warning restore CA1034 // Nested types should not be visible
         #pragma warning restore CA1034 // Nested types should not be visible
         {
         {
+            /// <summary>
+            /// gets the number of vertices.
+            /// </summary>
             int VertexCount { get; }
             int VertexCount { get; }
 
 
+            /// <summary>
+            /// Gets the position of a given vertex.
+            /// </summary>
+            /// <param name="idx">The Vertex Index</param>
+            /// <returns>The local vertex position.</returns>
             Vector3 GetVertexPosition(int idx);
             Vector3 GetVertexPosition(int idx);
 
 
+            /// <summary>
+            /// Sets the normal for the given vertex
+            /// </summary>
+            /// <param name="idx">The vertex index to set</param>
+            /// <param name="normal">The normal that will be set to the vertex</param>
             void SetVertexNormal(int idx, Vector3 normal);
             void SetVertexNormal(int idx, Vector3 normal);
 
 
+            /// <summary>
+            /// Gets a sequence of triangles, where each triangle is defined by three vertex indices.
+            /// </summary>
+            /// <returns>A collection of triangles</returns>
             IEnumerable<(int A, int B, int C)> GetTriangleIndices();
             IEnumerable<(int A, int B, int C)> GetTriangleIndices();
         }
         }
 
 

+ 32 - 0
src/SharpGLTF.Core/Runtime/VertexTangentsFactory.cs

@@ -8,6 +8,9 @@ namespace SharpGLTF.Runtime
 {
 {
     using VERTEXKEY = System.ValueTuple<Vector3, Vector3, Vector2>;
     using VERTEXKEY = System.ValueTuple<Vector3, Vector3, Vector2>;
 
 
+    /// <summary>
+    /// Factory used to calculate the tangents of a mesh which implements <see cref="IMeshPrimitive"/>
+    /// </summary>
     static class VertexTangentsFactory
     static class VertexTangentsFactory
     {
     {
         // https://gamedev.stackexchange.com/questions/128023/how-does-mikktspace-work-for-calculating-the-tangent-space-during-normal-mapping
         // https://gamedev.stackexchange.com/questions/128023/how-does-mikktspace-work-for-calculating-the-tangent-space-during-normal-mapping
@@ -22,14 +25,43 @@ namespace SharpGLTF.Runtime
         /// </summary>
         /// </summary>
         public interface IMeshPrimitive
         public interface IMeshPrimitive
         {
         {
+            /// <summary>
+            /// gets the number of vertices.
+            /// </summary>
             int VertexCount { get; }
             int VertexCount { get; }
 
 
+            /// <summary>
+            /// Gets the position of a given vertex.
+            /// </summary>
+            /// <param name="idx">The Vertex Index</param>
+            /// <returns>The local vertex position.</returns>
             Vector3 GetVertexPosition(int idx);
             Vector3 GetVertexPosition(int idx);
+
+            /// <summary>
+            /// Gets the normal of a given vertex.
+            /// </summary>
+            /// <param name="idx">The Vertex Index</param>
+            /// <returns>The local vertex normal.</returns>
             Vector3 GetVertexNormal(int idx);
             Vector3 GetVertexNormal(int idx);
+
+            /// <summary>
+            /// Gets the texture coordinate of a given vertex.
+            /// </summary>
+            /// <param name="idx">The Vertex Index</param>
+            /// <returns>The local texture coordinate.</returns>
             Vector2 GetVertexTexCoord(int idx);
             Vector2 GetVertexTexCoord(int idx);
 
 
+            /// <summary>
+            /// Sets the tangent for the given vertex
+            /// </summary>
+            /// <param name="idx">The vertex index to set</param>
+            /// <param name="tangent">The tangent that will be set to the vertex</param>
             void SetVertexTangent(int idx, Vector4 tangent);
             void SetVertexTangent(int idx, Vector4 tangent);
 
 
+            /// <summary>
+            /// Gets a sequence of triangles, where each triangle is defined by three vertex indices.
+            /// </summary>
+            /// <returns>A collection of triangles</returns>
             IEnumerable<(int A, int B, int C)> GetTriangleIndices();
             IEnumerable<(int A, int B, int C)> GetTriangleIndices();
         }
         }