Esempio n. 1
0
            public void UpdateMeta(UniGLTF.Extensions.VRMC_vrm.Meta meta, Texture2D thumbnail)
            {
                if (meta == null)
                {
                    return;
                }

                m_textModelTitle.text   = meta.Name;
                m_textModelVersion.text = meta.Version;
                m_textModelAuthor.text  = meta.Authors[0];
                m_textModelContact.text = meta.ContactInformation;
                if (meta.References != null && meta.References.Count > 0)
                {
                    m_textModelReference.text = meta.References[0];
                }
                // m_textPermissionAllowed.text = meta.AllowedUser.ToString();
                m_textPermissionViolent.text    = meta.AllowExcessivelyViolentUsage.ToString();
                m_textPermissionSexual.text     = meta.AllowExcessivelySexualUsage.ToString();
                m_textPermissionCommercial.text = meta.CommercialUsage.ToString();
                // m_textPermissionOther.text = meta.OtherPermissionUrl;

                // m_textDistributionLicense.text = meta.ModificationLicense.ToString();
                m_textDistributionOther.text = meta.OtherLicenseUrl;

                m_thumbnail.texture = thumbnail;
            }
Esempio n. 2
0
        public static Meta FromGltf(this UniGLTF.Extensions.VRMC_vrm.Meta self, List <Texture> textures)
        {
            var meta = new Meta
            {
                Name                  = self.Name,
                Version               = self.Version,
                ContactInformation    = self.ContactInformation,
                AvatarPermission      = ToAvaterPermission(self),
                RedistributionLicense = ToRedistributionLicense(self),
            };

            if (self.References != null)
            {
                meta.References.AddRange(self.References);
            }
            if (self.Authors != null)
            {
                meta.Authors.AddRange(self.Authors);
            }
            if (self.ThumbnailImage.HasValue)
            {
                var texture = textures[self.ThumbnailImage.Value] as ImageTexture;
                if (texture != null)
                {
                    meta.Thumbnail = texture.Image;
                }
            }

            return(meta);
        }
Esempio n. 3
0
 public static RedistributionLicense ToRedistributionLicense(this UniGLTF.Extensions.VRMC_vrm.Meta self)
 {
     return(new RedistributionLicense
     {
         CreditNotation = (CreditNotationType)self.CreditNotation,
         IsAllowRedistribution = self.AllowRedistribution.Value,
         ModificationLicense = (ModificationLicenseType)self.Modification,
         OtherLicenseUrl = self.OtherLicenseUrl,
     });
 }
Esempio n. 4
0
 public static AvatarPermission ToAvaterPermission(this UniGLTF.Extensions.VRMC_vrm.Meta self)
 {
     return(new AvatarPermission
     {
         AvatarUsage = (AvatarUsageType)self.AvatarPermission,
         IsAllowedViolentUsage = self.AllowExcessivelyViolentUsage.Value,
         IsAllowedSexualUsage = self.AllowExcessivelySexualUsage.Value,
         CommercialUsage = (CommercialUsageType)self.CommercialUsage,
         // OtherPermissionUrl = self.OtherPermissionUrl,
         IsAllowedPoliticalOrReligiousUsage = self.AllowPoliticalOrReligiousUsage.Value,
     });
 }
Esempio n. 5
0
        public static UniGLTF.Extensions.VRMC_vrm.Meta ToGltf(this Meta self, List <Texture> textures)
        {
            var meta = new UniGLTF.Extensions.VRMC_vrm.Meta
            {
                Name                 = self.Name,
                Version              = self.Version,
                ContactInformation   = self.ContactInformation,
                CopyrightInformation = self.CopyrightInformation,
                // AvatarPermission
                AvatarPermission             = (UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType)self.AvatarPermission.AvatarUsage,
                AllowExcessivelyViolentUsage = self.AvatarPermission.IsAllowedViolentUsage,
                AllowExcessivelySexualUsage  = self.AvatarPermission.IsAllowedSexualUsage,
                CommercialUsage = (UniGLTF.Extensions.VRMC_vrm.CommercialUsageType)self.AvatarPermission.CommercialUsage,
                AllowPoliticalOrReligiousUsage = self.AvatarPermission.IsAllowedPoliticalOrReligiousUsage,
                // OtherPermissionUrl = self.AvatarPermission.OtherPermissionUrl,
                // RedistributionLicense
                CreditNotation      = (UniGLTF.Extensions.VRMC_vrm.CreditNotationType)self.RedistributionLicense.CreditNotation,
                AllowRedistribution = self.RedistributionLicense.IsAllowRedistribution,
                Modification        = (UniGLTF.Extensions.VRMC_vrm.ModificationType)self.RedistributionLicense.ModificationLicense,
                OtherLicenseUrl     = self.RedistributionLicense.OtherLicenseUrl,
                References          = self.References,
                Authors             = self.Authors,
            };

            if (self.Thumbnail != null)
            {
                for (int i = 0; i < textures.Count; ++i)
                {
                    var texture = textures[i] as ImageTexture;
                    if (texture.Image == self.Thumbnail)
                    {
                        meta.ThumbnailImage = i;
                        break;
                    }
                }
            }
            return(meta);
        }
