forked from KhronosGroup/glTF-Asset-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.cs
81 lines (70 loc) · 2.83 KB
/
Example.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
using System;
using System.Collections.Generic;
using static glTFLoader.Schema.Material;
namespace AssetGenerator.ModelGroups
{
// Name the class but inherit from ModelGroup
internal class /*Example*/ : ModelGroup
{
// Set the ModelGroupID. The value used will need to be added to the ModelGroupId enum in ModelGroup.cs
public override ModelGroupId Id => ModelGroupId./*Example*/;
public /*Example*/(List<string> imageList)
{
UseFigure(imageList, "Indices_Primitive0");
// Track the common properties for use in the readme.
var doubleSided = true;
CommonProperties.Add(new Property(PropertyName.DoubleSided, doubleSided));
Model CreateModel(Action<List<Property>, Runtime.Material> setProperties)
{
var properties = new List<Property>();
Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane();
// Apply the common properties to this group's models.
meshPrimitive.Material = new Runtime.Material
{
DoubleSided = doubleSided
};
// Apply the properties that are specific to this model.
setProperties(properties, meshPrimitive.Material);
// Create the gltf object.
return new Model
{
Properties = properties,
GLTF = CreateGLTF(() => new Runtime.Scene
{
Nodes = new List<Runtime.Node>
{
new Runtime.Node
{
Mesh = new Runtime.Mesh
{
MeshPrimitives = new List<Runtime.MeshPrimitive>
{
meshPrimitive
}
},
},
},
}),
};
}
void SetAlphaModeBlend(List<Property> properties, Runtime.Material material)
{
var alphaMode = AlphaModeEnum.BLEND;
material.AlphaMode = alphaMode;
properties.Add(new Property(PropertyName.AlphaMode, alphaMode));
}
Models = new List<Model>
{
CreateModel((properties, material) =>
{
// There are no properties set on this model.
}),
CreateModel((properties, material) =>
{
SetAlphaModeBlend(properties, material);
}),
};
GenerateUsedPropertiesList();
}
}
}