forked from KhronosGroup/glTF-Asset-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaterial_Mixed.cs
102 lines (88 loc) · 4.5 KB
/
Material_Mixed.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
namespace AssetGenerator.ModelGroups
{
internal class Material_Mixed : ModelGroup
{
public override ModelGroupId Id => ModelGroupId.Material_Mixed;
public Material_Mixed(List<string> imageList)
{
var baseColorTexture = new Runtime.Texture { Source = UseTexture(imageList, "BaseColor_X") };
UseFigure(imageList, "UVSpace2");
UseFigure(imageList, "UVSpace3");
// Track the common properties for use in the readme.
CommonProperties.Add(new Property(PropertyName.ExtensionUsed, "Specular Glossiness"));
CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTexture.Source.ToReadmeString()));
Model CreateModel(Action<List<Property>, Runtime.Material, Runtime.Material> setProperties)
{
var properties = new List<Property>();
var meshPrimitives = MeshPrimitive.CreateMultiPrimitivePlane();
var baseColorTextureInfo = new Runtime.TextureInfo { Texture = baseColorTexture };
meshPrimitives[0].Material = new Runtime.Material();
meshPrimitives[0].Material.PbrMetallicRoughness = new Runtime.PbrMetallicRoughness();
meshPrimitives[1].Material = new Runtime.Material();
meshPrimitives[1].Material.PbrMetallicRoughness = new Runtime.PbrMetallicRoughness();
// Apply the common properties to the gltf.
meshPrimitives[0].Material.PbrMetallicRoughness.BaseColorTexture = baseColorTextureInfo;
meshPrimitives[1].Material.PbrMetallicRoughness.BaseColorTexture = baseColorTextureInfo;
// Apply the properties that are specific to this gltf.
setProperties(properties, meshPrimitives[0].Material, meshPrimitives[1].Material);
// Create the gltf object.
return new Model
{
Properties = properties,
GLTF = CreateGLTF(() => new Runtime.Scene
{
Nodes = new[]
{
new Runtime.Node
{
Mesh = new Runtime.Mesh
{
MeshPrimitives = meshPrimitives
},
},
},
}, extensionsUsed: new List<string>() { "KHR_materials_pbrSpecularGlossiness" }),
};
}
void SetSpecularGlossiness0(List<Property> properties, Runtime.Material material0)
{
material0.Extensions = new List<Runtime.Extensions.Extension> { new Runtime.Extensions.KHR_materials_pbrSpecularGlossiness() };
properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial0, ":white_check_mark:"));
}
void SetSpecularGlossiness1(List<Property> properties, Runtime.Material material1)
{
material1.Extensions = new List<Runtime.Extensions.Extension> { new Runtime.Extensions.KHR_materials_pbrSpecularGlossiness() };
properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial1, ":white_check_mark:"));
}
void NoSpecularGlossiness0(List<Property> properties)
{
properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial0, ":x:"));
}
void NoSpecularGlossiness1(List<Property> properties)
{
properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial1, ":x:"));
}
Models = new List<Model>
{
CreateModel((properties, material0, material1) =>
{
SetSpecularGlossiness0(properties, material0);
SetSpecularGlossiness1(properties, material1);
}),
CreateModel((properties, material0, material1) =>
{
NoSpecularGlossiness0(properties);
NoSpecularGlossiness1(properties);
}),
CreateModel((properties, material0, material1) =>
{
SetSpecularGlossiness0(properties, material0);
NoSpecularGlossiness1(properties);
}),
};
GenerateUsedPropertiesList();
}
}
}