Esempio n. 6
0
        public static UniGLTF.Extensions.VRMC_vrm.Meta Migrate(JsonNode vrm0)
        {
            var meta = new UniGLTF.Extensions.VRMC_vrm.Meta
            {
                AllowPoliticalOrReligiousUsage = false,
                AllowExcessivelySexualUsage    = false,
                AllowExcessivelyViolentUsage   = false,
                AllowRedistribution            = false,
                AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlyAuthor,
                CommercialUsage  = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit,
                CreditNotation   = UniGLTF.Extensions.VRMC_vrm.CreditNotationType.required,
                Modification     = UniGLTF.Extensions.VRMC_vrm.ModificationType.prohibited,
            };

            string otherLicenseUrl    = default;
            string otherPermissionUrl = default;

            foreach (var kv in vrm0.ObjectItems())
            {
                var key = kv.Key.GetString();
                switch (key)
                {
                case "title": meta.Name = kv.Value.GetString(); break;

                case "version": meta.Version = kv.Value.GetString(); break;

                case "author": meta.Authors = new List <string>()
                {
                        kv.Value.GetString()
                }; break;

                case "contactInformation": meta.ContactInformation = kv.Value.GetString(); break;

                case "reference": meta.References = new List <string>()
                {
                        kv.Value.GetString()
                }; break;

                case "texture": meta.ThumbnailImage = kv.Value.GetInt32(); break;

                case "allowedUserName":
                {
                    var allowedUserName = kv.Value.GetString();
                    switch (allowedUserName)
                    {
                    case "OnlyAuthor":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlyAuthor;
                        break;

                    case "ExplicitlyLicensedPerson":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlySeparatelyLicensedPerson;
                        break;

                    case "Everyone":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.everyone;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {allowedUserName}");
                    }
                }
                break;

                case "violentUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var violentUsageName = kv.Value.GetString();
                    switch (violentUsageName)
                    {
                    case "Allow":
                        meta.AllowExcessivelyViolentUsage = true;
                        break;

                    case "Disallow":
                        meta.AllowExcessivelyViolentUsage = false;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {violentUsageName}");
                    }
                }
                break;

                case "sexualUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var sexualUsageName = kv.Value.GetString();
                    switch (sexualUsageName)
                    {
                    case "Allow":
                        meta.AllowExcessivelySexualUsage = true;
                        break;

                    case "Disallow":
                        meta.AllowExcessivelySexualUsage = false;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {sexualUsageName}");
                    }
                }
                break;

                case "commercialUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var commercialUsageName = kv.Value.GetString();
                    switch (commercialUsageName)
                    {
                    case "Allow":
                        meta.CommercialUsage = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalProfit;
                        break;

                    case "Disallow":
                        meta.CommercialUsage = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {commercialUsageName}");
                    }
                }
                break;

                case "otherPermissionUrl": otherPermissionUrl = kv.Value.GetString(); break;

                case "otherLicenseUrl": otherLicenseUrl = kv.Value.GetString(); break;

                case "licenseName":
                {
                    // TODO
                    // CreditNotation = CreditNotationType.required,
                }
                break;

                default:
                    throw new NotImplementedException(key);
                } // switch
            }     // foreach

            //
            // OtherLicenseUrl migrate
            // OtherPermissionURL removed
            //
            if (!string.IsNullOrEmpty(otherLicenseUrl) && !string.IsNullOrEmpty(otherPermissionUrl))
            {
                if (otherLicenseUrl == otherPermissionUrl)
                {
                    // OK
                    meta.OtherLicenseUrl = otherLicenseUrl;
                }
                else
                {
                    // different otherLicenseUrl & otherPermissionUrl
                    throw new MigrationException("otherPermissionUrl", "can not migrate");
                }
            }
            else if (!string.IsNullOrEmpty(otherLicenseUrl))
            {
                meta.OtherLicenseUrl = otherLicenseUrl;
            }
            else if (!string.IsNullOrEmpty(otherPermissionUrl))
            {
                // otherPermissionUrl => otherLicenseUrl
                meta.OtherLicenseUrl = otherPermissionUrl;
            }
            else
            {
                // null
            }

            return(meta);
        }
