Exemplo n.º 1
0
        public Mesh_PrimitiveAttribute(List <string> imageList)
        {
            var baseColorTexture = new Texture {
                Source = UseTexture(imageList, "BaseColor_Plane")
            };
            var normalTexture = new Texture {
                Source = UseTexture(imageList, "Normal_Plane")
            };

            // Track the common properties for use in the readme.
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTexture.Source.ToReadmeString()));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive> setProperties)
            {
                var properties    = new List <Property>();
                var meshPrimitive = MeshPrimitive.CreateSinglePlane();

                meshPrimitive.Material = new Runtime.Material();

                // Apply the common properties to the gltf.
                meshPrimitive.Material.PbrMetallicRoughness = new PbrMetallicRoughness
                {
                    BaseColorTexture = new TextureInfo {
                        Texture = baseColorTexture
                    },
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive);

                // Create the gltf object.
                return(new Model
                {
                    Properties = properties,
                    GLTF = CreateGLTF(() => new Scene
                    {
                        Nodes = new List <Node>
                        {
                            new Node
                            {
                                Mesh = new Runtime.Mesh
                                {
                                    MeshPrimitives = new List <Runtime.MeshPrimitive>
                                    {
                                        meshPrimitive
                                    }
                                },
                            },
                        },
                    }),
                });
            }

            void SetVertexUVFloat(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TexCoords0.OutputType = DataType.Float;
                properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TexCoords0.OutputType.ToReadmeString()));
            }

            void SetVertexUVByte(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TexCoords0.OutputType = DataType.NormalizedUnsignedByte;
                properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TexCoords0.OutputType.ToReadmeString()));
            }

            void SetVertexUVShort(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TexCoords0.OutputType = DataType.NormalizedUnsignedShort;
                properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TexCoords0.OutputType.ToReadmeString()));
            }

            void SetVertexNormal(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                var normals = MeshPrimitive.GetSinglePlaneNormals();

                meshPrimitive.Normals = Data.Create(normals);
                properties.Add(new Property(PropertyName.VertexNormal, normals.ToReadmeString()));
            }

            void SetVertexTangent(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                var tangents = new[]
                {
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f)
                };

                meshPrimitive.Tangents = Data.Create(tangents);
                properties.Add(new Property(PropertyName.VertexTangent, tangents.ToReadmeString()));
            }

            void SetNormalTexture(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Material.NormalTexture = new NormalTextureInfo {
                    Texture = normalTexture
                };
                properties.Add(new Property(PropertyName.NormalTexture, normalTexture.Source.ToReadmeString()));
            }

            Models = new List <Model>
            {
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVFloat(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVByte(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVShort(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVFloat(properties, meshPrimitive);
                    SetVertexNormal(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVFloat(properties, meshPrimitive);
                    SetNormalTexture(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVFloat(properties, meshPrimitive);
                    SetVertexNormal(properties, meshPrimitive);
                    SetNormalTexture(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVFloat(properties, meshPrimitive);
                    SetVertexNormal(properties, meshPrimitive);
                    SetVertexTangent(properties, meshPrimitive);
                    SetNormalTexture(properties, meshPrimitive);
                }),
            };

            GenerateUsedPropertiesList();
        }
        public Buffer_Interleaved(List <string> imageList)
        {
            var baseColorTextureImage = UseTexture(imageList, "BaseColor_Grey");

            // Track the common properties for use in the readme.
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive> setProperties)
            {
                var properties    = new List <Property>();
                var meshPrimitive = MeshPrimitive.CreateSinglePlane();

                // Apply the common properties to the gltf.
                meshPrimitive.Interleave = true;
                meshPrimitive.Colors     = new[]
                {
                    new Vector4(0.0f, 1.0f, 0.0f, 0.2f),
                    new Vector4(1.0f, 0.0f, 0.0f, 0.2f),
                    new Vector4(1.0f, 1.0f, 0.0f, 0.2f),
                    new Vector4(0.0f, 0.0f, 1.0f, 0.2f)
                };
                meshPrimitive.Material = new Runtime.Material()
                {
                    MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness()
                    {
                        BaseColorTexture = new Runtime.Texture()
                        {
                            Source  = baseColorTextureImage,
                            Sampler = new Runtime.Sampler(),
                        },
                    },
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive);

                // Create the gltf object
                return(new Model
                {
                    Properties = properties,
                    GLTF = CreateGLTF(() => new Runtime.Scene()
                    {
                        Nodes = new[]
                        {
                            new Runtime.Node
                            {
                                Mesh = new Runtime.Mesh
                                {
                                    MeshPrimitives = new[]
                                    {
                                        meshPrimitive
                                    }
                                },
                            },
                        },
                    }),
                });
            }

            void SetUvTypeFloat(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TextureCoordsComponentType = Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.FLOAT;
                properties.Add(new Property(PropertyName.VertexUV0, "Float"));
            }

            void SetUvTypeTypeByte(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TextureCoordsComponentType = Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.NORMALIZED_UBYTE;
                properties.Add(new Property(PropertyName.VertexUV0, "Byte"));
            }

            void SetUvTypeTypeShort(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TextureCoordsComponentType = Runtime.MeshPrimitive.TextureCoordsComponentTypeEnum.NORMALIZED_USHORT;
                properties.Add(new Property(PropertyName.VertexUV0, "Short"));
            }

            void SetColorTypeFloat(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.FLOAT;
                meshPrimitive.ColorType          = Runtime.MeshPrimitive.ColorTypeEnum.VEC3;
                properties.Add(new Property(PropertyName.VertexColor, "Vector3 Float"));
            }

            void SetColorTypeByte(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.NORMALIZED_UBYTE;
                meshPrimitive.ColorType          = Runtime.MeshPrimitive.ColorTypeEnum.VEC3;
                properties.Add(new Property(PropertyName.VertexColor, "Vector3 Byte"));
            }

            void SetColorTypeShort(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.ColorComponentType = Runtime.MeshPrimitive.ColorComponentTypeEnum.NORMALIZED_USHORT;
                meshPrimitive.ColorType          = Runtime.MeshPrimitive.ColorTypeEnum.VEC3;
                properties.Add(new Property(PropertyName.VertexColor, "Vector3 Short"));
            }

            this.Models = new List <Model>
            {
                CreateModel((properties, meshPrimitive) => {
                    SetUvTypeFloat(properties, meshPrimitive);
                    SetColorTypeFloat(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) => {
                    SetUvTypeFloat(properties, meshPrimitive);
                    SetColorTypeByte(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) => {
                    SetUvTypeFloat(properties, meshPrimitive);
                    SetColorTypeShort(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) => {
                    SetUvTypeTypeByte(properties, meshPrimitive);
                    SetColorTypeFloat(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) => {
                    SetUvTypeTypeShort(properties, meshPrimitive);
                    SetColorTypeFloat(properties, meshPrimitive);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 3
0
        public Material_DoubleSided(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane");
            Runtime.Image normalImage           = UseTexture(imageList, "Normal_Plane");

            // Track the common properties for use in the readme.
            var doubleSidedValue = true;

            CommonProperties.Add(new Property(PropertyName.DoubleSided, doubleSidedValue.ToString()));
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString()));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive> setProperties)
            {
                var properties    = new List <Property>();
                var meshPrimitive = MeshPrimitive.CreateSinglePlane();

                meshPrimitive.Material = new Runtime.Material();
                meshPrimitive.Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();

                // Apply the common properties to the gltf.
                meshPrimitive.Material.DoubleSided = doubleSidedValue;
                meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture {
                    Source = baseColorTextureImage
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive);

                // 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 SetVertexNormal(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                var planeNormalsValue = MeshPrimitive.GetSinglePlaneNormals();

                meshPrimitive.Normals = planeNormalsValue;
                properties.Add(new Property(PropertyName.VertexNormal, planeNormalsValue.ToReadmeString()));
            }

            void SetVertexTangent(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                var planeTangentValue = MeshPrimitive.GetSinglePlaneTangents();

                meshPrimitive.Tangents = planeTangentValue;
                properties.Add(new Property(PropertyName.VertexTangent, planeTangentValue.ToReadmeString()));
            }

            void SetNormalTexture(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Material.NormalTexture = new Runtime.Texture {
                    Source = normalImage
                };
                properties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString()));
            }

            Models = new List <Model>
            {
                CreateModel((properties, meshPrimitive) =>
                {
                    // There are no properties set on this model.
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexNormal(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexNormal(properties, meshPrimitive);
                    SetNormalTexture(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexNormal(properties, meshPrimitive);
                    SetVertexTangent(properties, meshPrimitive);
                    SetNormalTexture(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetNormalTexture(properties, meshPrimitive);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 4
0
        public Material_AlphaBlend(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane");

            // Track the common properties for use in the readme.
            var alphaModeValue = AlphaModeEnum.BLEND;

            CommonProperties.Add(new Property(PropertyName.AlphaMode, alphaModeValue));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.PbrMetallicRoughness> setProperties)
            {
                var properties = new List <Property>();

                Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane(includeTextureCoords: false);

                // Apply the common properties to the gltf.
                meshPrimitive.Material = new Runtime.Material
                {
                    MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness
                    {
                        MetallicFactor = 0
                    },
                    AlphaMode = alphaModeValue,
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive, meshPrimitive.Material.MetallicRoughnessMaterial);

                // Create the gltf object.
                return(new Model
                {
                    Properties = properties,
                    GLTF = CreateGLTF(() => new Runtime.Scene
                    {
                        Nodes = new[]
                        {
                            new Runtime.Node
                            {
                                Mesh = new Runtime.Mesh
                                {
                                    MeshPrimitives = new[]
                                    {
                                        meshPrimitive
                                    }
                                },
                            },
                        },
                    }),
                });
            }

            void SetNoMetallicRoughness(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Material.MetallicRoughnessMaterial = null;
            }

            void SetBaseColorFactor(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness)
            {
                var baseColorFactorValue = new Vector4(1.0f, 1.0f, 1.0f, 0.7f);

                metallicRoughness.BaseColorFactor = baseColorFactorValue;
                properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue));
            }

            void SetBaseColorTexture(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness)
            {
                metallicRoughness.BaseColorTexture = new Runtime.Texture {
                    Source = baseColorTextureImage
                };
                properties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));
            }

            void SetVertexColor(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                var vertexColors = new[]
                {
                    new Vector4(0.3f, 0.3f, 0.3f, 0.4f),
                    new Vector4(0.3f, 0.3f, 0.3f, 0.2f),
                    new Vector4(0.3f, 0.3f, 0.3f, 0.8f),
                    new Vector4(0.3f, 0.3f, 0.3f, 0.6f),
                };

                meshPrimitive.ColorComponentType = ColorComponentTypeEnum.FLOAT;
                meshPrimitive.ColorType          = ColorTypeEnum.VEC4;
                meshPrimitive.Colors             = vertexColors;

                properties.Add(new Property(PropertyName.VertexColor, "Vector4 Float"));
            }

            Models = new List <Model>
            {
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    SetVertexColor(properties, meshPrimitive);
                    SetNoMetallicRoughness(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets();
                    SetBaseColorTexture(properties, metallicRoughness);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    SetBaseColorFactor(properties, metallicRoughness);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets();
                    SetVertexColor(properties, meshPrimitive);
                    SetBaseColorTexture(properties, metallicRoughness);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    SetVertexColor(properties, meshPrimitive);
                    SetBaseColorFactor(properties, metallicRoughness);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets();
                    SetBaseColorTexture(properties, metallicRoughness);
                    SetBaseColorFactor(properties, metallicRoughness);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    meshPrimitive.TextureCoordSets = MeshPrimitive.GetSinglePlaneTextureCoordSets();
                    SetVertexColor(properties, meshPrimitive);
                    SetBaseColorTexture(properties, metallicRoughness);
                    SetBaseColorFactor(properties, metallicRoughness);
                }),
            };

            GenerateUsedPropertiesList();
        }
        public Material_SpecularGlossiness(List <string> imageList)
        {
            Runtime.Image diffuseTextureImage            = UseTexture(imageList, "Diffuse_Plane");
            Runtime.Image specularGlossinessTextureImage = UseTexture(imageList, "SpecularGlossiness_Plane");
            Runtime.Image baseColorTextureImage          = UseTexture(imageList, "BaseColor_X");

            // Track the common properties for use in the readme.
            CommonProperties.Add(new Property(PropertyName.ExtensionUsed, "Specular Glossiness"));
            CommonProperties.Add(new Property(PropertyName.ExtensionRequired, "Specular Glossiness"));
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.Material, KHR_materials_pbrSpecularGlossiness> setProperties)
            {
                var properties    = new List <Property>();
                var meshPrimitive = MeshPrimitive.CreateSinglePlane();
                var extension     = new KHR_materials_pbrSpecularGlossiness();

                meshPrimitive.Material            = new Runtime.Material();
                meshPrimitive.Material.Extensions = new List <Extension> {
                    extension
                };
                meshPrimitive.Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();

                // Apply the common properties to the gltf.
                meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture {
                    Source = baseColorTextureImage
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive, meshPrimitive.Material, extension);

                // Create the gltf object.
                return(new Model
                {
                    Properties = properties,
                    GLTF = CreateGLTF(() => new Runtime.Scene
                    {
                        Nodes = new[]
                        {
                            new Runtime.Node
                            {
                                Mesh = new Runtime.Mesh
                                {
                                    MeshPrimitives = new[]
                                    {
                                        meshPrimitive
                                    }
                                },
                            },
                        },
                    },
                                      extensionsUsed: new List <string> {
                        "KHR_materials_pbrSpecularGlossiness"
                    },
                                      extensionsRequired: new List <string> {
                        "KHR_materials_pbrSpecularGlossiness"
                    }),
                });
            }

            void SetVertexColor(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                var vertexColors = new[]
                {
                    new Vector4(0.0f, 0.0f, 1.0f, 0.8f),
                    new Vector4(1.0f, 0.0f, 0.0f, 0.8f),
                    new Vector4(0.0f, 0.0f, 1.0f, 0.8f),
                    new Vector4(1.0f, 0.0f, 0.0f, 0.8f)
                };

                meshPrimitive.ColorComponentType = ColorComponentTypeEnum.FLOAT;
                meshPrimitive.ColorType          = ColorTypeEnum.VEC3;
                meshPrimitive.Colors             = vertexColors;

                properties.Add(new Property(PropertyName.VertexColor, "Vector3 Float"));
            }

            void SetDiffuseTexture(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension)
            {
                extension.DiffuseTexture = new Runtime.Texture {
                    Source = diffuseTextureImage
                };
                properties.Add(new Property(PropertyName.DiffuseTexture, diffuseTextureImage));
            }

            void SetDiffuseFactor(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension)
            {
                var diffuseFactorValue = new Vector4(0.2f, 0.2f, 0.2f, 0.8f);

                extension.DiffuseFactor = diffuseFactorValue;
                properties.Add(new Property(PropertyName.DiffuseFactor, diffuseFactorValue));
            }

            void SetSpecularGlossinessTexture(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension)
            {
                extension.SpecularGlossinessTexture = new Runtime.Texture {
                    Source = specularGlossinessTextureImage
                };
                properties.Add(new Property(PropertyName.SpecularGlossinessTexture, specularGlossinessTextureImage));
            }

            void SetSpecularFactor(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension)
            {
                var specularFactorValue = new Vector3(0.4f, 0.4f, 0.4f);

                extension.SpecularFactor = specularFactorValue;
                properties.Add(new Property(PropertyName.SpecularFactor, specularFactorValue));
            }

            void SetSpecularFactorToZero(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension)
            {
                var specularFactorValue = new Vector3(0.0f, 0.0f, 0.0f);

                extension.SpecularFactor = specularFactorValue;
                properties.Add(new Property(PropertyName.SpecularFactor, specularFactorValue));
            }

            void SetGlossinessFactor(List <Property> properties, KHR_materials_pbrSpecularGlossiness extension)
            {
                extension.GlossinessFactor = 0.3f;
                properties.Add(new Property(PropertyName.GlossinessFactor, extension.GlossinessFactor));
            }

            Models = new List <Model>
            {
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    // There are no properties set on this model.
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetVertexColor(properties, meshPrimitive);
                    SetSpecularFactorToZero(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetDiffuseTexture(properties, extension);
                    SetSpecularFactorToZero(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetDiffuseFactor(properties, extension);
                    SetSpecularFactorToZero(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetSpecularGlossinessTexture(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetSpecularFactor(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetGlossinessFactor(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetVertexColor(properties, meshPrimitive);
                    SetDiffuseTexture(properties, extension);
                    SetSpecularFactorToZero(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetDiffuseTexture(properties, extension);
                    SetDiffuseFactor(properties, extension);
                    SetSpecularFactorToZero(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetDiffuseTexture(properties, extension);
                    SetGlossinessFactor(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetSpecularGlossinessTexture(properties, extension);
                    SetSpecularFactor(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetSpecularGlossinessTexture(properties, extension);
                    SetGlossinessFactor(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetDiffuseTexture(properties, extension);
                    SetSpecularFactor(properties, extension);
                    SetGlossinessFactor(properties, extension);
                }),
                CreateModel((properties, meshPrimitive, material, extension) =>
                {
                    SetVertexColor(properties, meshPrimitive);
                    SetDiffuseTexture(properties, extension);
                    SetDiffuseFactor(properties, extension);
                    SetSpecularGlossinessTexture(properties, extension);
                    SetSpecularFactor(properties, extension);
                    SetGlossinessFactor(properties, extension);
                }),
            };

            GenerateUsedPropertiesList();
        }
        public Material_AlphaMask(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane");

            // Track the common properties for use in the readme.
            var alphaModeValue = AlphaModeEnum.MASK;

            CommonProperties.Add(new Property(PropertyName.AlphaMode, alphaModeValue));
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));

            Model CreateModel(Action <List <Property>, Runtime.Material, Runtime.PbrMetallicRoughness> setProperties)
            {
                var properties    = new List <Property>();
                var meshPrimitive = MeshPrimitive.CreateSinglePlane();

                meshPrimitive.Material = new Runtime.Material();
                meshPrimitive.Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();

                // Apply the common properties to the gltf.
                meshPrimitive.Material.AlphaMode = alphaModeValue;
                meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture {
                    Source = baseColorTextureImage
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive.Material, meshPrimitive.Material.MetallicRoughnessMaterial);

                // Create the gltf object.
                return(new Model
                {
                    Properties = properties,
                    GLTF = CreateGLTF(() => new Runtime.Scene
                    {
                        Nodes = new[]
                        {
                            new Runtime.Node
                            {
                                Mesh = new Runtime.Mesh
                                {
                                    MeshPrimitives = new List <Runtime.MeshPrimitive>
                                    {
                                        meshPrimitive
                                    }
                                },
                            },
                        },
                    }),
                });
            }

            void SetAlphaCutoff_Low(List <Property> properties, Runtime.Material material)
            {
                material.AlphaCutoff = 0.4f;
                properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff));
            }

            void SetAlphaCutoff_High(List <Property> properties, Runtime.Material material)
            {
                material.AlphaCutoff = 0.7f;
                properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff));
            }

            void SetAlphaCutoff_Multiplied(List <Property> properties, Runtime.Material material)
            {
                material.AlphaCutoff = 0.6f;
                properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff));
            }

            void SetAlphaCutoff_All(List <Property> properties, Runtime.Material material)
            {
                material.AlphaCutoff = 1.1f;
                properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff));
            }

            void SetAlphaCutoff_None(List <Property> properties, Runtime.Material material)
            {
                material.AlphaCutoff = 0.0f;
                properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff));
            }

            void SetBaseColorFactor(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness)
            {
                var baseColorFactorValue = new Vector4(1.0f, 1.0f, 1.0f, 0.7f);

                metallicRoughness.BaseColorFactor = baseColorFactorValue;
                properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue));
            }

            Models = new List <Model>
            {
                CreateModel((properties, material, metallicRoughness) =>
                {
                    // There are no properties set on this model.
                }),
                CreateModel((properties, material, metallicRoughness) =>
                {
                    SetAlphaCutoff_Low(properties, material);
                }),
                CreateModel((properties, material, metallicRoughness) =>
                {
                    SetAlphaCutoff_High(properties, material);
                }),
                CreateModel((properties, material, metallicRoughness) =>
                {
                    SetAlphaCutoff_All(properties, material);
                }),
                CreateModel((properties, material, metallicRoughness) =>
                {
                    SetAlphaCutoff_None(properties, material);
                }),
                CreateModel((properties, material, metallicRoughness) =>
                {
                    SetAlphaCutoff_Low(properties, material);
                    SetBaseColorFactor(properties, metallicRoughness);
                }),
                CreateModel((properties, material, metallicRoughness) =>
                {
                    SetAlphaCutoff_Multiplied(properties, material);
                    SetBaseColorFactor(properties, metallicRoughness);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 7
0
        public Texture_Sampler(List <string> imageList)
        {
            var baseColorImage = UseTexture(imageList, "BaseColor_Plane");

            // Track the common properties for use in the readme.
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorImage.ToReadmeString()));

            Model CreateModel(Action <List <Property>, Runtime.Sampler> setProperties)
            {
                var properties = new List <Property>();

                Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane();
                meshPrimitive.Material = new Runtime.Material
                {
                    PbrMetallicRoughness = new Runtime.PbrMetallicRoughness
                    {
                        BaseColorTexture = new Runtime.TextureInfo
                        {
                            Texture = new Runtime.Texture
                            {
                                Source  = baseColorImage,
                                Sampler = new Runtime.Sampler()
                            }
                        },
                    },
                };

                // Apply the common properties to the gltf.
                meshPrimitive.TexCoords0 = Runtime.Data.Create
                                           (
                    new[]
                {
                    new Vector2(1.3f, 1.3f),
                    new Vector2(-0.3f, 1.3f),
                    new Vector2(-0.3f, -0.3f),
                    new Vector2(1.3f, -0.3f)
                }
                                           );

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive.Material.PbrMetallicRoughness.BaseColorTexture.Texture.Sampler);

                // 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 SetWrapT(List <Property> properties, Runtime.Sampler sampler, Runtime.SamplerWrap enumValue)
            {
                sampler.WrapT = enumValue;
                properties.Add(new Property(PropertyName.WrapT, enumValue.ToReadmeString()));
            }

            void SetWrapS(List <Property> properties, Runtime.Sampler sampler, Runtime.SamplerWrap enumValue)
            {
                sampler.WrapS = enumValue;
                properties.Add(new Property(PropertyName.WrapS, sampler.WrapS.ToReadmeString()));
            }

            void SetMagFilter(List <Property> properties, Runtime.Sampler sampler, Runtime.SamplerMagFilter enumValue)
            {
                sampler.MagFilter = enumValue;
                properties.Add(new Property(PropertyName.MagFilter, enumValue.ToReadmeString()));
            }

            void SetMinFilter(List <Property> properties, Runtime.Sampler sampler, Runtime.SamplerMinFilter enumValue)
            {
                sampler.MinFilter = enumValue;
                properties.Add(new Property(PropertyName.MinFilter, enumValue.ToReadmeString()));
            }

            Models = new List <Model>
            {
                CreateModel((properties, sampler) =>
                {
                    // There are no properties set on this model.
                }),
                CreateModel((properties, sampler) =>
                {
                    SetWrapT(properties, sampler, Runtime.SamplerWrap.ClampToEdge);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetWrapT(properties, sampler, Runtime.SamplerWrap.MirroredRepeat);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetWrapS(properties, sampler, Runtime.SamplerWrap.ClampToEdge);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetWrapS(properties, sampler, Runtime.SamplerWrap.MirroredRepeat);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMagFilter(properties, sampler, Runtime.SamplerMagFilter.Nearest);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMagFilter(properties, sampler, Runtime.SamplerMagFilter.Linear);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, Runtime.SamplerMinFilter.Nearest);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, Runtime.SamplerMinFilter.Linear);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, Runtime.SamplerMinFilter.NearestMipmapNearest);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, Runtime.SamplerMinFilter.LinearMipmapNearest);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, Runtime.SamplerMinFilter.NearestMipmapLinear);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, Runtime.SamplerMinFilter.LinearMipmapLinear);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetWrapT(properties, sampler, Runtime.SamplerWrap.ClampToEdge);
                    SetWrapS(properties, sampler, Runtime.SamplerWrap.ClampToEdge);
                    SetMagFilter(properties, sampler, Runtime.SamplerMagFilter.Nearest);
                    SetMinFilter(properties, sampler, Runtime.SamplerMinFilter.Nearest);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 8
