コード例 #1
0
        static NormalTextureInfo ExportNormalTextureInfo(
            UnityEngine.Texture texture,
            TextureMapType textureMapType,
            UnityEngine.Material material,
            IGltfWritable gltf
            )
        {
            var imageId = gltf.AddImage(texture);

            if (imageId < 0)
            {
                return(null);
            }
            var textureId = gltf.AddTexture(imageId);
            var info      = new NormalTextureInfo {
                index = textureId,
                // texCoord = 0 // TODO: figure out which UV set was used
            };

            if (material.HasProperty(MaterialGenerator.bumpScalePropId))
            {
                info.scale = material.GetFloat(MaterialGenerator.bumpScalePropId);
            }

            return(info);
        }
コード例 #2
0
        /// <summary>
        /// Adds an ImageExport to the glTF.
        /// No conversions or channel swizzling
        /// </summary>
        /// <param name="gltf"></param>
        /// <param name="imageExport"></param>
        /// <param name="textureId"></param>
        /// <returns>glTF texture ID</returns>
        protected static bool AddImageExport(IGltfWritable gltf, ImageExportBase imageExport, out int textureId)
        {
            var imageId = gltf.AddImage(imageExport);

            if (imageId < 0)
            {
                textureId = -1;
                return(false);
            }

            var samplerId = gltf.AddSampler(imageExport.filterMode, imageExport.wrapModeU, imageExport.wrapModeV);

            textureId = gltf.AddTexture(imageId, samplerId);
            return(true);
        }
コード例 #3
0
        static TextureInfo ExportTextureInfo(UnityEngine.Texture texture, TextureMapType textureMapType, IGltfWritable gltf)
        {
            var imageId = gltf.AddImage(texture);

            if (imageId < 0)
            {
                return(null);
            }
            var textureId = gltf.AddTexture(imageId);
            var info      = new TextureInfo {
                index = textureId,
                // texCoord = 0 // TODO: figure out which UV set was used
            };

            return(info);
        }