Esempio n. 7
0
        public static void Check(JsonNode vrm0, UniGLTF.Extensions.VRMC_vrm.Meta vrm1)
        {
            if (vrm0["title"].GetString() != vrm1.Name)
            {
                throw new MigrationException("meta.title", vrm1.Name);
            }
            if (vrm0["version"].GetString() != vrm1.Version)
            {
                throw new MigrationException("meta.version", vrm1.Version);
            }
            if (!IsSingleList("meta.author", vrm0["author"].GetString(), vrm1.Authors))
            {
                throw new MigrationException("meta.author", $"{vrm1.Authors}");
            }
            if (vrm0["contactInformation"].GetString() != vrm1.ContactInformation)
            {
                throw new MigrationException("meta.contactInformation", vrm1.ContactInformation);
            }
            if (!IsSingleList("meta.reference", vrm0["reference"].GetString(), vrm1.References))
            {
                throw new MigrationException("meta.reference", $"{vrm1.References}");
            }
            if (vrm0["texture"].GetInt32() != vrm1.ThumbnailImage)
            {
                throw new MigrationException("meta.texture", $"{vrm1.ThumbnailImage}");
            }

            if (vrm0["allowedUserName"].GetString() != AvatarPermission("meta.allowedUserName", vrm1.AvatarPermission))
            {
                throw new MigrationException("meta.allowedUserName", $"{vrm1.AvatarPermission}");
            }
            if (vrm0["violentUssageName"].GetString() == "Allow" != vrm1.AllowExcessivelyViolentUsage)
            {
                throw new MigrationException("meta.violentUssageName", $"{vrm1.AllowExcessivelyViolentUsage}");
            }
            if (vrm0["sexualUssageName"].GetString() == "Allow" != vrm1.AllowExcessivelySexualUsage)
            {
                throw new MigrationException("meta.sexualUssageName", $"{vrm1.AllowExcessivelyViolentUsage}");
            }

            if (vrm0["commercialUssageName"].GetString() == "Allow")
            {
                if (vrm1.CommercialUsage == UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit)
                {
                    throw new MigrationException("meta.commercialUssageName", $"{vrm1.CommercialUsage}");
                }
            }
            else
            {
                if (vrm1.CommercialUsage == UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.corporation ||
                    vrm1.CommercialUsage == UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalProfit)
                {
                    throw new MigrationException("meta.commercialUssageName", $"{vrm1.CommercialUsage}");
                }
            }

            if (MigrationVrmMeta.GetLicenseUrl(vrm0) != vrm1.OtherLicenseUrl)
            {
                throw new MigrationException("meta.otherLicenseUrl", vrm1.OtherLicenseUrl);
            }

            switch (vrm0["licenseName"].GetString())
            {
            case "Other":
            {
                if (vrm1.Modification != UniGLTF.Extensions.VRMC_vrm.ModificationType.prohibited)
                {
                    throw new MigrationException("meta.licenceName", $"{vrm1.Modification}");
                }
                if (vrm1.AllowRedistribution.Value)
                {
                    throw new MigrationException("meta.liceneName", $"{vrm1.Modification}");
                }
                break;
            }

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 8
0
        public static UniGLTF.Extensions.VRMC_vrm.Meta Migrate(UniGLTF.glTF gltf, JsonNode vrm0)
        {
            var meta = new UniGLTF.Extensions.VRMC_vrm.Meta
            {
                AllowPoliticalOrReligiousUsage = false,
                AllowExcessivelySexualUsage    = false,
                AllowExcessivelyViolentUsage   = false,
                AllowRedistribution            = false,
                AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlyAuthor,
                CommercialUsage  = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit,
                CreditNotation   = UniGLTF.Extensions.VRMC_vrm.CreditNotationType.required,
                Modification     = UniGLTF.Extensions.VRMC_vrm.ModificationType.prohibited,
            };

            string otherLicenseUrl    = default;
            string otherPermissionUrl = default;

            foreach (var kv in vrm0.ObjectItems())
            {
                var key = kv.Key.GetString();
                switch (key)
                {
                case "title": meta.Name = kv.Value.GetString(); break;

                case "version": meta.Version = kv.Value.GetString(); break;

                case "author": meta.Authors = new List <string>()
                {
                        kv.Value.GetString()
                }; break;

                case "contactInformation": meta.ContactInformation = kv.Value.GetString(); break;

                case "reference": meta.References = new List <string>()
                {
                        kv.Value.GetString()
                }; break;

                case "texture":
                {
                    // vrm0x use texture. vrm10 use image
                    var textureIndex = kv.Value.GetInt32();
                    if (textureIndex == -1)
                    {
                        meta.ThumbnailImage = -1;
                    }
                    else
                    {
                        var gltfTexture = gltf.textures[textureIndex];
                        meta.ThumbnailImage = gltfTexture.source;
                    }
                    break;
                }

                case "allowedUserName":
                {
                    var allowedUserName = kv.Value.GetString();
                    switch (allowedUserName)
                    {
                    case "OnlyAuthor":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlyAuthor;
                        break;

                    case "ExplicitlyLicensedPerson":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlySeparatelyLicensedPerson;
                        break;

                    case "Everyone":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.everyone;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {allowedUserName}");
                    }
                }
                break;

                case "violentUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var violentUsageName = kv.Value.GetString();
                    switch (violentUsageName)
                    {
                    case "Allow":
                        meta.AllowExcessivelyViolentUsage = true;
                        break;

                    case "Disallow":
                        meta.AllowExcessivelyViolentUsage = false;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {violentUsageName}");
                    }
                }
                break;

                case "sexualUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var sexualUsageName = kv.Value.GetString();
                    switch (sexualUsageName)
                    {
                    case "Allow":
                        meta.AllowExcessivelySexualUsage = true;
                        break;

                    case "Disallow":
                        meta.AllowExcessivelySexualUsage = false;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {sexualUsageName}");
                    }
                }
                break;

                case "commercialUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var commercialUsageName = kv.Value.GetString();
                    switch (commercialUsageName)
                    {
                    case "Allow":
                        meta.CommercialUsage = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalProfit;
                        break;

                    case "Disallow":
                        meta.CommercialUsage = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {commercialUsageName}");
                    }
                }
                break;

                case "otherPermissionUrl": otherPermissionUrl = kv.Value.GetString(); break;

                case "otherLicenseUrl": otherLicenseUrl = kv.Value.GetString(); break;

                case "licenseName":
                {
                    // TODO
                    // CreditNotation = CreditNotationType.required,
                }
                break;

                default:
                    Debug.LogWarning($"[meta migration] unknown key: {key}");
                    break;
                } // switch
            }     // foreach

            //
            // OtherLicenseUrl migrate
            // OtherPermissionURL removed
            //
            if (!string.IsNullOrEmpty(otherLicenseUrl) && !string.IsNullOrEmpty(otherPermissionUrl))
            {
                if (otherLicenseUrl == otherPermissionUrl)
                {
                    // OK
                    meta.OtherLicenseUrl = otherLicenseUrl;
                }
                else
                {
                    // https://github.com/vrm-c/UniVRM/issues/1611
                    // 両方を記述しエラーとしない
                    meta.OtherLicenseUrl = $"'{otherLicenseUrl}', '{otherPermissionUrl}'";
                }
            }
            else if (!string.IsNullOrEmpty(otherLicenseUrl))
            {
                meta.OtherLicenseUrl = otherLicenseUrl;
            }
            else if (!string.IsNullOrEmpty(otherPermissionUrl))
            {
                // otherPermissionUrl => otherLicenseUrl
                meta.OtherLicenseUrl = otherPermissionUrl;
            }
            else
            {
                // null
            }

            return(meta);
        }
