Skip to content

Commit cb60c5d

Browse files
authored
Refactor ReadmeStringHelper into ReadmeExtensionMehtods (KhronosGroup#542)
1 parent e3dc2ef commit cb60c5d

20 files changed

+295
-297
lines changed

Source/ModelGroups/Buffer_Interleaved.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public Buffer_Interleaved(List<string> imageList)
1414
Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Grey");
1515

1616
// Track the common properties for use in the readme.
17-
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));
17+
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString()));
1818

1919
Model CreateModel(Action<List<Property>, Runtime.MeshPrimitive> setProperties)
2020
{

Source/ModelGroups/Material.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public Material(List<string> imageList)
1717
// Track the common properties for use in the readme.
1818
var metallicFactorValue = 0.0f;
1919
var baseColorFactorValue = new Vector4(0.2f, 0.2f, 0.2f, 1.0f);
20-
CommonProperties.Add(new Property(PropertyName.MetallicFactor, metallicFactorValue));
21-
CommonProperties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue));
20+
CommonProperties.Add(new Property(PropertyName.MetallicFactor, metallicFactorValue.ToReadmeString()));
21+
CommonProperties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue.ToReadmeString()));
2222

2323
Model CreateModel(Action<List<Property>, Runtime.MeshPrimitive, Runtime.Material> setProperties)
2424
{
@@ -65,38 +65,38 @@ void SetNormalTexture(List<Property> properties, Runtime.MeshPrimitive meshPrimi
6565
{
6666
meshPrimitive.Normals = MeshPrimitive.GetSinglePlaneNormals();
6767
meshPrimitive.Material.NormalTexture = new Runtime.Texture { Source = normalImage };
68-
properties.Add(new Property(PropertyName.NormalTexture, normalImage));
68+
properties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString()));
6969
}
7070

7171
void SetNormalScale(List<Property> properties, Runtime.Material material)
7272
{
7373
material.NormalScale = 10.0f;
74-
properties.Add(new Property(PropertyName.NormalTextureScale, material.NormalScale));
74+
properties.Add(new Property(PropertyName.NormalTextureScale, material.NormalScale.ToReadmeString()));
7575
}
7676

7777
void SetOcclusionTexture(List<Property> properties, Runtime.Material material)
7878
{
7979
material.OcclusionTexture = new Runtime.Texture { Source = occlusionImage };
80-
properties.Add(new Property(PropertyName.OcclusionTexture, occlusionImage));
80+
properties.Add(new Property(PropertyName.OcclusionTexture, occlusionImage.ToReadmeString()));
8181
}
8282

8383
void SetOcclusionStrength(List<Property> properties, Runtime.Material material)
8484
{
8585
material.OcclusionStrength = 0.5f;
86-
properties.Add(new Property(PropertyName.OcclusionTextureStrength, material.OcclusionStrength));
86+
properties.Add(new Property(PropertyName.OcclusionTextureStrength, material.OcclusionStrength.ToReadmeString()));
8787
}
8888

8989
void SetEmissiveTexture(List<Property> properties, Runtime.Material material)
9090
{
9191
material.EmissiveTexture = new Runtime.Texture { Source = emissiveImage };
92-
properties.Add(new Property(PropertyName.EmissiveTexture, emissiveImage));
92+
properties.Add(new Property(PropertyName.EmissiveTexture, emissiveImage.ToReadmeString()));
9393
}
9494

9595
void SetEmissiveFactor(List<Property> properties, Runtime.Material material)
9696
{
9797
var emissiveFactorValue = new Vector3(1.0f, 1.0f, 1.0f);
9898
material.EmissiveFactor = emissiveFactorValue;
99-
properties.Add(new Property(PropertyName.EmissiveFactor, emissiveFactorValue));
99+
properties.Add(new Property(PropertyName.EmissiveFactor, emissiveFactorValue.ToReadmeString()));
100100
}
101101

102102
Models = new List<Model>

Source/ModelGroups/Material_AlphaBlend.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public Material_AlphaBlend(List<string> imageList)
1616

