public void ModelLoad() { ModelReset(); GameObject oriUnit = ResourceMgr.Load(string.Format("Character/Prefab/{0}", bodymodel.text)) as GameObject; if (oriUnit == null) { Debug.LogWarning("not found player model error! path = Character/Prefab/" + bodymodel.text); oriUnit = ResourceMgr.Load(string.Format("Etc/Missing_Model")) as GameObject; GameObject _ErrorUnit = GameObject.Instantiate(oriUnit) as GameObject; } GameObject _myUnit = GameObject.Instantiate(oriUnit) as GameObject; ModelModifier Modifier = _myUnit.AddComponent <ModelModifier>(); // 여기까지 베이스모델 로딩완료 머리/무기를 붙이자 if (!headmodel.text.Equals("")) { Modifier.ModelApply(string.Format("Character/Prefab/{0}", headmodel.text)); } if (!weaponmodel.text.Equals("")) { Modifier.ModelApply(string.Format("Character/Prefab/{0}", weaponmodel.text)); } _myUnit.transform.parent = ModelRoot.transform; }
public void ModifierTest() { var model = new Model(Coordinates.Vrm1); var modifier = new ModelModifier(model); var node0 = new Node("node0"); modifier.NodeAdd(node0); Assert.AreEqual(1, model.Nodes.Count); var node1 = new Node("node1"); modifier.NodeAdd(node1, node0); Assert.AreEqual(2, model.Nodes.Count); var node2 = new Node("node2"); modifier.NodeReplace(node0, node2); Assert.AreEqual(2, model.Nodes.Count); Assert.AreEqual(node2, model.Nodes[1]); Assert.AreEqual(1, node2.Children.Count); modifier.NodeRemove(node1); Assert.AreEqual(1, model.Nodes.Count); Assert.AreEqual(0, node2.Children.Count); }
public void ModelLoad() { ModelReset(); GameObject oriUnit = ResourceMgr.Load(string.Format("Character/Prefab/{0}", bodymodel.text)) as GameObject; if (oriUnit == null) { Debug.LogWarning("not found player model error! path = Character/Prefab/" + bodymodel.text); oriUnit = ResourceMgr.Load(string.Format("Etc/Missing_Model")) as GameObject; GameObject _ErrorUnit = GameObject.Instantiate(oriUnit) as GameObject; } GameObject _myUnit = GameObject.Instantiate(oriUnit) as GameObject; ModelModifier Modifier = _myUnit.AddComponent <ModelModifier>(); // 여기까지 베이스모델 로딩완료 머리/무기를 붙이자 if (!headmodel.text.Equals("")) { Modifier.ModelApply(string.Format("Character/Prefab/{0}", headmodel.text)); } if (!weaponmodel.text.Equals("")) { Modifier.ModelApply(string.Format("Character/Prefab/{0}", weaponmodel.text)); } _myUnit.transform.parent = ModelRoot.transform; //_myUnit.layer = 8; NGUITools.SetLayer(_myUnit, 8); _myUnit.transform.localPosition = Vector3.zero; _myUnit.transform.localScale = new Vector3(180f, 180f, 180f); _myUnit.transform.localEulerAngles = new Vector3(0f, 180f, 0f); }
public static IEnumerator CreatePlayerDefaultModelAsync(string basePrefName, string weaponPrefName, string headPrefName, System.Action <GameObject> callback) { GameObject oriUnit = null; yield return(SceneManager.instance.StartCoroutine(ResourceMgr.LoadAsync(string.Format("Character/Prefab/{0}", basePrefName), (retval) => { oriUnit = retval as GameObject; }))); if (oriUnit == null) { Debug.LogWarning("not found player model error! path = Character/Prefab/" + basePrefName); oriUnit = ResourceMgr.Load(string.Format("Etc/Missing_Model")) as GameObject; GameObject _ErrorUnit = GameObject.Instantiate(oriUnit) as GameObject; callback(_ErrorUnit); } GameObject _myUnit = GameObject.Instantiate(oriUnit) as GameObject; ModelModifier Modifier = _myUnit.AddComponent <ModelModifier>(); // 여기까지 베이스모델 로딩완료 머리/무기를 붙이자 if (!headPrefName.Equals("")) { Modifier.ModelApply(string.Format("Character/Prefab/{0}", headPrefName)); } if (!weaponPrefName.Equals("")) { Modifier.ModelApply(string.Format("Character/Prefab/{0}", weaponPrefName)); } callback(_myUnit); }
public static GameObject CreatePlayerDefaultModel(string basePrefName, string weaponPrefName, string headPrefName) { GameObject oriUnit = ResourceMgr.Load(string.Format("Character/Prefab/{0}", basePrefName)) as GameObject; if (oriUnit == null) { Debug.LogWarning("not found player model error! path = Character/Prefab/" + basePrefName); oriUnit = ResourceMgr.Load(string.Format("Etc/Missing_Model")) as GameObject; GameObject _ErrorUnit = GameObject.Instantiate(oriUnit) as GameObject; return(_ErrorUnit); } GameObject _myUnit = GameObject.Instantiate(oriUnit) as GameObject; ModelModifier Modifier = _myUnit.AddComponent <ModelModifier>(); // 여기까지 베이스모델 로딩완료 머리/무기를 붙이자 if (!headPrefName.Equals("")) { Modifier.ModelApply(string.Format("Character/Prefab/{0}", headPrefName)); } if (!weaponPrefName.Equals("")) { Modifier.ModelApply(string.Format("Character/Prefab/{0}", weaponPrefName)); } return(_myUnit); }
protected override void ExportPath(string path) { m_logLabel = ""; m_logLabel += $"export...\n"; var root = State.ExportRoot; try { var converter = new UniVRM10.RuntimeVrmConverter(); var model = converter.ToModelFrom10(root); if (HumanoidValidator.HasRotationOrScale(root)) { // 正規化 m_logLabel += $"normalize...\n"; var modifier = new ModelModifier(model); modifier.SkinningBake(); } // 右手系に変換 m_logLabel += $"convert to right handed coordinate...\n"; model.ConvertCoordinate(VrmLib.Coordinates.Vrm1, ignoreVrm: false); // export vrm-1.0 var exporter = new UniVRM10.Vrm10Exporter(AssetTextureUtil.IsTextureEditorAsset); var option = new VrmLib.ExportArgs(); exporter.Export(root, model, converter, option, AssetTextureUtil.GetTextureBytesWithMime, Meta ? Meta : m_tmpMeta); var exportedBytes = exporter.Storage.ToBytes(); m_logLabel += $"write to {path}...\n"; File.WriteAllBytes(path, exportedBytes); Debug.Log("exportedBytes: " + exportedBytes.Length); var assetPath = UniGLTF.UnityPath.FromFullpath(path); if (assetPath.IsUnderAssetsFolder) { // asset folder 内。import を発動 assetPath.ImportAsset(); } } catch (Exception ex) { m_logLabel += ex.ToString(); // rethrow throw; } }
void Export() { var path = ComDialog.Save("write file", "export.vrm"); if (string.IsNullOrEmpty(path)) { Debug.Log($"cancel save"); return; } Debug.Log($"save to {path}"); var exporter = new UniVRM10.RuntimeVrmConverter(); var meta = ScriptableObject.CreateInstance <UniVRM10.VRMMetaObject>(); meta.Name = ""; meta.Copyrights = ""; meta.Version = ""; meta.Authors = new[] { "PriMan" }; meta.ContactInformation = ""; meta.Reference = ""; meta.OtherPermissionUrl = ""; meta.OtherLicenseUrl = ""; var model = exporter.ToModelFrom10(m_builder.Root.gameObject, meta); foreach (var kv in exporter.Nodes) { kv.Value.HumanoidBone = m_builder.GetHumanBone(kv.Key.transform); } // normalize var modifier = new ModelModifier(model); modifier.SkinningBake(); VrmLib.ModelExtensionsForCoordinates.ConvertCoordinate(model, VrmLib.Coordinates.Gltf); var bytes = Vrm10.ModelExtensions.ToGlb(model); File.WriteAllBytes(path, bytes); }
////////////////////////////////////////////////////////////////////////// private void Awake() { m_ModelModifier = GetComponentInChildren <ModelModifier>(); m_TargetRow = Mathf.Clamp(m_TargetRow, 0, Grid.Instance.m_Column - 1); m_Behavior = GetComponent <BehaviorBase>(); m_Behavior.Master = this; m_Behavior.iInit(); transform.position = UnityRandom.BoundPoint(PlayerEntity.Instance.m_ZoneSpawn); // restore moves m_MovesLeft = m_MaxMoves; // add to reserve PlayerEntity.Instance.m_ReserveActors.Add(this); // increase danger level PlayerEntity.Instance.m_CurrentDangers += m_DangerLevel; // increase visitors count PlayerEntity.Instance.m_CurrentVisitors++; }
void OnExportClicked() { m_logLabel.text = ""; var rootObject = m_gameObjectField.value as GameObject; if (!ValidateRoot(rootObject)) { m_logLabel.text += "export aborted"; return; } // save dialog var path = EditorUtility.SaveFilePanel( "Save vrm", null, rootObject.name + EXTENSION, EXTENSION.Substring(1)); if (string.IsNullOrEmpty(path)) { return; } m_logLabel.text += $"export...\n"; try { var exporter = new UniVRM10.RuntimeVrmConverter(); var meta = m_meta.GetVRMMetaObject(); var model = exporter.ToModelFrom10(rootObject, meta); if (HasRotationOrScale(rootObject.transform)) { // 正規化 m_logLabel.text += $"normalize...\n"; var modifier = new ModelModifier(model); modifier.SkinningBake(); } // 右手系に変換 m_logLabel.text += $"convert to right handed coordinate...\n"; model.ConvertCoordinate(VrmLib.Coordinates.Gltf, ignoreVrm: false); var exportedBytes = GetGlb(model); m_logLabel.text += $"write to {path}...\n"; File.WriteAllBytes(path, exportedBytes); Debug.Log("exportedBytes: " + exportedBytes.Length); var assetPath = ToAssetPath(path); if (!string.IsNullOrEmpty(assetPath)) { AssetDatabase.ImportAsset(assetPath); } } catch (Exception ex) { m_logLabel.text += ex.ToString(); // rethrow throw; } }
public Modifier(ModelModifier modifiers) { Modifiers = modifiers; }