Esempio n. 9
0
        ///
        /// 互換性の無いところ
        ///
        /// * きつくなる方向は許す
        /// * 緩くなる方向は不許可(throw)
        ///
        // "meta": {
        //   "title": "Alicia Solid",
        //   "version": "1.10",
        //   "author": "© DWANGO Co., Ltd.",
        //   "contactInformation": "https://3d.nicovideo.jp/alicia/",
        //   "reference": "",
        //   "texture": 7,
        //   "allowedUserName": "******",
        //   "violentUssageName": "Disallow",
        //   "sexualUssageName": "Disallow",
        //   "commercialUssageName": "Allow",
        //   "otherPermissionUrl": "https://3d.nicovideo.jp/alicia/rule.html",
        //   "licenseName": "Other",
        //   "otherLicenseUrl": "https://3d.nicovideo.jp/alicia/rule.html"
        // },
        static UniGLTF.Extensions.VRMC_vrm.Meta MigrateMeta(ListTreeNode <JsonValue> vrm0)
        {
            var meta = new UniGLTF.Extensions.VRMC_vrm.Meta
            {
                AllowPoliticalOrReligiousUsage = false,
                AllowExcessivelySexualUsage    = false,
                AllowExcessivelyViolentUsage   = false,
                AllowRedistribution            = false,
                AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlyAuthor,
                CommercialUsage  = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit,
                CreditNotation   = UniGLTF.Extensions.VRMC_vrm.CreditNotationType.required,
                Modification     = UniGLTF.Extensions.VRMC_vrm.ModificationType.prohibited,
            };

            foreach (var kv in vrm0.ObjectItems())
            {
                var key = kv.Key.GetString();
                switch (key)
                {
                case "title": meta.Name = kv.Value.GetString(); break;

                case "version": meta.Version = kv.Value.GetString(); break;

                case "author": meta.Authors = new List <string>()
                {
                        kv.Value.GetString()
                }; break;

                case "contactInformation": meta.ContactInformation = kv.Value.GetString(); break;

                case "reference": meta.References = new List <string>()
                {
                        kv.Value.GetString()
                }; break;

                case "texture": meta.ThumbnailImage = kv.Value.GetInt32(); break;

                case "allowedUserName":
                {
                    var allowedUserName = kv.Value.GetString();
                    switch (allowedUserName)
                    {
                    case "OnlyAuthor":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlyAuthor;
                        break;

                    case "ExplicitlyLicensedPerson":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.explicitlyLicensedPerson;
                        break;

                    case "Everyone":
                        meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.everyone;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {allowedUserName}");
                    }
                }
                break;

                case "violentUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var violentUsageName = kv.Value.GetString();
                    switch (violentUsageName)
                    {
                    case "Allow":
                        meta.AllowExcessivelyViolentUsage = true;
                        break;

                    case "Disallow":
                        meta.AllowExcessivelyViolentUsage = false;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {violentUsageName}");
                    }
                }
                break;

                case "sexualUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var sexualUsageName = kv.Value.GetString();
                    switch (sexualUsageName)
                    {
                    case "Allow":
                        meta.AllowExcessivelySexualUsage = true;
                        break;

                    case "Disallow":
                        meta.AllowExcessivelySexualUsage = false;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {sexualUsageName}");
                    }
                }
                break;

                case "commercialUssageName":     // Typo "Ussage" is VRM 0.x spec.
                {
                    var commercialUsageName = kv.Value.GetString();
                    switch (commercialUsageName)
                    {
                    case "Allow":
                        meta.CommercialUsage = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalProfit;
                        break;

                    case "Disallow":
                        meta.CommercialUsage = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit;
                        break;

                    default:
                        throw new NotImplementedException($"{key}: {commercialUsageName}");
                    }
                }
                break;

                case "otherPermissionUrl":
                {
                    // TODO
                    // var url = kv.Value.GetString();
                    // if (!String.IsNullOrWhiteSpace(url))
                    // {
                    //     throw new NotImplementedException("otherPermissionUrl not allowd");
                    // }
                }
                break;

                case "otherLicenseUrl": meta.OtherLicenseUrl = kv.Value.GetString(); break;

                case "licenseName":
                {
                    // TODO
                    // CreditNotation = CreditNotationType.required,
                }
                break;

                default:
                    throw new NotImplementedException(key);
                }
            }

            return(meta);
        }