// remove mPoints from channel, just use target list, if targets.Count == 1 then use delta // first target goes into mPoints // guess we should update any targets who we have already, ie use name void LoadTargets(MegaMorphChan channel) { MegaMorph mr = (MegaMorph)target; string filename = EditorUtility.OpenFilePanel("Morph Targets", lastpath, "obj"); if (filename == null || filename.Length < 1) { return; } lastpath = filename; List <MegaTargetMesh> targets = MegaTargetMesh.LoadTargets(filename, mr.importScale, mr.flipyz, mr.negx); if (targets != null) { if (channel.mName == "Empty") { channel.mName = Path.GetFileNameWithoutExtension(filename); } // Now need to check that each target has correct num verts and face list matches for (int i = 0; i < targets.Count; i++) { MegaTargetMesh tm = targets[i]; if (tm.verts.Count != mr.oPoints.Length) { EditorUtility.DisplayDialog("Target Vertex count mismatch!", "Target " + tm.name + " has wrong number of verts", "OK"); } else { // See if we have a target with this name, if so update that MegaMorphTarget mt = channel.GetTarget(tm.name); if (mt == null) // add a new target { mt = new MegaMorphTarget(); mt.name = tm.name; channel.mTargetCache.Add(mt); } mt.points = tm.verts.ToArray(); //for ( int v = 0; v < mt.points.Length; v++ ) //{ //if ( mt.points[v] == mr.oPoints[v] ) //Debug.Log("Vert " + v + " isnt morphed"); //} } } channel.ResetPercent(); channel.Rebuild(mr); // rebuild delta for 1st channel } mr.BuildCompress(); }
public MegaMorphChan LoadChan(BinaryReader br) { MegaMorphChan chan = new MegaMorphChan(); chan.control = null; chan.showparams = false; chan.mTargetCache = new List<MegaMorphTarget>(); currentChan = chan; //Parse(br, ParseChan); MegaParse.Parse(br, ParseChan); MegaMorph mr = (MegaMorph)target; chan.Rebuild(mr); return chan; }
public MegaMorphChan LoadChan(BinaryReader br) { MegaMorphChan chan = new MegaMorphChan(); chan.control = null; chan.showparams = false; chan.mTargetCache = new List <MegaMorphTarget>(); currentChan = chan; //Parse(br, ParseChan); MegaParse.Parse(br, ParseChan); MegaMorph mr = (MegaMorph)target; chan.Rebuild(mr); return(chan); }
public MegaMorphChan LoadChan(BinaryReader br) { MegaMorphChan chan = new MegaMorphChan(); //Debug.Log("Load Chan"); chan.control = null; chan.showparams = false; chan.mTargetCache = new List<MegaMorphTarget>(); currentChan = chan; //Parse(br, ParseChan); MegaParse.Parse(br, ParseChan); for ( int i = 0; i < chan.mTargetCache.Count; i++ ) { if ( chan.mTargetCache[i].points == null || chan.mTargetCache[i].points.Length == 0 ) return null; } MegaMorph mr = (MegaMorph)target; chan.Rebuild(mr); return chan; }
// remove mPoints from channel, just use target list, if targets.Count == 1 then use delta // first target goes into mPoints // guess we should update any targets who we have already, ie use name void LoadTargets(MegaMorphChan channel) { MegaMorph mr = (MegaMorph)target; string filename = EditorUtility.OpenFilePanel("Morph Targets", lastpath, "obj"); if ( filename == null || filename.Length < 1 ) return; lastpath = filename; List<MegaTargetMesh> targets = MegaTargetMesh.LoadTargets(filename, mr.importScale, mr.flipyz, mr.negx); if ( targets != null ) { if ( channel.mName == "Empty" ) channel.mName = Path.GetFileNameWithoutExtension(filename); // Now need to check that each target has correct num verts and face list matches for ( int i = 0; i < targets.Count; i++ ) { MegaTargetMesh tm = targets[i]; if ( tm.verts.Count != mr.oPoints.Length ) EditorUtility.DisplayDialog("Target Vertex count mismatch!", "Target " + tm.name + " has wrong number of verts", "OK"); else { // See if we have a target with this name, if so update that MegaMorphTarget mt = channel.GetTarget(tm.name); if ( mt == null ) // add a new target { mt = new MegaMorphTarget(); mt.name = tm.name; channel.mTargetCache.Add(mt); } mt.points = tm.verts.ToArray(); //for ( int v = 0; v < mt.points.Length; v++ ) //{ //if ( mt.points[v] == mr.oPoints[v] ) //Debug.Log("Vert " + v + " isnt morphed"); //} } } channel.ResetPercent(); channel.Rebuild(mr); // rebuild delta for 1st channel } mr.BuildCompress(); }
// Still need to be able to add in unity meshes void DisplayTarget(MegaMorph morph, MegaMorphChan channel, MegaMorphTarget mt, int num) { PushCols(); EditorGUI.indentLevel = 1; mt.name = EditorGUILayout.TextField("Name", mt.name); mt.percent = EditorGUILayout.Slider("Percent", mt.percent, 0.0f, 100.0f); EditorGUILayout.BeginHorizontal(); if ( mt.points == null || mt.points.Length != morph.oPoints.Length) GUI.backgroundColor = new Color(0.5f, 0.5f, 0.5f); else GUI.backgroundColor = new Color(0.0f, 1.0f, 0.0f); if ( GUILayout.Button("Load") ) { LoadTarget(mt); } GUI.backgroundColor = new Color(1.0f, 0.5f, 0.5f); if ( GUILayout.Button("Delete") ) { MegaMorphTarget mt0 = channel.mTargetCache[0]; channel.mTargetCache.Remove(mt); channel.ResetPercent(); if ( channel.mTargetCache.Count > 0 && channel.mTargetCache[0] != mt0 ) channel.Rebuild(morph); } GUI.backgroundColor = new Color(1.0f, 1.0f, 0.5f); if ( GUILayout.Button("Up") ) { if ( num > 0 ) { SwapTargets(channel, num, num - 1); if ( num == 1 ) channel.Rebuild(morph); } } GUI.backgroundColor = new Color(0.5f, 1.0f, 1.0f); if ( GUILayout.Button("Dn") ) { if ( num < channel.mTargetCache.Count - 1 ) { SwapTargets(channel, num, num + 1); if ( num == 0 ) channel.Rebuild(morph); } } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = 0; PopCols(); }
// Still need to be able to add in unity meshes void DisplayTarget(MegaMorph morph, MegaMorphChan channel, MegaMorphTarget mt, int num) { PushCols(); EditorGUI.indentLevel = 1; mt.name = EditorGUILayout.TextField("Name", mt.name); mt.percent = EditorGUILayout.Slider("Percent", mt.percent, 0.0f, 100.0f); EditorGUILayout.BeginHorizontal(); if (mt.points == null || mt.points.Length != morph.oPoints.Length) { GUI.backgroundColor = new Color(0.5f, 0.5f, 0.5f); } else { GUI.backgroundColor = new Color(0.0f, 1.0f, 0.0f); } if (GUILayout.Button("Load")) { LoadTarget(mt); } GUI.backgroundColor = new Color(1.0f, 0.5f, 0.5f); if (GUILayout.Button("Delete")) { MegaMorphTarget mt0 = channel.mTargetCache[0]; channel.mTargetCache.Remove(mt); channel.ResetPercent(); if (channel.mTargetCache.Count > 0 && channel.mTargetCache[0] != mt0) { channel.Rebuild(morph); } } GUI.backgroundColor = new Color(1.0f, 1.0f, 0.5f); if (GUILayout.Button("Up")) { if (num > 0) { SwapTargets(channel, num, num - 1); if (num == 1) { channel.Rebuild(morph); } } } GUI.backgroundColor = new Color(0.5f, 1.0f, 1.0f); if (GUILayout.Button("Dn")) { if (num < channel.mTargetCache.Count - 1) { SwapTargets(channel, num, num + 1); if (num == 0) { channel.Rebuild(morph); } } } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = 0; PopCols(); }