// 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(); }
void LoadMorph() { MegaMorph mr = (MegaMorph)target; //Modifiers mod = mr.GetComponent<Modifiers>(); // Do this at start and store string filename = EditorUtility.OpenFilePanel("Morph File", lastpath, "mor"); if (filename == null || filename.Length < 1) { return; } lastpath = filename; // Clear what we have mr.chanBank.Clear(); ParseFile(filename, MorphCallback); mr.animate = false; float looptime = 0.0f; // Set Looptime and animate if there is an anim for (int i = 0; i < mr.chanBank.Count; i++) { MegaMorphChan mc = mr.chanBank[i]; if (mc.control != null) { mr.animate = true; float t = mc.control.Times[mc.control.Times.Length - 1]; if (t > looptime) { looptime = t; } } } if (mr.animate) { mr.looptime = looptime; } mr.compressedmem = 0; mr.BuildCompress(); }
void LoadMorph() { MegaMorph mr = (MegaMorph)target; //Modifiers mod = mr.GetComponent<Modifiers>(); // Do this at start and store string filename = EditorUtility.OpenFilePanel("Morph File", lastpath, "mor"); if (filename == null || filename.Length < 1) { return; } lastpath = filename; startchan = 0; bool opt = true; if (mr.chanBank != null && mr.chanBank.Count > 0) { opt = EditorUtility.DisplayDialog("Channel Import Option", "Channels already present, do you want to 'Add' or 'Replace' channels in this file?", "Add", "Replace"); } // Clear what we have if (opt) { startchan = mr.chanBank.Count; } else { mr.chanBank.Clear(); } ParseFile(filename, MorphCallback); mr.animate = false; float looptime = 0.0f; // Set Looptime and animate if there is an anim for (int i = 0; i < mr.chanBank.Count; i++) { MegaMorphChan mc = mr.chanBank[i]; if (mc.control != null) // ISSUE: On 2nd load we suddenly have controls for no reason { mr.animate = true; if (mc.control.Times != null && mc.control.Times.Length > 0) { float t = mc.control.Times[mc.control.Times.Length - 1]; if (t > looptime) { looptime = t; } } } } if (mr.animate) { mr.looptime = looptime; } mr.compressedmem = 0; mr.BuildCompress(); }