1717
// Track the common properties for use in the readme.
1818
var alphaModeValue = AlphaModeEnum.BLEND;
19-
CommonProperties.Add(new Property(PropertyName.AlphaMode, alphaModeValue));
19+
CommonProperties.Add(new Property(PropertyName.AlphaMode, alphaModeValue.ToReadmeString()));
2020

2121
Model CreateModel(Action<List<Property>, Runtime.MeshPrimitive, Runtime.PbrMetallicRoughness> setProperties)
2222
{
@@ -68,13 +68,13 @@ void SetBaseColorFactor(List<Property> properties, Runtime.PbrMetallicRoughness
6868
{
6969
var baseColorFactorValue = new Vector4(1.0f, 1.0f, 1.0f, 0.7f);
7070
metallicRoughness.BaseColorFactor = baseColorFactorValue;
71-
properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue));
71+
properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue.ToReadmeString()));
7272
}
7373

7474
void SetBaseColorTexture(List<Property> properties, Runtime.PbrMetallicRoughness metallicRoughness)
7575
{
7676
metallicRoughness.BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage };
77-
properties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));
77+
properties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString()));
7878
}
7979

8080
void SetVertexColor(List<Property> properties, Runtime.MeshPrimitive meshPrimitive)

Source/ModelGroups/Material_AlphaMask.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public Material_AlphaMask(List<string> imageList)
1515

1616
// Track the common properties for use in the readme.
1717
var alphaModeValue = AlphaModeEnum.MASK;
18-
CommonProperties.Add(new Property(PropertyName.AlphaMode, alphaModeValue));
19-
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));
18+
CommonProperties.Add(new Property(PropertyName.AlphaMode, alphaModeValue.ToReadmeString()));
19+
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString()));
2020

2121
Model CreateModel(Action<List<Property>, Runtime.Material, Runtime.PbrMetallicRoughness> setProperties)
2222
{
@@ -58,38 +58,38 @@ Model CreateModel(Action<List<Property>, Runtime.Material, Runtime.PbrMetallicRo
5858
void SetAlphaCutoff_Low(List<Property> properties, Runtime.Material material)
5959
{
6060
material.AlphaCutoff = 0.4f;
61-
properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff));
61+
properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff.ToReadmeString()));
6262
}
6363

6464
void SetAlphaCutoff_High(List<Property> properties, Runtime.Material material)
6565
{
6666
material.AlphaCutoff = 0.7f;
67-
properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff));
67+
properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff.ToReadmeString()));
6868
}
6969

7070
void SetAlphaCutoff_Multiplied(List<Property> properties, Runtime.Material material)
7171
{
7272
material.AlphaCutoff = 0.6f;
73-
properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff));
73+
properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff.ToReadmeString()));
7474
}
7575

7676
void SetAlphaCutoff_All(List<Property> properties, Runtime.Material material)
7777
{
7878
material.AlphaCutoff = 1.1f;
79-
properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff));
79+
properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff.ToReadmeString()));
8080
}
8181

8282
void SetAlphaCutoff_None(List<Property> properties, Runtime.Material material)
8383
{
8484
material.AlphaCutoff = 0.0f;
85-
properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff));
85+
properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff.ToReadmeString()));
8686
}
8787

8888
void SetBaseColorFactor(List<Property> properties, Runtime.PbrMetallicRoughness metallicRoughness)
8989
{
9090
var baseColorFactorValue = new Vector4(1.0f, 1.0f, 1.0f, 0.7f);
9191
metallicRoughness.BaseColorFactor = baseColorFactorValue;
92-
properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue));
92+
properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue.ToReadmeString()));
9393
}
9494

9595
Models = new List<Model>

Source/ModelGroups/Material_DoubleSided.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public Material_DoubleSided(List<string> imageList)
1515

1616
// Track the common properties for use in the readme.
1717
var doubleSidedValue = true;
18-
CommonProperties.Add(new Property(PropertyName.DoubleSided, doubleSidedValue));
19-
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));
18+
CommonProperties.Add(new Property(PropertyName.DoubleSided, doubleSidedValue.ToString()));
19+
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString()));
2020

