public static string WriteJoint(this MJoint joint, string tap) { string desc = ""; string nl = System.Environment.NewLine; if (joint.Parent == null) { desc += "HIERARCHY" + nl + "ROOT "; } else { desc += tap + "JOINT "; } desc += joint.ID; desc += nl + tap + "{" + nl; tap += " "; desc += tap; desc += "OFFSET " + joint.Position.X + " " + joint.Position.Y + " " + joint.Position.Z + nl + tap; desc += "ROTATION " + joint.Rotation.W + " " + joint.Rotation.X + " " + joint.Rotation.Y + " " + joint.Rotation.Z + nl + tap; desc += "CHANNELS "; if (joint.Channels != null) { foreach (MChannel c in joint.Channels) { desc += c.ToString() + " "; } } desc += nl; return(desc); }
private static MJoint ParseJoint(string[] mos, ref int line_counter, List <MJoint> mjointList) { // parse lines for current joint // Todo: Improve parser to consider empty lines and comments string name = mos[line_counter].Split(' ')[1]; float[] off = parseFloatParameter(mos[line_counter + 2].Split(' '), 3); MVector3 offset = new MVector3(off[0], off[1], off[2]); float[] quat = parseFloatParameter(mos[line_counter + 3].Split(' '), 4); MQuaternion rotation = new MQuaternion(quat[1], quat[2], quat[3], quat[0]); string[] channels = mos[line_counter + 4].Replace("CHANNELS", "").Split(' '); List <MChannel> mchannels = MapChannels(channels); MJoint mjoint = new MJoint(name, MJointTypeMap[name], offset, rotation); mjoint.Channels = mchannels; mjointList.Add(mjoint); line_counter += 5; while (!mos[line_counter].Contains("}")) { MJoint child = ParseJoint(mos, ref line_counter, mjointList); child.Parent = mjoint.ID; } line_counter += 1; return(mjoint); }
/// <summary> /// Returns a deep copy of a MJoint /// </summary> /// <param name="transform"></param> /// <returns></returns> public static MJoint Clone(this MJoint bone) { return(new MJoint(bone.ID, bone.Type, bone.Position.Clone(), bone.Rotation.Clone()) { Parent = bone.Parent, }); }
public void Read(TProtocol iprot) { iprot.IncrementRecursionDepth(); try { bool isset_Joints = false; TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.List) { { Joints = new List <MJoint>(); TList _list16 = iprot.ReadListBegin(); for (int _i17 = 0; _i17 < _list16.Count; ++_i17) { MJoint _elem18; _elem18 = new MJoint(); _elem18.Read(iprot); Joints.Add(_elem18); } iprot.ReadListEnd(); } isset_Joints = true; } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.Map) { { Properties = new Dictionary <string, string>(); TMap _map19 = iprot.ReadMapBegin(); for (int _i20 = 0; _i20 < _map19.Count; ++_i20) { string _key21; string _val22; _key21 = iprot.ReadString(); _val22 = iprot.ReadString(); Properties[_key21] = _val22; } iprot.ReadMapEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); if (!isset_Joints) { throw new TProtocolException(TProtocolException.INVALID_DATA, "required field Joints not set"); } } finally { iprot.DecrementRecursionDepth(); } }
public void Read(TProtocol iprot) { iprot.IncrementRecursionDepth(); try { bool isset_AvatarID = false; bool isset_Joints = false; TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { AvatarID = iprot.ReadString(); isset_AvatarID = true; } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.List) { { Joints = new List <MJoint>(); TList _list12 = iprot.ReadListBegin(); for (int _i13 = 0; _i13 < _list12.Count; ++_i13) { MJoint _elem14; _elem14 = new MJoint(); _elem14.Read(iprot); Joints.Add(_elem14); } iprot.ReadListEnd(); } isset_Joints = true; } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); if (!isset_AvatarID) { throw new TProtocolException(TProtocolException.INVALID_DATA, "required field AvatarID not set"); } if (!isset_Joints) { throw new TProtocolException(TProtocolException.INVALID_DATA, "required field Joints not set"); } } finally { iprot.DecrementRecursionDepth(); } }