Browse Source

implement setColor and MaxColors to 1

Bert Temme 2 years ago
parent
commit
1e3de303b4

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

@@ -23,10 +23,10 @@ namespace SharpGLTF.Cesium
 
         public void CreatePointCloudWithCustomAttributesTest()
         {
-            var material = new MaterialBuilder("material1").WithUnlitShader();
+            var material = new MaterialBuilder("material1");
             var mesh = new MeshBuilder<VertexPosition, VertexPointcloud, VertexEmpty>("mesh");
             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++)
             {
@@ -34,7 +34,7 @@ namespace SharpGLTF.Cesium
                 {
                     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);
                     }

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

@@ -12,7 +12,6 @@ namespace SharpGLTF
     {
         public VertexPointcloud(Vector4 color, float intensity, float classification)
         {
-            // Q: How to set the color??
             Color = color;
             Intensity = intensity;
             Classification = classification;
@@ -30,19 +29,21 @@ namespace SharpGLTF
         [VertexAttribute(CLASSIFICATIONATTRIBUTENAME, EncodingType.FLOAT, false)]
         public float Classification;
 
-        public int MaxColors => 0;
+        public int MaxColors => 1;
 
         public int MaxTextCoords => 0;
 
         public IEnumerable<string> CustomAttributes => throw new NotImplementedException();
 
         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 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)); }