Ejemplo n.º 1
0
        static void Export_TextureTransform(Material m, glTFTextureInfo textureInfo, string propertyName)
        {
            if (textureInfo != null && m.HasProperty(propertyName))
            {
                var offset = m.GetTextureOffset(propertyName);
                var scale  = m.GetTextureScale(propertyName);
                offset.y = (offset.y + scale.y - 1) * -1.0f;

                textureInfo.extensions = new glTFTextureInfo_extensions
                {
                    KHR_texture_transform = new glTF_KHR_texture_transform()
                    {
                        offset = new float[] { offset.x, offset.y },
                        scale  = new float[] { scale.x, scale.y },
                    }
                };
            }
        }
Ejemplo n.º 2
0
        private static void SetTextureOffsetAndScale(Material material, glTFTextureInfo textureInfo, string propertyName)
        {
            if (textureInfo.extensions != null && textureInfo.extensions.KHR_texture_transform != null)
            {
                var     textureTransform = textureInfo.extensions.KHR_texture_transform;
                Vector2 offset           = new Vector2(0, 0);
                Vector2 scale            = new Vector2(1, 1);
                if (textureTransform.offset != null && textureTransform.offset.Length == 2)
                {
                    offset = new Vector2(textureTransform.offset[0], textureTransform.offset[1]);
                }
                if (textureTransform.scale != null && textureTransform.scale.Length == 2)
                {
                    scale = new Vector2(textureTransform.scale[0], textureTransform.scale[1]);
                }

                offset.y = (offset.y + scale.y - 1.0f) * -1.0f;

                material.SetTextureOffset(propertyName, offset);
                material.SetTextureScale(propertyName, scale);
            }
        }
Ejemplo n.º 3
0
 static void Export_MainTextureTransform(Material m, glTFTextureInfo textureInfo)
 {
     Export_TextureTransform(m, textureInfo, "_MainTex");
 }