2121
Model CreateModel(Action<List<Property>, Runtime.MeshPrimitive> setProperties)
2222
{
@@ -59,20 +59,20 @@ void SetVertexNormal(List<Property> properties, Runtime.MeshPrimitive meshPrimit
5959
{
6060
var planeNormalsValue = MeshPrimitive.GetSinglePlaneNormals();
6161
meshPrimitive.Normals = planeNormalsValue;
62-
properties.Add(new Property(PropertyName.VertexNormal, planeNormalsValue));
62+
properties.Add(new Property(PropertyName.VertexNormal, planeNormalsValue.ToReadmeString()));
6363
}
6464

6565
void SetVertexTangent(List<Property> properties, Runtime.MeshPrimitive meshPrimitive)
6666
{
6767
var planeTangentValue = MeshPrimitive.GetSinglePlaneTangents();
6868
meshPrimitive.Tangents = planeTangentValue;
69-
properties.Add(new Property(PropertyName.VertexTangent, planeTangentValue));
69+
properties.Add(new Property(PropertyName.VertexTangent, planeTangentValue.ToReadmeString()));
7070
}
7171

7272
void SetNormalTexture(List<Property> properties, Runtime.MeshPrimitive meshPrimitive)
7373
{
7474
meshPrimitive.Material.NormalTexture = new Runtime.Texture { Source = normalImage };
75-
properties.Add(new Property(PropertyName.NormalTexture, normalImage));
75+
properties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString()));
7676
}
7777

7878
Models = new List<Model>

Source/ModelGroups/Material_MetallicRoughness.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,32 @@ void SetVertexColor(List<Property> properties, Runtime.MeshPrimitive meshPrimiti
7171
void SetBaseColorTexture(List<Property> properties, Runtime.PbrMetallicRoughness metallicRoughness)
7272
{
7373
metallicRoughness.BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage };
74-
properties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));
74+
properties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString()));
7575
}
7676

7777
void SetBaseColorFactor(List<Property> properties, Runtime.PbrMetallicRoughness metallicRoughness)
7878
{
7979
var baseColorFactorValue = new Vector4(0.2f, 0.2f, 0.2f, 0.8f);
8080
metallicRoughness.BaseColorFactor = baseColorFactorValue;
81-
properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue));
81+
properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue.ToReadmeString()));
8282
}
8383

8484
void SetMetallicRoughnessTexture(List<Property> properties, Runtime.PbrMetallicRoughness metallicRoughness)
8585
{
8686
metallicRoughness.MetallicRoughnessTexture = new Runtime.Texture { Source = metallicRoughnessTextureImage };
87-
properties.Add(new Property(PropertyName.MetallicRoughnessTexture, metallicRoughnessTextureImage));
87+
properties.Add(new Property(PropertyName.MetallicRoughnessTexture, metallicRoughnessTextureImage.ToReadmeString()));
8888
}
8989

9090
void SetMetallicFactor(List<Property> properties, Runtime.PbrMetallicRoughness metallicRoughness)
9191
{
9292
metallicRoughness.MetallicFactor = 0.0f;
93-
properties.Add(new Property(PropertyName.MetallicFactor, metallicRoughness.MetallicFactor));
93+
properties.Add(new Property(PropertyName.MetallicFactor, metallicRoughness.MetallicFactor.ToReadmeString()));
9494
}
9595

9696
void SetRoughnessFactor(List<Property> properties, Runtime.PbrMetallicRoughness metallicRoughness)
9797
{
9898
metallicRoughness.RoughnessFactor = 0.0f;
99-
properties.Add(new Property(PropertyName.RoughnessFactor, metallicRoughness.RoughnessFactor));
99+
properties.Add(new Property(PropertyName.RoughnessFactor, metallicRoughness.RoughnessFactor.ToReadmeString()));
100100
}
101101

102102
Models = new List<Model>

Source/ModelGroups/Material_Mixed.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public Material_Mixed(List<string> imageList)
1515

