private VRMData LoadVRM() { var path = WindowsDialogs.OpenFileDialog("VRMファイル選択", ".vrm"); if (string.IsNullOrEmpty(path)) { return null; } var vrmdata = new VRMData(); vrmdata.FilePath = path; var context = new VRMImporterContext(path); var bytes = File.ReadAllBytes(path); // GLB形式でJSONを取得しParseします context.ParseVrm(bytes); // metaを取得 var meta = context.ReadMeta(true); //サムネイル if (meta.Thumbnail != null) { vrmdata.ThumbnailPNGBytes = meta.Thumbnail.EncodeToPNG(); //Or SaveAsPng( memoryStream, texture.Width, texture.Height ) } //Info vrmdata.Title = meta.Title; vrmdata.Version = meta.Version; vrmdata.Author = meta.Author; vrmdata.ContactInformation = meta.ContactInformation; vrmdata.Reference = meta.Reference; // Permission vrmdata.AllowedUser = (ControlWindow.AllowedUser)meta.AllowedUser; vrmdata.ViolentUssage = (ControlWindow.UssageLicense)meta.ViolentUssage; vrmdata.SexualUssage = (ControlWindow.UssageLicense)meta.SexualUssage; vrmdata.CommercialUssage = (ControlWindow.UssageLicense)meta.CommercialUssage; vrmdata.OtherPermissionUrl = meta.OtherPermissionUrl; // Distribution License vrmdata.LicenseType = (ControlWindow.LicenseType)meta.LicenseType; vrmdata.OtherLicenseUrl = meta.OtherLicenseUrl; /* // ParseしたJSONをシーンオブジェクトに変換していく var now = Time.time; var go = await VRMImporter.LoadVrmAsync(context); var delta = Time.time - now; Debug.LogFormat("LoadVrmAsync {0:0.0} seconds", delta); //OnLoaded(go); */ return vrmdata; }
private void Import(bool createObject) { if (vrik == null && CurrentModel != null) { vrik = CurrentModel.GetComponent <VRIK>(); Debug.Log("ExternalSender: VRIK Updated"); } if (vrik == null) { return; } var path = Application.dataPath + "/../SavedTrackerPositions/"; var filename = WindowsDialogs.OpenFileDialog("Import tracker positions", ".json"); if (string.IsNullOrEmpty(filename)) { return; } var json = System.IO.File.ReadAllText(filename); var alldata = sh_akira.Json.Serializer.Deserialize <AllTrackerPositions>(json); foreach (Transform child in RootObject) { Destroy(child.gameObject); } var Trackers = alldata.Trackers; AddIfNotNull(Trackers, createObject, "Head", ref vrik.solver.spine.headTarget); AddIfNotNull(Trackers, createObject, "Pelvis", ref vrik.solver.spine.pelvisTarget); AddIfNotNull(Trackers, createObject, "LeftArm", ref vrik.solver.leftArm.target); AddIfNotNull(Trackers, createObject, "RightArm", ref vrik.solver.rightArm.target); AddIfNotNull(Trackers, createObject, "LeftLeg", ref vrik.solver.leftLeg.target); AddIfNotNull(Trackers, createObject, "RightLeg", ref vrik.solver.rightLeg.target); alldata.RootTransform.ToLocalTransform(vrik.references.root); alldata.VrikSolverData.ApplyTo(vrik.solver); }
private void LoadSettings() { var path = WindowsDialogs.OpenFileDialog("設定読み込み先選択", ".json"); if (string.IsNullOrEmpty(path)) { return; } CurrentSettings = Json.Serializer.Deserialize<Settings>(File.ReadAllText(path)); if (CurrentSettings != null) { if (string.IsNullOrWhiteSpace(CurrentSettings.VRMPath) == false) { win.CurrentVRMFilePath = CurrentSettings.VRMPath; ImportVRM(CurrentSettings.VRMPath, false); } if (CurrentSettings.BackgroundColor != null) { ChangeBackgroundColor(CurrentSettings.BackgroundColor.r, CurrentSettings.BackgroundColor.g, CurrentSettings.BackgroundColor.b, false); } if (CurrentSettings.CustomBackgroundColor != null) { WindowLoader.Instance.LoadCustomBackgroundColor?.Invoke(CurrentSettings.CustomBackgroundColor.r, CurrentSettings.CustomBackgroundColor.g, CurrentSettings.CustomBackgroundColor.b); } if (CurrentSettings.IsTransparent) { SetBackgroundTransparent(); } SetWindowBorder(CurrentSettings.HideBorder); WindowLoader.Instance.LoadHideBorder?.Invoke(CurrentSettings.HideBorder); SetWindowTopMost(CurrentSettings.IsTopMost); WindowLoader.Instance.LoadIsTopMost?.Invoke(CurrentSettings.IsTopMost); if (CurrentSettings.FreeCameraTransform != null) { CurrentSettings.FreeCameraTransform.ToLocalTransform(FreeCamera.transform); } if (CurrentSettings.FrontCameraLookTargetSettings != null) { CurrentSettings.FrontCameraLookTargetSettings.ApplyTo(FrontCamera); } if (CurrentSettings.BackCameraLookTargetSettings != null) { CurrentSettings.BackCameraLookTargetSettings.ApplyTo(BackCamera); } if (CurrentSettings.CameraType.HasValue) { ChangeCamera(CurrentSettings.CameraType.Value); } SetGridVisible(CurrentSettings.ShowCameraGrid); WindowLoader.Instance.LoadShowCameraGrid?.Invoke(CurrentSettings.ShowCameraGrid); SetWindowClickThrough(CurrentSettings.WindowClickThrough); WindowLoader.Instance.LoadSetWindowClickThrough?.Invoke(CurrentSettings.WindowClickThrough); SetLipSyncEnable(CurrentSettings.LipSyncEnable); WindowLoader.Instance.LoadLipSyncEnable?.Invoke(CurrentSettings.LipSyncEnable); SetLipSyncDevice(CurrentSettings.LipSyncDevice); WindowLoader.Instance.LoadLipSyncDevice?.Invoke(CurrentSettings.LipSyncDevice); SetLipSyncGain(CurrentSettings.LipSyncGain); WindowLoader.Instance.LoadLipSyncGain(CurrentSettings.LipSyncGain); SetLipSyncMaxWeightEnable(CurrentSettings.LipSyncMaxWeightEnable); WindowLoader.Instance.LoadLipSyncMaxWeightEnable?.Invoke(CurrentSettings.LipSyncMaxWeightEnable); SetLipSyncWeightThreashold(CurrentSettings.LipSyncWeightThreashold); WindowLoader.Instance.LoadLipSyncWeightThreashold?.Invoke(CurrentSettings.LipSyncWeightThreashold); SetLipSyncMaxWeightEmphasis(CurrentSettings.LipSyncMaxWeightEmphasis); WindowLoader.Instance.LoadLipSyncMaxWeightEmphasis?.Invoke(CurrentSettings.LipSyncMaxWeightEmphasis); SetAutoBlinkEnable(CurrentSettings.AutoBlinkEnable); WindowLoader.Instance.LoadAutoBlinkEnable?.Invoke(CurrentSettings.AutoBlinkEnable); SetBlinkTimeMin(CurrentSettings.BlinkTimeMin); WindowLoader.Instance.LoadBlinkTimeMin?.Invoke(CurrentSettings.BlinkTimeMin); SetBlinkTimeMax(CurrentSettings.BlinkTimeMax); WindowLoader.Instance.LoadBlinkTimeMax?.Invoke(CurrentSettings.BlinkTimeMax); SetCloseAnimationTime(CurrentSettings.CloseAnimationTime); WindowLoader.Instance.LoadCloseAnimationTime?.Invoke(CurrentSettings.CloseAnimationTime); SetOpenAnimationTime(CurrentSettings.OpenAnimationTime); WindowLoader.Instance.LoadOpenAnimationTime?.Invoke(CurrentSettings.OpenAnimationTime); SetClosingTime(CurrentSettings.ClosingTime); WindowLoader.Instance.LoadClosingTime?.Invoke(CurrentSettings.ClosingTime); SetDefaultFace(CurrentSettings.DefaultFace); WindowLoader.Instance.LoadDefaultFace?.Invoke(CurrentSettings.DefaultFace); } }