소스 검색

implement setColor and MaxColors to 1

Bert Temme 2 년 전
부모
커밋
1e3de303b4
2개의 변경된 파일8개의 추가작업 그리고 7개의 파일을 삭제
  1. 3 3
      tests/SharpGLTF.Cesium.Tests/ExtStructuralMetadataTests.cs
  2. 5 4
      tests/SharpGLTF.Cesium.Tests/VertexPointcloud.cs

+ 3 - 3
tests/SharpGLTF.Cesium.Tests/ExtStructuralMetadataTests.cs

@@ -23,10 +23,10 @@ namespace SharpGLTF.Cesium
 
 
         public void CreatePointCloudWithCustomAttributesTest()
         public void CreatePointCloudWithCustomAttributesTest()
         {
         {
-            var material = new MaterialBuilder("material1").WithUnlitShader();
+            var material = new MaterialBuilder("material1");
             var mesh = new MeshBuilder<VertexPosition, VertexPointcloud, VertexEmpty>("mesh");
             var mesh = new MeshBuilder<VertexPosition, VertexPointcloud, VertexEmpty>("mesh");
             var pointCloud = mesh.UsePrimitive(material, 1);
             var pointCloud = mesh.UsePrimitive(material, 1);
-            var greenColor = new Vector4(0f, 1f, 0f, 1f);
+            var redColor = new Vector4(1f, 0f, 0f, 1f);
 
 
             for (var x = -10; x < 10; x++)
             for (var x = -10; x < 10; x++)
             {
             {
@@ -34,7 +34,7 @@ namespace SharpGLTF.Cesium
                 {
                 {
                     for (var z = -10; z < 10; z++)
                     for (var z = -10; z < 10; z++)
                     {
                     {
-                        var vt0 = VertexBuilder.GetVertexPointcloud(new Vector3(x, y, z), greenColor, 199, 4);
+                        var vt0 = VertexBuilder.GetVertexPointcloud(new Vector3(x, y, z), redColor, 199, 4);
 
 
                         pointCloud.AddPoint(vt0);
                         pointCloud.AddPoint(vt0);
                     }
                     }

+ 5 - 4
tests/SharpGLTF.Cesium.Tests/VertexPointcloud.cs

@@ -12,7 +12,6 @@ namespace SharpGLTF
     {
     {
         public VertexPointcloud(Vector4 color, float intensity, float classification)
         public VertexPointcloud(Vector4 color, float intensity, float classification)
         {
         {
-            // Q: How to set the color??
             Color = color;
             Color = color;
             Intensity = intensity;
             Intensity = intensity;
             Classification = classification;
             Classification = classification;
@@ -30,19 +29,21 @@ namespace SharpGLTF
         [VertexAttribute(CLASSIFICATIONATTRIBUTENAME, EncodingType.FLOAT, false)]
         [VertexAttribute(CLASSIFICATIONATTRIBUTENAME, EncodingType.FLOAT, false)]
         public float Classification;
         public float Classification;
 
 
-        public int MaxColors => 0;
+        public int MaxColors => 1;
 
 
         public int MaxTextCoords => 0;
         public int MaxTextCoords => 0;
 
 
         public IEnumerable<string> CustomAttributes => throw new NotImplementedException();
         public IEnumerable<string> CustomAttributes => throw new NotImplementedException();
 
 
         void IVertexMaterial.SetColor(int setIndex, Vector4 color) {
         void IVertexMaterial.SetColor(int setIndex, Vector4 color) {
-            if (setIndex == 0) this.Color = color;
+            if (setIndex == 0) Color = color;
         }
         }
 
 
         public void SetTexCoord(int setIndex, Vector2 coord) { }
         public void SetTexCoord(int setIndex, Vector2 coord) { }
 
 
-        public Vector4 GetColor(int index) { throw new ArgumentOutOfRangeException(nameof(index)); }
+        public Vector4 GetColor(int index) {
+            return Color;
+        }
 
 
         public Vector2 GetTexCoord(int index) { throw new ArgumentOutOfRangeException(nameof(index)); }
         public Vector2 GetTexCoord(int index) { throw new ArgumentOutOfRangeException(nameof(index)); }