1616
// Track the common properties for use in the readme.
1717
CommonProperties.Add(new Property(PropertyName.ExtensionUsed, "Specular Glossiness"));
18-
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));
18+
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString()));
1919

2020
Model CreateModel(Action<List<Property>, Runtime.Material, Runtime.Material> setProperties)
2121
{

Source/ModelGroups/Material_SpecularGlossiness.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Material_SpecularGlossiness(List<string> imageList)
1919
// Track the common properties for use in the readme.
2020
CommonProperties.Add(new Property(PropertyName.ExtensionUsed, "Specular Glossiness"));
2121
CommonProperties.Add(new Property(PropertyName.ExtensionRequired, "Specular Glossiness"));
22-
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));
22+
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString()));
2323

2424
Model CreateModel(Action<List<Property>, Runtime.MeshPrimitive, Runtime.Material, KHR_materials_pbrSpecularGlossiness> setProperties)
2525
{
@@ -80,40 +80,40 @@ void SetVertexColor(List<Property> properties, Runtime.MeshPrimitive meshPrimiti
8080
void SetDiffuseTexture(List<Property> properties, KHR_materials_pbrSpecularGlossiness extension)
8181
{
8282
extension.DiffuseTexture = new Runtime.Texture { Source = diffuseTextureImage };
83-
properties.Add(new Property(PropertyName.DiffuseTexture, diffuseTextureImage));
83+
properties.Add(new Property(PropertyName.DiffuseTexture, diffuseTextureImage.ToReadmeString()));
8484
}
8585

8686
void SetDiffuseFactor(List<Property> properties, KHR_materials_pbrSpecularGlossiness extension)
8787
{
8888
var diffuseFactorValue = new Vector4(0.2f, 0.2f, 0.2f, 0.8f);
8989
extension.DiffuseFactor = diffuseFactorValue;
90-
properties.Add(new Property(PropertyName.DiffuseFactor, diffuseFactorValue));
90+
properties.Add(new Property(PropertyName.DiffuseFactor, diffuseFactorValue.ToReadmeString()));
9191
}
9292

9393
void SetSpecularGlossinessTexture(List<Property> properties, KHR_materials_pbrSpecularGlossiness extension)
9494
{
9595
extension.SpecularGlossinessTexture = new Runtime.Texture { Source = specularGlossinessTextureImage };
96-
properties.Add(new Property(PropertyName.SpecularGlossinessTexture, specularGlossinessTextureImage));
96+
properties.Add(new Property(PropertyName.SpecularGlossinessTexture, specularGlossinessTextureImage.ToReadmeString()));
9797
}
9898

9999
void SetSpecularFactor(List<Property> properties, KHR_materials_pbrSpecularGlossiness extension)
100100
{
101101
var specularFactorValue = new Vector3(0.4f, 0.4f, 0.4f);
102102
extension.SpecularFactor = specularFactorValue;
103-
properties.Add(new Property(PropertyName.SpecularFactor, specularFactorValue));
103+
properties.Add(new Property(PropertyName.SpecularFactor, specularFactorValue.ToReadmeString()));
104104
}
105105

106106
void SetSpecularFactorToZero(List<Property> properties, KHR_materials_pbrSpecularGlossiness extension)
107107
{
108108
var specularFactorValue = new Vector3(0.0f, 0.0f, 0.0f);
109109
extension.SpecularFactor = specularFactorValue;
110-
properties.Add(new Property(PropertyName.SpecularFactor, specularFactorValue));
110+
properties.Add(new Property(PropertyName.SpecularFactor, specularFactorValue.ToReadmeString()));
111111
}
112112

113113
void SetGlossinessFactor(List<Property> properties, KHR_materials_pbrSpecularGlossiness extension)
114114
{
115115
extension.GlossinessFactor = 0.3f;
116-
properties.Add(new Property(PropertyName.GlossinessFactor, extension.GlossinessFactor));
116+
properties.Add(new Property(PropertyName.GlossinessFactor, extension.GlossinessFactor.ToReadmeString()));
117117
}
118118

119119
Models = new List<Model>

0 commit comments

Comments
 (0)