瀏覽代碼

finish set featureIds by textures

Bert Temme 2 年之前
父節點
當前提交
1e506e5278

+ 13 - 4
src/SharpGLTF.Cesium/Schema2/MeshExtMeshFeatures.cs

@@ -47,6 +47,8 @@ namespace SharpGLTF.Schema2
             if (index.HasValue) _LogicalTextureIndex = (int)index;
             if (index.HasValue) _LogicalTextureIndex = (int)index;
             if (texCoord.HasValue) TextureCoordinate = (int)texCoord;
             if (texCoord.HasValue) TextureCoordinate = (int)texCoord;
         }
         }
+
+        public int Index { get => _LogicalTextureIndex; }
     }
     }
 
 
     public partial class MeshExtMeshFeatureID
     public partial class MeshExtMeshFeatureID
@@ -96,7 +98,6 @@ namespace SharpGLTF.Schema2
 
 
     public static class ExtMeshFeatures
     public static class ExtMeshFeatures
     {
     {
-
         /// <summary>
         /// <summary>
         /// Set the FeatureIds for a MeshPrimitive
         /// Set the FeatureIds for a MeshPrimitive
         /// </summary>
         /// </summary>
@@ -111,7 +112,7 @@ namespace SharpGLTF.Schema2
             foreach (var featureId in featureIds)
             foreach (var featureId in featureIds)
             {
             {
                 ValidateFeature(primitive, featureId);
                 ValidateFeature(primitive, featureId);
-           };
+            };
 
 
             var ext = primitive.UseExtension<MeshExtMeshFeatures>();
             var ext = primitive.UseExtension<MeshExtMeshFeatures>();
             ext.FeatureIds = featureIds;
             ext.FeatureIds = featureIds;
@@ -120,7 +121,7 @@ namespace SharpGLTF.Schema2
         private static void ValidateFeature(MeshPrimitive primitive, MeshExtMeshFeatureID item)
         private static void ValidateFeature(MeshPrimitive primitive, MeshExtMeshFeatureID item)
         {
         {
             Guard.MustBeGreaterThanOrEqualTo((int)item.FeatureCount, 1, nameof(item.FeatureCount));
             Guard.MustBeGreaterThanOrEqualTo((int)item.FeatureCount, 1, nameof(item.FeatureCount));
-            
+
             if (item.NullFeatureId.HasValue)
             if (item.NullFeatureId.HasValue)
             {
             {
                 Guard.MustBeGreaterThanOrEqualTo((int)item.NullFeatureId, 0, nameof(item.NullFeatureId));
                 Guard.MustBeGreaterThanOrEqualTo((int)item.NullFeatureId, 0, nameof(item.NullFeatureId));
@@ -141,7 +142,15 @@ namespace SharpGLTF.Schema2
             {
             {
                 Guard.MustBeGreaterThanOrEqualTo((int)item.PropertyTable, 0, nameof(item.PropertyTable));
                 Guard.MustBeGreaterThanOrEqualTo((int)item.PropertyTable, 0, nameof(item.PropertyTable));
             }
             }
+            if (item.Texture != null)
+            {
+                Guard.MustBeGreaterThanOrEqualTo((int)item.Texture.TextureCoordinate, 0, nameof(item.Texture.TextureCoordinate));
+                var expectedTexCoordAttribute = $"TEXCOORD_{item.Texture.TextureCoordinate}";
+                Guard.NotNull(primitive.GetVertexAccessor(expectedTexCoordAttribute), expectedTexCoordAttribute);
+
+                var image = primitive.LogicalParent.LogicalParent.LogicalImages[item.Texture.Index];
+                Guard.NotNull(image, "Texture " + nameof(item.Texture.Index));
+            }
         }
         }
     }
     }
-
 }
 }

文件差異過大導致無法顯示
+ 7 - 9
tests/SharpGLTF.Cesium.Tests/ExtMeshFeaturesTests.cs


部分文件因文件數量過多而無法顯示