Exemplo n.º 1
0
        public void TextureEnumerationInUnknownShader()
        {
            using (var data = GltfData.CreateFromGltfDataForTest(
                       new glTF
            {
                images = new List <glTFImage>
                {
                    new glTFImage
                    {
                        mimeType = "image/png",
                    }
                },
                textures = new List <glTFTexture>
                {
                    new glTFTexture
                    {
                        name = "texture0",
                        source = 0,
                    }
                },
                materials = new List <glTFMaterial>
                {
                    new glTFMaterial
                    {
                        pbrMetallicRoughness = new glTFPbrMetallicRoughness
                        {
                            baseColorTexture = new glTFMaterialBaseColorTextureInfo
                            {
                                index = 0,
                            }
                        }
                    },
                }
            },
                       default
                       ))
            {
                var vrm = new glTF_VRM_extensions
                {
                    materialProperties = new List <glTF_VRM_Material>
                    {
                        new glTF_VRM_Material
                        {
                            shader            = "UnknownShader",
                            textureProperties = new Dictionary <string, int>
                            {
                                { "_MainTex", 0 },
                            }
                        },
                    }
                };

                // 2系統ある?
                Assert.IsTrue(VRMMToonMaterialImporter.TryCreateParam(data, vrm, 0, out VRMShaders.MaterialDescriptor matDesc));
                Assert.AreEqual(1, matDesc.TextureSlots.Count);

                var items = new VrmTextureDescriptorGenerator(data, vrm).Get().GetEnumerable().ToArray();
                Assert.AreEqual(1, items.Length);
            }
        }
Exemplo n.º 2
0
 public VRMImporterContext(
     VRMData data,
     IReadOnlyDictionary <SubAssetKey, Object> externalObjectMap = null,
     ITextureDeserializer textureDeserializer       = null,
     IMaterialDescriptorGenerator materialGenerator = null)
     : base(data.Data, externalObjectMap, textureDeserializer, materialGenerator ?? new VRMMaterialDescriptorGenerator(data.VrmExtension))
 {
     _data = data;
     TextureDescriptorGenerator = new VrmTextureDescriptorGenerator(Data, VRM);
 }
Exemplo n.º 3
0
 public VRMImporterContext(
     GltfData data,
     IReadOnlyDictionary <SubAssetKey, Object> externalObjectMap = null,
     ITextureDeserializer textureDeserializer = null)
     : base(data, externalObjectMap, textureDeserializer)
 {
     // parse VRM part
     if (glTF_VRM_extensions.TryDeserialize(GLTF.extensions, out glTF_VRM_extensions vrm))
     {
         VRM = vrm;
         TextureDescriptorGenerator  = new VrmTextureDescriptorGenerator(Data, VRM);
         MaterialDescriptorGenerator = new VRMMaterialDescriptorGenerator(VRM);
     }
     else
     {
         throw new NotVrm0Exception();
     }
 }
Exemplo n.º 4
0
 public void TextureEnumerationTest()
 {
     using (
         var data = GltfData.CreateFromGltfDataForTest(
             new glTF
     {
         images = new List <glTFImage>
         {
             new glTFImage
             {
                 mimeType = "image/png",
             }
         },
         textures = new List <glTFTexture>
         {
             new glTFTexture
             {
                 name = "texture0",
                 source = 0,
             }
         },
         materials = new List <glTFMaterial>
         {
             new glTFMaterial
             {
                 pbrMetallicRoughness = new glTFPbrMetallicRoughness
                 {
                     baseColorTexture = new glTFMaterialBaseColorTextureInfo
                     {
                         index = 0,
                     }
                 }
             },
             new glTFMaterial
             {
                 pbrMetallicRoughness = new glTFPbrMetallicRoughness
                 {
                     baseColorTexture = new glTFMaterialBaseColorTextureInfo
                     {
                         index = 0,
                     }
                 }
             },
         }
     },
             default
             ))
     {
         var vrm = new glTF_VRM_extensions
         {
             materialProperties = new List <glTF_VRM_Material>
             {
                 new glTF_VRM_Material
                 {
                     textureProperties = new Dictionary <string, int>
                     {
                         { "_MainTex", 0 },
                     }
                 },
                 new glTF_VRM_Material
                 {
                     textureProperties = new Dictionary <string, int>
                     {
                         { "_MainTex", 0 },
                     }
                 },
             }
         };
         var items = new VrmTextureDescriptorGenerator(data, vrm).Get().GetEnumerable().ToArray();
         Assert.AreEqual(1, items.Length);
     }
 }