0
        public Material_AlphaBlend(List <string> imageList)
        {
            var baseColorTexture = new Texture {
                Source = UseTexture(imageList, "BaseColor_Plane")
            };

            // Track the common properties for use in the readme.
            CommonProperties.Add(new Property(PropertyName.AlphaMode, MaterialAlphaMode.Blend.ToReadmeString()));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, PbrMetallicRoughness> setProperties)
            {
                var properties = new List <Property>();

                Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane(includeTextureCoords: false);

                // Apply the common properties to the gltf.
                meshPrimitive.Material = new Runtime.Material
                {
                    PbrMetallicRoughness = new PbrMetallicRoughness
                    {
                        MetallicFactor = 0
                    },
                    AlphaMode = MaterialAlphaMode.Blend,
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive, meshPrimitive.Material.PbrMetallicRoughness);

                // Create the gltf object.
                return(new Model
                {
                    Properties = properties,
                    GLTF = CreateGLTF(() => new Scene
                    {
                        Nodes = new[]
                        {
                            new Node
                            {
                                Mesh = new Runtime.Mesh
                                {
                                    MeshPrimitives = new[]
                                    {
                                        meshPrimitive
                                    }
                                },
                            },
                        },
                    }),
                });
            }

            void SetNoMetallicRoughness(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Material.PbrMetallicRoughness = null;
            }

            void SetBaseColorFactor(List <Property> properties, PbrMetallicRoughness metallicRoughness)
            {
                var baseColorFactorValue = new Vector4(1.0f, 1.0f, 1.0f, 0.7f);

                metallicRoughness.BaseColorFactor = baseColorFactorValue;
                properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue.ToReadmeString()));
            }

            void SetBaseColorTexture(List <Property> properties, PbrMetallicRoughness metallicRoughness)
            {
                metallicRoughness.BaseColorTexture = new TextureInfo {
                    Texture = baseColorTexture
                };
                properties.Add(new Property(PropertyName.BaseColorTexture, baseColorTexture.Source.ToReadmeString()));
            }

            void SetVertexColor(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Colors = Data.Create
                                       (
                    new[]
                {
                    new Vector4(0.3f, 0.3f, 0.3f, 0.4f),
                    new Vector4(0.3f, 0.3f, 0.3f, 0.2f),
                    new Vector4(0.3f, 0.3f, 0.3f, 0.8f),
                    new Vector4(0.3f, 0.3f, 0.3f, 0.6f),
                }
                                       );

                properties.Add(new Property(PropertyName.VertexColor, $"Vector4 Float"));
            }

            Models = new List <Model>
            {
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    SetVertexColor(properties, meshPrimitive);
                    SetNoMetallicRoughness(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    meshPrimitive.TexCoords0 = Data.Create(MeshPrimitive.GetSinglePlaneTexCoords());
                    SetBaseColorTexture(properties, metallicRoughness);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    SetBaseColorFactor(properties, metallicRoughness);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    meshPrimitive.TexCoords0 = Data.Create(MeshPrimitive.GetSinglePlaneTexCoords());
                    SetVertexColor(properties, meshPrimitive);
                    SetBaseColorTexture(properties, metallicRoughness);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    SetVertexColor(properties, meshPrimitive);
                    SetBaseColorFactor(properties, metallicRoughness);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    meshPrimitive.TexCoords0 = Data.Create(MeshPrimitive.GetSinglePlaneTexCoords());
                    SetBaseColorTexture(properties, metallicRoughness);
                    SetBaseColorFactor(properties, metallicRoughness);
                }),
                CreateModel((properties, meshPrimitive, metallicRoughness) =>
                {
                    meshPrimitive.TexCoords0 = Data.Create(MeshPrimitive.GetSinglePlaneTexCoords());
                    SetVertexColor(properties, meshPrimitive);
                    SetBaseColorTexture(properties, metallicRoughness);
                    SetBaseColorFactor(properties, metallicRoughness);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 9
0
        public Animation_SamplerType(List <string> imageList)
        {
            var baseColorTexture = new Texture {
                Source = UseTexture(imageList, "BaseColor_Cube")
            };

            CommonProperties.Add(new Property(PropertyName.Target, "Rotation"));
            CommonProperties.Add(new Property(PropertyName.Interpolation, "Linear"));

            Model CreateModel(DataType outputType)
            {
                var properties        = new List <Property>();
                var cubeMeshPrimitive = MeshPrimitive.CreateCube();

                // Apply the common properties to the gltf.
                cubeMeshPrimitive.Material = new Runtime.Material
                {
                    PbrMetallicRoughness = new PbrMetallicRoughness
                    {
                        BaseColorTexture = new TextureInfo {
                            Texture = baseColorTexture
                        },
                    },
                };
                var node = new Node
                {
                    Mesh = new Runtime.Mesh
                    {
                        MeshPrimitives = new[]
                        {
                            cubeMeshPrimitive
                        }
                    }
                };
                var channel = new AnimationChannel
                {
                    Target = new AnimationChannelTarget
                    {
                        Node = node,
                        Path = AnimationChannelTargetPath.Rotation,
                    },
                    Sampler = new AnimationSampler
                    {
                        Interpolation = AnimationSamplerInterpolation.Linear,
                        Input         = Data.Create(new[]
                        {
                            0.0f,
                            1.0f,
                            2.0f,
                            3.0f,
                            4.0f,
                        }),
                        Output = Data.Create(new[]
                        {
                            Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                            Quaternion.Identity,
                            Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(-90.0f), 0.0f, 0.0f),
                            Quaternion.Identity,
                            Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                        }, outputType),
                    },
                };

                // Apply the properties that are specific to this gltf.
                properties.Add(new Property(PropertyName.SamplerOutputComponentType, outputType.ToReadmeString()));

                // Create the gltf object.
                GLTF gltf = CreateGLTF(() => new Scene
                {
                    Nodes = new[]
                    {
                        node
                    },
                });

                gltf.Animations = new[]
                {
                    new Animation
                    {
                        Channels = new List <AnimationChannel>
                        {
                            channel
                        }
                    }
                };
                return(new Model
                {
                    Properties = properties,
                    GLTF = gltf,
                    Animated = true,
                });
            }

            Models = new List <Model>
            {
                CreateModel(DataType.Float),
                CreateModel(DataType.NormalizedByte),
                CreateModel(DataType.NormalizedShort),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 10
0
        public Mesh_PrimitivesUV(List <string> imageList)
        {
            var baseColorTexture = new Texture {
                Source = UseTexture(imageList, "BaseColor_Plane")
            };
            var normalTexture = new Texture {
                Source = UseTexture(imageList, "Normal_Plane")
            };

            UseFigure(imageList, "Indices_Primitive0");
            UseFigure(imageList, "Indices_Primitive1");
            UseFigure(imageList, "UVSpace2");
            UseFigure(imageList, "UVSpace3");
            UseFigure(imageList, "UVSpace4");
            UseFigure(imageList, "UVSpace5");

            // Track the common properties for use in the readme.
            var normals = Data.Create(new[]
            {
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
            });
            var tangents = Data.Create(new[]
            {
                new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
            });
            var colors = Data.Create(new[]
            {
                new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
            });

            CommonProperties.Add(new Property(PropertyName.VertexNormal, normals.Values.ToReadmeString()));
            CommonProperties.Add(new Property(PropertyName.VertexTangent, tangents.Values.ToReadmeString()));
            CommonProperties.Add(new Property(PropertyName.VertexColor, colors.Values.ToReadmeString()));
            CommonProperties.Add(new Property(PropertyName.NormalTexture, normalTexture.Source.ToReadmeString()));
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTexture.Source.ToReadmeString()));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.MeshPrimitive> setProperties)
            {
                var properties = new List <Property>();
                List <Runtime.MeshPrimitive> meshPrimitives = MeshPrimitive.CreateMultiPrimitivePlane(false);

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitives[0], meshPrimitives[1]);

                // Create the gltf object
                return(new Model
                {
                    Properties = properties,
                    GLTF = CreateGLTF(() => new Scene
                    {
                        Nodes = new List <Node>
                        {
                            new Node
                            {
                                Mesh = new Runtime.Mesh
                                {
                                    MeshPrimitives = meshPrimitives
                                },
                            },
                        },
                    }),
                });
            }

            void SetCommonProperties(Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Normals  = normals;
                meshPrimitive.Tangents = tangents;
                meshPrimitive.Colors   = colors;

                meshPrimitive.Material = new Runtime.Material
                {
                    NormalTexture = new NormalTextureInfo {
                        Texture = normalTexture
                    },
                    PbrMetallicRoughness = new PbrMetallicRoughness
                    {
                        BaseColorTexture = new TextureInfo {
                            Texture = baseColorTexture
                        },
                        MetallicFactor = 0,
                    }
                };
            }

            void SetPrimitive0VertexUV0(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                SetCommonProperties(meshPrimitive);
                meshPrimitive.TexCoords0 = Data.Create
                                           (
                    new[]
                {
                    new Vector2(0.0f, 1.0f),
                    new Vector2(1.0f, 0.0f),
                    new Vector2(0.0f, 0.0f),
                }
                                           );
                properties.Add(new Property(PropertyName.Primitive0VertexUV0, ":white_check_mark:"));
            }

            void SetPrimitive0VertexUV1(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Material.PbrMetallicRoughness.BaseColorTexture.TexCoord = 1;
                meshPrimitive.Material.NormalTexture.TexCoord = 1;
                meshPrimitive.TexCoords1 = Data.Create
                                           (
                    new[]
                {
                    new Vector2(0.5f, 0.5f),
                    new Vector2(1.0f, 0.0f),
                    new Vector2(0.5f, 0.0f),
                }
                                           );
                properties.Add(new Property(PropertyName.Primitive0VertexUV1, ":white_check_mark:"));
            }

            void SetPrimitive1VertexUV0(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                SetCommonProperties(meshPrimitive);
                meshPrimitive.TexCoords0 = Data.Create(new[]
                {
                    new Vector2(0.0f, 1.0f),
                    new Vector2(1.0f, 1.0f),
                    new Vector2(1.0f, 0.0f),
                });
                properties.Add(new Property(PropertyName.Primitive1VertexUV0, ":white_check_mark:"));
            }

            void SetPrimitive1VertexUV1(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Material.PbrMetallicRoughness.BaseColorTexture.TexCoord = 1;
                meshPrimitive.Material.NormalTexture.TexCoord = 1;
                meshPrimitive.TexCoords1 = Data.Create(new[]
                {
                    new Vector2(0.5f, 0.5f),
                    new Vector2(1.0f, 0.5f),
                    new Vector2(1.0f, 0.0f),
                });
                properties.Add(new Property(PropertyName.Primitive1VertexUV1, ":white_check_mark:"));
            }

            Models = new List <Model>
            {
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) =>
                {
                    // do nothing
                }),
                CreateModel((properties, meshPrimitive0, meshPrimitive1) =>
                {
                    SetPrimitive0VertexUV0(properties, meshPrimitive0);
                }),
                CreateModel((properties, meshPrimitive0, meshPrimitive1) =>
                {
                    SetPrimitive1VertexUV0(properties, meshPrimitive1);
                }),
                CreateModel((properties, meshPrimitive0, meshPrimitive1) =>
                {
                    SetPrimitive0VertexUV0(properties, meshPrimitive0);
                    SetPrimitive1VertexUV0(properties, meshPrimitive1);
                }),
                CreateModel((properties, meshPrimitive0, meshPrimitive1) =>
                {
                    SetPrimitive0VertexUV0(properties, meshPrimitive0);
                    SetPrimitive0VertexUV1(properties, meshPrimitive0);
                }),
                CreateModel((properties, meshPrimitive0, meshPrimitive1) =>
                {
                    SetPrimitive1VertexUV0(properties, meshPrimitive1);
                    SetPrimitive1VertexUV1(properties, meshPrimitive1);
                }),
                CreateModel((properties, meshPrimitive0, meshPrimitive1) =>
                {
                    SetPrimitive0VertexUV0(properties, meshPrimitive0);
                    SetPrimitive1VertexUV0(properties, meshPrimitive1);
                    SetPrimitive1VertexUV1(properties, meshPrimitive1);
                }),
                CreateModel((properties, meshPrimitive0, meshPrimitive1) =>
                {
                    SetPrimitive0VertexUV0(properties, meshPrimitive0);
                    SetPrimitive0VertexUV1(properties, meshPrimitive0);
                    SetPrimitive1VertexUV0(properties, meshPrimitive1);
                }),
                CreateModel((properties, meshPrimitive0, meshPrimitive1) =>
                {
                    SetPrimitive0VertexUV0(properties, meshPrimitive0);
                    SetPrimitive1VertexUV0(properties, meshPrimitive1);
                    SetPrimitive0VertexUV1(properties, meshPrimitive0);
                    SetPrimitive1VertexUV1(properties, meshPrimitive1);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 11
0
        public Material(List <string> imageList)
        {
            Runtime.Image emissiveImage  = UseTexture(imageList, "Emissive_Plane");
            Runtime.Image normalImage    = UseTexture(imageList, "Normal_Plane");
            Runtime.Image occlusionImage = UseTexture(imageList, "Occlusion_Plane");

            // Track the common properties for use in the readme.
            var metallicFactorValue  = 0.0f;
            var baseColorFactorValue = new Vector4(0.2f, 0.2f, 0.2f, 1.0f);

            CommonProperties.Add(new Property(PropertyName.MetallicFactor, metallicFactorValue));
            CommonProperties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.Material> setProperties)
            {
                var properties = new List <Property>();

                Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane();
                meshPrimitive.Material = new Runtime.Material();
                meshPrimitive.Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();

                // Apply the common properties to the gltf.
                meshPrimitive.Material.MetallicRoughnessMaterial.MetallicFactor  = metallicFactorValue;
                meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorFactor = baseColorFactorValue;

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive, 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 SetNormalTexture(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                var planeNormalsValue = new[]
                {
                    new Vector3(0.0f, 0.0f, 1.0f),
                    new Vector3(0.0f, 0.0f, 1.0f),
                    new Vector3(0.0f, 0.0f, 1.0f),
                    new Vector3(0.0f, 0.0f, 1.0f),
                };

                meshPrimitive.Normals = planeNormalsValue;
                meshPrimitive.Material.NormalTexture = new Runtime.Texture {
                    Source = normalImage
                };
                properties.Add(new Property(PropertyName.NormalTexture, normalImage));
            }

            void SetNormalScale(List <Property> properties, Runtime.Material material)
            {
                material.NormalScale = 10.0f;
                properties.Add(new Property(PropertyName.NormalTextureScale, material.NormalScale));
            }

            void SetOcclusionTexture(List <Property> properties, Runtime.Material material)
            {
                material.OcclusionTexture = new Runtime.Texture {
                    Source = occlusionImage
                };
                properties.Add(new Property(PropertyName.OcclusionTexture, occlusionImage));
            }

            void SetOcclusionStrength(List <Property> properties, Runtime.Material material)
            {
                material.OcclusionStrength = 0.5f;
                properties.Add(new Property(PropertyName.OcclusionTextureStrength, material.OcclusionStrength));
            }

            void SetEmissiveTexture(List <Property> properties, Runtime.Material material)
            {
                material.EmissiveTexture = new Runtime.Texture {
                    Source = emissiveImage
                };
                properties.Add(new Property(PropertyName.EmissiveTexture, emissiveImage));
            }

            void SetEmissiveFactor(List <Property> properties, Runtime.Material material)
            {
                var emissiveFactorValue = new Vector3(1.0f, 1.0f, 1.0f);

                material.EmissiveFactor = emissiveFactorValue;
                properties.Add(new Property(PropertyName.EmissiveFactor, emissiveFactorValue));
            }

            Models = new List <Model>
            {
                CreateModel((properties, meshPrimitive, material) => {
                    // There are no properties set on this model.
                }),
                CreateModel((properties, meshPrimitive, material) => {
                    SetNormalTexture(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive, material) => {
                    SetOcclusionTexture(properties, material);
                }),
                CreateModel((properties, meshPrimitive, material) => {
                    SetEmissiveFactor(properties, material);
                }),
                CreateModel((properties, meshPrimitive, material) => {
                    SetNormalTexture(properties, meshPrimitive);
                    SetNormalScale(properties, material);
                }),
                CreateModel((properties, meshPrimitive, material) => {
                    SetOcclusionTexture(properties, material);
                    SetOcclusionStrength(properties, material);
                }),
                CreateModel((properties, meshPrimitive, material) => {
                    SetEmissiveTexture(properties, material);
                    SetEmissiveFactor(properties, material);
                }),
                CreateModel((properties, meshPrimitive, material) => {
                    SetNormalTexture(properties, meshPrimitive);
                    SetNormalScale(properties, material);
                    SetOcclusionTexture(properties, material);
                    SetOcclusionStrength(properties, material);
                    SetEmissiveTexture(properties, material);
                    SetEmissiveFactor(properties, material);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 12
0
        public Texture_Sampler(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane");

            // Track the common properties for use in the readme.
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));

            Model CreateModel(Action <List <Property>, Runtime.Sampler> setProperties)
            {
                var properties = new List <Property>();

                Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane();
                meshPrimitive.Material = new Runtime.Material
                {
                    MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness
                    {
                        BaseColorTexture = new Runtime.Texture
                        {
                            Source  = baseColorTextureImage,
                            Sampler = new Runtime.Sampler(),
                        },
                    },
                };

                // Apply the common properties to the gltf.
                meshPrimitive.TextureCoordSets = new List <List <Vector2> >
                {
                    new List <Vector2>()
                    {
                        new Vector2(1.3f, 1.3f),
                        new Vector2(-0.3f, 1.3f),
                        new Vector2(-0.3f, -0.3f),
                        new Vector2(1.3f, -0.3f),
                    }
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture.Sampler);

                // 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 SetWrapT(List <Property> properties, Runtime.Sampler sampler, WrapTEnum enumValue)
            {
                sampler.WrapT = enumValue;
                properties.Add(new Property(PropertyName.WrapT, enumValue));
            }

            void SetWrapS(List <Property> properties, Runtime.Sampler sampler, WrapSEnum enumValue)
            {
                sampler.WrapS = enumValue;
                properties.Add(new Property(PropertyName.WrapS, sampler.WrapS));
            }

            void SetMagFilter(List <Property> properties, Runtime.Sampler sampler, MagFilterEnum enumValue)
            {
                sampler.MagFilter = enumValue;
                properties.Add(new Property(PropertyName.MagFilter, enumValue));
            }

            void SetMinFilter(List <Property> properties, Runtime.Sampler sampler, MinFilterEnum enumValue)
            {
                sampler.MinFilter = enumValue;
                properties.Add(new Property(PropertyName.MinFilter, enumValue));
            }

            Models = new List <Model>
            {
                CreateModel((properties, sampler) =>
                {
                    // There are no properties set on this model.
                }),
                CreateModel((properties, sampler) =>
                {
                    SetWrapT(properties, sampler, WrapTEnum.CLAMP_TO_EDGE);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetWrapT(properties, sampler, WrapTEnum.MIRRORED_REPEAT);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetWrapS(properties, sampler, WrapSEnum.CLAMP_TO_EDGE);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetWrapS(properties, sampler, WrapSEnum.MIRRORED_REPEAT);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMagFilter(properties, sampler, MagFilterEnum.NEAREST);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMagFilter(properties, sampler, MagFilterEnum.LINEAR);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, MinFilterEnum.NEAREST);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, MinFilterEnum.LINEAR);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, MinFilterEnum.NEAREST_MIPMAP_NEAREST);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, MinFilterEnum.LINEAR_MIPMAP_NEAREST);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, MinFilterEnum.NEAREST_MIPMAP_LINEAR);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetMinFilter(properties, sampler, MinFilterEnum.LINEAR_MIPMAP_LINEAR);
                }),
                CreateModel((properties, sampler) =>
                {
                    SetWrapT(properties, sampler, WrapTEnum.CLAMP_TO_EDGE);
                    SetWrapS(properties, sampler, WrapSEnum.CLAMP_TO_EDGE);
                    SetMagFilter(properties, sampler, MagFilterEnum.NEAREST);
                    SetMinFilter(properties, sampler, MinFilterEnum.NEAREST);
                }),
            };

            GenerateUsedPropertiesList();
        }
        public Animation_SamplerType(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Cube");

            CommonProperties.Add(new Property(PropertyName.Target, "Rotation"));
            CommonProperties.Add(new Property(PropertyName.Interpolation, "Linear"));

            Model CreateModel(AnimationSampler.ComponentTypeEnum samplerOutputComponentType, string samplerOutputComponentTypeDisplayValue)
            {
                var properties        = new List <Property>();
                var cubeMeshPrimitive = MeshPrimitive.CreateCube();

                // Apply the common properties to the gltf.
                cubeMeshPrimitive.Material = new Runtime.Material
                {
                    MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness
                    {
                        BaseColorTexture = new Runtime.Texture {
                            Source = baseColorTextureImage
                        },
                    },
                };
                var node = new Runtime.Node
                {
                    Mesh = new Runtime.Mesh
                    {
                        MeshPrimitives = new[]
                        {
                            cubeMeshPrimitive
                        }
                    }
                };
                var channel = new Runtime.AnimationChannel
                {
                    Target = new Runtime.AnimationChannelTarget
                    {
                        Node = node,
                        Path = Runtime.AnimationChannelTarget.PathEnum.ROTATION,
                    },
                    Sampler = new Runtime.LinearAnimationSampler <Quaternion>
                              (
                        new[]
                    {
                        0.0f,
                        1.0f,
                        2.0f,
                        3.0f,
                        4.0f,
                    },
                        new[]
                    {
                        Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                        Quaternion.Identity,
                        Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(-90.0f), 0.0f, 0.0f),
                        Quaternion.Identity,
                        Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                    },
                        outputComponentType: samplerOutputComponentType
                              )
                };

                // Apply the properties that are specific to this gltf.
                properties.Add(new Property(PropertyName.SamplerOutputComponentType, samplerOutputComponentTypeDisplayValue));

                // Create the gltf object.
                Runtime.GLTF gltf = CreateGLTF(() => new Runtime.Scene
                {
                    Nodes = new[]
                    {
                        node
                    },
                });
                gltf.Animations = new[]
                {
                    new Runtime.Animation
                    {
                        Channels = new List <Runtime.AnimationChannel>
                        {
                            channel
                        }
                    }
                };
                return(new Model
                {
                    Properties = properties,
                    GLTF = gltf,
                    Animated = true,
                });
            }

            Models = new List <Model>
            {
                CreateModel(AnimationSampler.ComponentTypeEnum.FLOAT, "Float"),
                CreateModel(AnimationSampler.ComponentTypeEnum.NORMALIZED_BYTE, "Byte"),
                CreateModel(AnimationSampler.ComponentTypeEnum.NORMALIZED_SHORT, "Short"),
            };

            GenerateUsedPropertiesList();
        }
        public Mesh_PrimitiveAttribute(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane");
            Runtime.Image normalImage           = UseTexture(imageList, "Normal_Plane");

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

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive> setProperties)
            {
                var properties    = new List <Property>();
                var meshPrimitive = MeshPrimitive.CreateSinglePlane();

                meshPrimitive.Material = new Runtime.Material();

                // Apply the common properties to the gltf.
                meshPrimitive.Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness
                {
                    BaseColorTexture = new Runtime.Texture
                    {
                        Source = baseColorTextureImage
                    }
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive);

                // 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 SetVertexUVFloat(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TextureCoordsComponentType = TextureCoordsComponentTypeEnum.FLOAT;
                properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TextureCoordsComponentType.ToReadmeString()));
            }

            void SetVertexUVByte(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TextureCoordsComponentType = TextureCoordsComponentTypeEnum.NORMALIZED_UBYTE;
                properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TextureCoordsComponentType.ToReadmeString()));
            }

            void SetVertexUVShort(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TextureCoordsComponentType = TextureCoordsComponentTypeEnum.NORMALIZED_USHORT;
                properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TextureCoordsComponentType.ToReadmeString()));
            }

            void SetVertexNormal(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                var planeNormalsValue = MeshPrimitive.GetSinglePlaneNormals();

                meshPrimitive.Normals = planeNormalsValue;
                properties.Add(new Property(PropertyName.VertexNormal, planeNormalsValue.ToReadmeString()));
            }

            void SetVertexTangent(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                var planeTangentValue = new List <Vector4>
                {
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f)
                };

                meshPrimitive.Tangents = planeTangentValue;
                properties.Add(new Property(PropertyName.VertexTangent, planeTangentValue.ToReadmeString()));
            }

            void SetNormalTexture(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Material.NormalTexture = new Runtime.Texture {
                    Source = normalImage
                };
                properties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString()));
            }

            Models = new List <Model>
            {
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVFloat(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVByte(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVShort(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVFloat(properties, meshPrimitive);
                    SetVertexNormal(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVFloat(properties, meshPrimitive);
                    SetNormalTexture(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVFloat(properties, meshPrimitive);
                    SetVertexNormal(properties, meshPrimitive);
                    SetNormalTexture(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetVertexUVFloat(properties, meshPrimitive);
                    SetVertexNormal(properties, meshPrimitive);
                    SetVertexTangent(properties, meshPrimitive);
                    SetNormalTexture(properties, meshPrimitive);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 15
0
        public Material_Mixed(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = 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, baseColorTextureImage));

            Model CreateModel(Action <List <Property>, Runtime.Material, Runtime.Material> setProperties)
            {
                var properties       = new List <Property>();
                var meshPrimitives   = MeshPrimitive.CreateMultiPrimitivePlane();
                var baseColorTexture = new Runtime.Texture {
                    Source = baseColorTextureImage
                };

                meshPrimitives[0].Material = new Runtime.Material();
                meshPrimitives[0].Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();
                meshPrimitives[1].Material = new Runtime.Material();
                meshPrimitives[1].Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness();

                // Apply the common properties to the gltf.
                meshPrimitives[0].Material.MetallicRoughnessMaterial.BaseColorTexture = baseColorTexture;
                meshPrimitives[1].Material.MetallicRoughnessMaterial.BaseColorTexture = baseColorTexture;

                // 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();
        }
Exemplo n.º 16
0
        public Mesh_Primitives(List <string> imageList)
        {
            UseFigure(imageList, "Indices_Primitive0");
            UseFigure(imageList, "Indices_Primitive1");

            // Track the common properties for use in the readme.
            var baseColorFactorGreen = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);
            var baseColorFactorBlue  = new Vector4(0.0f, 0.0f, 1.0f, 1.0f);

            CommonProperties.Add(new Property(PropertyName.Material0WithBaseColorFactor, baseColorFactorGreen));
            CommonProperties.Add(new Property(PropertyName.Material1WithBaseColorFactor, baseColorFactorBlue));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.MeshPrimitive> setProperties)
            {
                var properties     = new List <Property>();
                var meshPrimitives = MeshPrimitive.CreateMultiPrimitivePlane(includeTextureCoords: false);

                // There are no common properties in this model group.

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitives[0], meshPrimitives[1]);

                // 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 = meshPrimitives
                                },
                            },
                        },
                    }),
                });
            }

            void SetPrimitiveZeroGreen(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Material = new Runtime.Material()
                {
                    MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness()
                    {
                        BaseColorFactor = baseColorFactorGreen
                    }
                };

                properties.Add(new Property(PropertyName.Primitive0, "Material 0"));
            }

            void SetPrimitiveOneBlue(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Material = new Runtime.Material()
                {
                    MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness()
                    {
                        BaseColorFactor = baseColorFactorBlue
                    }
                };

                properties.Add(new Property(PropertyName.Primitive1, "Material 1"));
            }

            this.Models = new List <Model>
            {
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => {
                    SetPrimitiveZeroGreen(properties, meshPrimitiveZero);
                    SetPrimitiveOneBlue(properties, meshPrimitiveOne);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 17
0
        public Mesh_PrimitivesUV(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane");
            Runtime.Image normalImage           = UseTexture(imageList, "Normal_Plane");
            UseFigure(imageList, "Indices_Primitive0");
            UseFigure(imageList, "Indices_Primitive1");
            UseFigure(imageList, "UVSpace2");
            UseFigure(imageList, "UVSpace3");
            UseFigure(imageList, "UVSpace4");
            UseFigure(imageList, "UVSpace5");

            // Track the common properties for use in the readme.
            var vertexNormalValue = new List <Vector3>
            {
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
            };
            var tangentValue = new List <Vector4>
            {
                new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
            };
            var vertexColorValue = new List <Vector4>
            {
                new Vector4(0.0f, 1.0f, 0.0f, 0.2f),
                new Vector4(1.0f, 0.0f, 0.0f, 0.2f),
                new Vector4(0.0f, 0.0f, 1.0f, 0.2f),
            };

            CommonProperties.Add(new Property(PropertyName.VertexNormal, vertexNormalValue));
            CommonProperties.Add(new Property(PropertyName.VertexTangent, tangentValue));
            CommonProperties.Add(new Property(PropertyName.VertexColor, vertexColorValue));
            CommonProperties.Add(new Property(PropertyName.NormalTexture, normalImage));
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.MeshPrimitive> setProperties)
            {
                var properties = new List <Property>();
                List <Runtime.MeshPrimitive> meshPrimitives = MeshPrimitive.CreateMultiPrimitivePlane();

                // Apply the common properties to the gltf.
                foreach (var meshPrimitive in meshPrimitives)
                {
                    meshPrimitive.TextureCoordSets = new List <List <Vector2> >();
                    meshPrimitive.Material         = new Runtime.Material
                    {
                        MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness
                        {
                            MetallicFactor = 0
                        }
                    };
                }

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitives[0], meshPrimitives[1]);

                // 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 = meshPrimitives
                                },
                            },
                        },
                    }),
                });
            }

            void SetCommonProperties(Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Normals  = vertexNormalValue;
                meshPrimitive.Tangents = tangentValue;
                meshPrimitive.Colors   = vertexColorValue;
                meshPrimitive.Material.NormalTexture = new Runtime.Texture {
                    Source = normalImage
                };
                meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture()
                {
                    Source = baseColorTextureImage
                };
            }

            void SetNullUV(Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Material         = null;
                meshPrimitive.TextureCoordSets = null;
            }

            void SetPrimitiveZeroVertexUVZero(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                SetCommonProperties(meshPrimitive);
                meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat(
                    new[]
                {
                    new[]
                    {
                        new Vector2(0.0f, 1.0f),
                        new Vector2(1.0f, 0.0f),
                        new Vector2(0.0f, 0.0f),
                    }
                });
                properties.Add(new Property(PropertyName.Primitive0VertexUV0, ":white_check_mark:"));
            }

            void SetPrimitiveOneVertexUVZero(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                SetCommonProperties(meshPrimitive);
                meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat(
                    new[]
                {
                    new[]
                    {
                        new Vector2(0.0f, 1.0f),
                        new Vector2(1.0f, 1.0f),
                        new Vector2(1.0f, 0.0f),
                    }
                });
                properties.Add(new Property(PropertyName.Primitive1VertexUV0, ":white_check_mark:"));
            }

            void SetPrimitiveZeroVertexUVOne(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                SetCommonProperties(meshPrimitive);
                meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 1;
                meshPrimitive.Material.NormalTexture.TexCoordIndex = 1;
                meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat(
                    new[]
                {
                    new[]
                    {
                        new Vector2(0.5f, 0.5f),
                        new Vector2(1.0f, 0.0f),
                        new Vector2(0.5f, 0.0f),
                    }
                });
                properties.Add(new Property(PropertyName.Primitive0VertexUV1, ":white_check_mark:"));
            }

            void SetPrimitiveOneVertexUVOne(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                SetCommonProperties(meshPrimitive);
                meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 1;
                meshPrimitive.Material.NormalTexture.TexCoordIndex = 1;
                meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat(
                    new[]
                {
                    new[]
                    {
                        new Vector2(0.5f, 0.5f),
                        new Vector2(1.0f, 0.5f),
                        new Vector2(1.0f, 0.0f),
                    }
                });
                properties.Add(new Property(PropertyName.Primitive1VertexUV1, ":white_check_mark:"));
            }

            Models = new List <Model>
            {
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) =>
                {
                    SetNullUV(meshPrimitiveZero);
                    SetNullUV(meshPrimitiveOne);
                }),
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) =>
                {
                    SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero);
                    SetNullUV(meshPrimitiveOne);
                }),
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) =>
                {
                    SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne);
                    SetNullUV(meshPrimitiveZero);
                }),
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) =>
                {
                    SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero);
                    SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne);
                }),
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) =>
                {
                    SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero);
                    SetPrimitiveZeroVertexUVOne(properties, meshPrimitiveZero);
                    SetNullUV(meshPrimitiveOne);
                }),
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) =>
                {
                    SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne);
                    SetPrimitiveOneVertexUVOne(properties, meshPrimitiveOne);
                    SetNullUV(meshPrimitiveZero);
                }),
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) =>
                {
                    SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero);
                    SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne);
                    SetPrimitiveOneVertexUVOne(properties, meshPrimitiveOne);
                }),
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) =>
                {
                    SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero);
                    SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne);
                    SetPrimitiveZeroVertexUVOne(properties, meshPrimitiveZero);
                }),
                CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) =>
                {
                    SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero);
                    SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne);
                    SetPrimitiveZeroVertexUVOne(properties, meshPrimitiveZero);
                    SetPrimitiveOneVertexUVOne(properties, meshPrimitiveOne);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 18
