void AddEnvelopes(GmdcGroup g, Ambertation.Scenes.Mesh m, GmdcElement bonee, GmdcElement bonewighte, Hashtable jointmap) { if (bonee != null && true) { int pos = 0; foreach (SimPe.Plugin.Gmdc.GmdcElementValueOneInt vi in bonee.Values) { byte[] data = vi.Bytes; IntArrayList used = new IntArrayList(); for (int datapos = 0; datapos < 3; datapos++) //we can only store 3 bone weights { byte b = data[datapos]; if (b != 0xff && b < g.UsedJoints.Count) { int bnr = g.UsedJoints[b]; if (used.Contains(bnr)) { continue; } used.Add(bnr); Ambertation.Scenes.Joint nj = jointmap[bnr] as Ambertation.Scenes.Joint; if (nj != null) { double w = 1; if (bonewighte != null) { if (bonewighte.Values.Count > pos) { SimPe.Plugin.Gmdc.GmdcElementValueBase v = bonewighte.Values[pos]; if (datapos < v.Data.Length) { w = v.Data[datapos]; } } } //if there is no envelope for nj, make sure we get a new one //with pos 0-Weights inserted Ambertation.Scenes.Envelope e = m.GetJointEnvelope(nj, pos); e.Weights.Add(w); //added = true; } } } pos++; m.SyncEnvelopeLenghts(pos); //fill all unset EnvelopeWeights with 0 } // bonee.Values } }
/// <summary> /// Recusrivley add all SubJoints /// </summary> /// <param name="start"></param> /// <param name="relmap"></param> /// <param name="l"></param> static void SortJointsRec(int start, System.Collections.Hashtable relmap, IntArrayList l) { if (start == -1) { return; } if (l.Contains(start)) { return; } l.Add(start); foreach (int k in relmap.Keys) { if ((int)relmap[k] == start) { SortJointsRec(k, relmap, l); } } }