void LoadTarget(MegaMorphTarget mt) { MegaMorph mr = (MegaMorph)target; string filename = EditorUtility.OpenFilePanel("Morph Target", 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 && targets.Count > 0) { MegaTargetMesh tm = targets[0]; if (tm.verts.Count != mr.oPoints.Length) { EditorUtility.DisplayDialog("Target Vertex count mismatch!", "Target " + tm.name + " has wrong number of verts", "OK"); } else { mt.points = tm.verts.ToArray(); mt.name = tm.name; } } }
// 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 LoadBase(MegaMorph morph) { string filename = EditorUtility.OpenFilePanel("Morph Base", lastpath, "obj"); if (filename == null || filename.Length < 1) { return; } lastpath = filename; List <MegaTargetMesh> targets = MegaTargetMesh.LoadTargets(filename, 1.0f, false, false); //morph.importScale, morph.flipyz, morph.negx); // only use first if (targets != null && targets.Count > 0) { if (!TryMapping(targets, morph)) { // No match found EditorUtility.DisplayDialog("Mapping Failed!", "Mapping of " + Path.GetFileNameWithoutExtension(filename) + " failed!", "OK"); EditorUtility.ClearProgressBar(); return; } } }