0
        public Node_Attribute(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage         = UseTexture(imageList, "BaseColor_Nodes");
            Runtime.Image normalImage                   = UseTexture(imageList, "Normal_Nodes");
            Runtime.Image metallicRoughnessTextureImage = UseTexture(imageList, "MetallicRoughness_Nodes");

            // Track the common properties for use in the readme.
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage.ToReadmeString()));
            CommonProperties.Add(new Property(PropertyName.NormalTexture, normalImage.ToReadmeString()));
            CommonProperties.Add(new Property(PropertyName.MetallicRoughnessTexture, metallicRoughnessTextureImage.ToReadmeString()));

            Model CreateModel(Action <List <Property>, Runtime.Node> setProperties)
            {
                var properties            = new List <Property>();
                List <Runtime.Node> nodes = Nodes.CreateMultiNode();

                // Apply the common properties to the gltf.
                foreach (var node in nodes)
                {
                    node.Mesh.MeshPrimitives.First().Material = new Runtime.Material
                    {
                        NormalTexture = new Runtime.Texture {
                            Source = normalImage
                        },
                        MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness
                        {
                            BaseColorTexture = new Runtime.Texture {
                                Source = baseColorTextureImage
                            },
                            MetallicRoughnessTexture = new Runtime.Texture {
                                Source = metallicRoughnessTextureImage
                            },
                        },
                    };
                }

                // Apply the properties that are specific to this gltf.
                setProperties(properties, nodes[1]);

                // Create the gltf object.
                return(new Model
                {
                    Properties = properties,
                    GLTF = CreateGLTF(() => new Runtime.Scene
                    {
                        Nodes = new[]
                        {
                            nodes[0]
                        }
                    })
                });
            }

            void SetTranslation(List <Property> properties, Runtime.Node node)
            {
                node.Translation = new Vector3(-2.0f, 2.0f, -2.0f);
                properties.Add(new Property(PropertyName.Translation, node.Translation.ToReadmeString()));
            }

            void SetTranslationX(List <Property> properties, Runtime.Node node)
            {
                node.Translation = new Vector3(-2.0f, 0.0f, 0.0f);
                properties.Add(new Property(PropertyName.Translation, node.Translation.ToReadmeString()));
            }

            void SetTranslationY(List <Property> properties, Runtime.Node node)
            {
                node.Translation = new Vector3(0.0f, 2.0f, 0.0f);
                properties.Add(new Property(PropertyName.Translation, node.Translation.ToReadmeString()));
            }

            void SetTranslationZ(List <Property> properties, Runtime.Node node)
            {
                node.Translation = new Vector3(0.0f, 0.0f, -2.0f);
                properties.Add(new Property(PropertyName.Translation, node.Translation.ToReadmeString()));
            }

            void SetRotation(List <Property> properties, Runtime.Node node)
            {
                var rotation = new Quaternion(0.0f, 1.0f, 0.0f, 0.0f);

                node.Rotation = rotation;
                properties.Add(new Property(PropertyName.Rotation, rotation.ToReadmeString()));
            }

            void SetScale(List <Property> properties, Runtime.Node node)
            {
                node.Scale = new Vector3(1.2f, 1.2f, 1.2f);
                properties.Add(new Property(PropertyName.Scale, node.Scale.ToReadmeString()));
            }

            void SetMatrix(List <Property> properties, Runtime.Node node)
            {
                Matrix4x4 matrixT   = Matrix4x4.CreateTranslation(new Vector3(-2.0f, 2.0f, -2.0f));
                Matrix4x4 matrixR   = Matrix4x4.CreateRotationY(FloatMath.Pi);
                Matrix4x4 matrixS   = Matrix4x4.CreateScale(1.2f);
                Matrix4x4 matrixTRS = Matrix4x4.Multiply(Matrix4x4.Multiply(matrixS, matrixR), matrixT);

                node.Matrix = matrixTRS;
                properties.Add(new Property(PropertyName.Matrix, matrixTRS.ToReadmeString()));
            }

            Models = new List <Model>
            {
                CreateModel((properties, node) =>
                {
                    // There are no properties set on this model.
                }),
                CreateModel((properties, node) =>
                {
                    SetTranslation(properties, node);
                }),
                CreateModel((properties, node) =>
                {
                    SetTranslationX(properties, node);
                }),
                CreateModel((properties, node) =>
                {
                    SetTranslationY(properties, node);
                }),
                CreateModel((properties, node) =>
                {
                    SetTranslationZ(properties, node);
                }),
                CreateModel((properties, node) =>
                {
                    SetRotation(properties, node);
                }),
                CreateModel((properties, node) =>
                {
                    SetScale(properties, node);
                }),
                CreateModel((properties, node) =>
                {
                    SetTranslation(properties, node);
                    SetRotation(properties, node);
                    SetScale(properties, node);
                }),
                CreateModel((properties, node) =>
                {
                    SetMatrix(properties, node);
                }),
            };

            GenerateUsedPropertiesList();
        }
        public Node_NegativeScale(List <string> imageList)
        {
            var baseColorTextureImage         = UseTexture(imageList, "BaseColor_Nodes");
            var normalImage                   = UseTexture(imageList, "Normal_Nodes");
            var metallicRoughnessTextureImage = UseTexture(imageList, "MetallicRoughness_Nodes");

            // Track the common properties for use in the readme.
            var translationValue       = new Vector3(0, 2, 0);
            var matrixTranslationValue = Matrix4x4.CreateTranslation(translationValue);

            CommonProperties.Add(new Property(PropertyName.Translation, translationValue));
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage));
            CommonProperties.Add(new Property(PropertyName.NormalTexture, normalImage));
            CommonProperties.Add(new Property(PropertyName.MetallicRoughnessTexture, metallicRoughnessTextureImage));

            Model CreateModel(Action <List <Property>, Runtime.Node, Runtime.Node> setProperties)
            {
                var properties = new List <Property>();
                var gltf       = Gltf.CreateMultiNode();
                var nodes      = new[]
                {
                    gltf.Scenes.First().Nodes.First(),
                    gltf.Scenes.First().Nodes.First().Children.First(),
                };

                // Apply the common properties to the gltf.
                foreach (var node in nodes)
                {
                    node.Mesh.MeshPrimitives.First().Material = new Runtime.Material()
                    {
                        NormalTexture = new Runtime.Texture()
                        {
                            Source = normalImage
                        },
                        MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness()
                        {
                            BaseColorTexture = new Runtime.Texture()
                            {
                                Source = baseColorTextureImage
                            },
                            MetallicRoughnessTexture = new Runtime.Texture()
                            {
                                Source = metallicRoughnessTextureImage
                            },
                        },
                    };
                }

                // Apply the properties that are specific to this gltf.
                setProperties(properties, nodes[0], nodes[1]);

                // Applies a translation to avoid clippine the other node.
                // Models with a matrix applied have the translation applied in that matrix.
                if (properties.Find(e => e.Name == PropertyName.Matrix) == null)
                {
                    nodes[1].Translation = translationValue;
                }

                // Create the gltf object
                return(new Model
                {
                    Properties = properties,
                    GLTF = CreateGLTF(() => gltf.Scenes.First()),
                });
            }

            void SetMatrixScaleX(List <Property> properties, Runtime.Node node)
            {
                node.Matrix = Matrix4x4.Multiply(Matrix4x4.CreateScale(new Vector3(-1, 1, 1)), matrixTranslationValue);
                properties.Add(new Property(PropertyName.Matrix, node.Matrix));
            }

            void SetMatrixScaleXY(List <Property> properties, Runtime.Node node)
            {
                node.Matrix = Matrix4x4.Multiply(Matrix4x4.CreateScale(new Vector3(-1, -1, 1)), matrixTranslationValue);
                properties.Add(new Property(PropertyName.Matrix, node.Matrix));
            }

            void SetMatrixScaleXYZ(List <Property> properties, Runtime.Node node)
            {
                node.Matrix = Matrix4x4.Multiply(Matrix4x4.CreateScale(new Vector3(-1, -1, -1)), matrixTranslationValue);
                properties.Add(new Property(PropertyName.Matrix, node.Matrix));
            }

            void SetScaleX(List <Property> properties, Runtime.Node node)
            {
                node.Scale = new Vector3(-1, 1, 1);
                properties.Add(new Property(PropertyName.Scale, node.Scale));
            }

            void SetScaleXY(List <Property> properties, Runtime.Node node)
            {
                node.Scale = new Vector3(-1, -1, 1);
                properties.Add(new Property(PropertyName.Scale, node.Scale));
            }

            void SetScaleXYZ(List <Property> properties, Runtime.Node node)
            {
                node.Scale = new Vector3(-1, -1, -1);
                properties.Add(new Property(PropertyName.Scale, node.Scale));
            }

            void SetVertexNormal(List <Property> properties, Runtime.Node nodeZero, Runtime.Node nodeOne)
            {
                var normals = Gltf.GetMultiNodeNormals();

                nodeZero.Mesh.MeshPrimitives.First().Normals = normals;
                nodeOne.Mesh.MeshPrimitives.First().Normals  = normals;
                properties.Add(new Property(PropertyName.VertexNormal, ":white_check_mark:"));
            }

            void SetVertexTangent(List <Property> properties, Runtime.Node nodeZero, Runtime.Node nodeOne)
            {
                var tangents = Gltf.GetMultiNodeTangents();

                nodeZero.Mesh.MeshPrimitives.First().Tangents = tangents;
                nodeOne.Mesh.MeshPrimitives.First().Tangents  = tangents;
                properties.Add(new Property(PropertyName.VertexTangent, ":white_check_mark:"));
            }

            this.Models = new List <Model>
            {
                CreateModel((properties, nodeZero, nodeOne) => {
                    // There are no properties set on this model.
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetMatrixScaleX(properties, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetMatrixScaleXY(properties, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetMatrixScaleXYZ(properties, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetScaleX(properties, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetScaleXY(properties, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetScaleXYZ(properties, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetScaleX(properties, nodeOne);
                    SetVertexNormal(properties, nodeZero, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetScaleXY(properties, nodeOne);
                    SetVertexNormal(properties, nodeZero, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetScaleXYZ(properties, nodeOne);
                    SetVertexNormal(properties, nodeZero, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetScaleX(properties, nodeOne);
                    SetVertexNormal(properties, nodeZero, nodeOne);
                    SetVertexTangent(properties, nodeZero, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetScaleXY(properties, nodeOne);
                    SetVertexNormal(properties, nodeZero, nodeOne);
                    SetVertexTangent(properties, nodeZero, nodeOne);
                }),
                CreateModel((properties, nodeZero, nodeOne) => {
                    SetScaleXYZ(properties, nodeOne);
                    SetVertexNormal(properties, nodeZero, nodeOne);
                    SetVertexTangent(properties, nodeZero, nodeOne);
                }),
            };

            GenerateUsedPropertiesList();
        }
Exemplo n.º 20
0
        public Buffer_Interleaved(List <string> imageList)
        {
            var baseColorTexture = new Texture {
                Source = UseTexture(imageList, "BaseColor_Grey")
            };

            // Track the common properties for use in the readme.
            CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTexture.Source.ToReadmeString()));

            Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive> setProperties)
            {
                var properties = new List <Property>();

                Runtime.MeshPrimitive meshPrimitive = MeshPrimitive.CreateSinglePlane();

                // Apply the common properties to the gltf.
                meshPrimitive.Interleave = true;
                meshPrimitive.Colors     = Data.Create
                                           (
                    new[]
                {
                    new Vector3(0.0f, 1.0f, 0.0f),
                    new Vector3(1.0f, 0.0f, 0.0f),
                    new Vector3(1.0f, 1.0f, 0.0f),
                    new Vector3(0.0f, 0.0f, 1.0f),
                }
                                           );
                meshPrimitive.Material = new Runtime.Material
                {
                    PbrMetallicRoughness = new PbrMetallicRoughness
                    {
                        BaseColorTexture = new TextureInfo {
                            Texture = baseColorTexture
                        },
                    },
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, meshPrimitive);

                // Create the gltf object.
                return(new Model
                {
                    Properties = properties,
                    GLTF = CreateGLTF(() => new Scene
                    {
                        Nodes = new[]
                        {
                            new Node
                            {
                                Mesh = new Runtime.Mesh
                                {
                                    MeshPrimitives = new[]
                                    {
                                        meshPrimitive
                                    }
                                },
                            },
                        },
                    }),
                });
            }

            void SetUvTypeFloat(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TexCoords0.OutputType = DataType.Float;
                properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TexCoords0.OutputType.ToReadmeString()));
            }

            void SetUvTypeByte(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TexCoords0.OutputType = DataType.NormalizedUnsignedByte;
                properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TexCoords0.OutputType.ToReadmeString()));
            }

            void SetUvTypeShort(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.TexCoords0.OutputType = DataType.NormalizedUnsignedShort;
                properties.Add(new Property(PropertyName.VertexUV0, meshPrimitive.TexCoords0.OutputType.ToReadmeString()));
            }

            void SetColorTypeFloat(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Colors.OutputType = DataType.Float;
                properties.Add(new Property(PropertyName.VertexColor, $"Vector3 {meshPrimitive.Colors.OutputType.ToReadmeString()}"));
            }

            void SetColorTypeByte(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Colors.OutputType = DataType.NormalizedUnsignedByte;
                properties.Add(new Property(PropertyName.VertexColor, $"Vector3 {meshPrimitive.Colors.OutputType.ToReadmeString()}"));
            }

            void SetColorTypeShort(List <Property> properties, Runtime.MeshPrimitive meshPrimitive)
            {
                meshPrimitive.Colors.OutputType = DataType.NormalizedUnsignedShort;
                properties.Add(new Property(PropertyName.VertexColor, $"Vector3 {meshPrimitive.Colors.OutputType.ToReadmeString()}"));
            }

            Models = new List <Model>
            {
                CreateModel((properties, meshPrimitive) =>
                {
                    SetUvTypeFloat(properties, meshPrimitive);
                    SetColorTypeFloat(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetUvTypeFloat(properties, meshPrimitive);
                    SetColorTypeByte(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetUvTypeFloat(properties, meshPrimitive);
                    SetColorTypeShort(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetUvTypeByte(properties, meshPrimitive);
                    SetColorTypeFloat(properties, meshPrimitive);
                }),
                CreateModel((properties, meshPrimitive) =>
                {
                    SetUvTypeShort(properties, meshPrimitive);
                    SetColorTypeFloat(properties, meshPrimitive);
                }),
            };

            GenerateUsedPropertiesList();
        }