소스 검색

finish set featureIds by textures

Bert Temme 2 년 전
부모
커밋
1e506e5278
2개의 변경된 파일20개의 추가작업 그리고 13개의 파일을 삭제
  1. 13 4
      src/SharpGLTF.Cesium/Schema2/MeshExtMeshFeatures.cs
  2. 7 9
      tests/SharpGLTF.Cesium.Tests/ExtMeshFeaturesTests.cs

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

@@ -47,6 +47,8 @@ namespace SharpGLTF.Schema2
             if (index.HasValue) _LogicalTextureIndex = (int)index;
             if (texCoord.HasValue) TextureCoordinate = (int)texCoord;
         }
+
+        public int Index { get => _LogicalTextureIndex; }
     }
 
     public partial class MeshExtMeshFeatureID
@@ -96,7 +98,6 @@ namespace SharpGLTF.Schema2
 
     public static class ExtMeshFeatures
     {
-
         /// <summary>
         /// Set the FeatureIds for a MeshPrimitive
         /// </summary>
@@ -111,7 +112,7 @@ namespace SharpGLTF.Schema2
             foreach (var featureId in featureIds)
             {
                 ValidateFeature(primitive, featureId);
-           };
+            };
 
             var ext = primitive.UseExtension<MeshExtMeshFeatures>();
             ext.FeatureIds = featureIds;
@@ -120,7 +121,7 @@ namespace SharpGLTF.Schema2
         private static void ValidateFeature(MeshPrimitive primitive, MeshExtMeshFeatureID item)
         {
             Guard.MustBeGreaterThanOrEqualTo((int)item.FeatureCount, 1, nameof(item.FeatureCount));
-            
+
             if (item.NullFeatureId.HasValue)
             {
                 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));
             }
+            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


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.