public static void BuildBind(IINode _node, int _parentId, Pose _pose) { DualQuaternion DQ = GetBoneBindDQ(_node); Joint _joint = new Joint(_pose.joints.Count, _node.Name, _parentId, DQ, DualQuaternion.Identity); _pose.joints.Add(_joint); int childrensNb = _node.NumberOfChildren; for (int i = 0; i < childrensNb; i++) { if (!_node.GetChildNode(i).Name.EndsWith("Nub")) { BuildBind(_node.GetChildNode(i), _joint.id, _pose); } } }
public static bool ExportAnimation(int[] _frames, string _filename, int _samplingRate) { List <IINode> nodes = GetSelection(); foreach (IINode _node in nodes) { IIDerivedObject theObj = (IIDerivedObject)_node.ObjectRef; IInterval interval = maxGlobal.Interval.Create(); interval.SetInfinite(); maxGlobal.IGameInterface.InitialiseIGame(false); for (int m = 0; m < theObj.Modifiers.Count; m++) { IModifier theModifier = theObj.GetModifier(m); if (theModifier.ClassName == "Skin") { IISkin _skin = (IISkin)theModifier.GetInterface((InterfaceID)(0x00010000)); IINode _bone = _skin.GetBone(0); int nbBones = _skin.NumBones; List <string> boneName = new List <string>(); for (int b = 0; b < nbBones; b++) { boneName.Add(_skin.GetBone(b).Name); } #region create bindPose World Pose bindPose = new Pose("bindPose"); BuildBind(_bone, -1, bindPose); #endregion ROD_core.Graphics.Animation.Clip_Skinning clip = new ROD_core.Graphics.Animation.Clip_Skinning(); clip.sequencesData = new List <Pose>(); clip.sequencesTiming = new List <TimeSpan>(); for (int f = 0; f < _frames.Length; f++) { // create Pose at frame (_frame) Pose _pose = new Pose("frame" + _frames[f].ToString()); BuildLJoint(_bone, -1, _pose, _frames, f, _samplingRate, bindPose); clip.sequencesData.Add(_pose); clip.sequencesTiming.Add(TimeSpan.FromSeconds(_frames[f] / 30)); } clip.saveToFile(_filename); } } } return(true); }
public static void BuildLJoint(IINode _node, int _parentId, Pose _pose, int[] _frames, int _f, int _samplingRate, Pose _bindPose) { DualQuaternion LDQ = GetBoneLocalDQ(_node, _frames, _f); CurveHandle curve = GetCurve(_node, _frames, _f, _samplingRate); Joint _joint = new Joint(_pose.joints.Count, _node.Name, _parentId, DualQuaternion.Identity, LDQ, curve); _pose.joints.Add(_joint); int childrensNb = _node.NumberOfChildren; for (int i = 0; i < childrensNb; i++) { if (!_node.GetChildNode(i).Name.EndsWith("Nub")) { BuildLJoint(_node.GetChildNode(i), _joint.id, _pose, _frames, _f, _samplingRate, _bindPose); } } }
public static bool ExportSkeleton(string _filenameSkeleton) { List <IINode> nodes = GetSelection(); foreach (IINode _node in nodes) { IIDerivedObject theObj = (IIDerivedObject)_node.ObjectRef; IInterval interval = maxGlobal.Interval.Create(); interval.SetInfinite(); maxGlobal.IGameInterface.InitialiseIGame(false); for (int m = 0; m < theObj.Modifiers.Count; m++) { IModifier theModifier = theObj.GetModifier(m); if (theModifier.ClassName == "Skin") { IISkin _skin = (IISkin)theModifier.GetInterface((InterfaceID)(0x00010000)); IINode _bone = _skin.GetBone(0); int nbBones = _skin.NumBones; List <string> boneName = new List <string>(); for (int b = 0; b < nbBones; b++) { boneName.Add(_skin.GetBone(b).Name); } #region create bindPose World Pose bindPose = new Pose("bindPose"); BuildBind(_bone, -1, bindPose); #endregion Skeleton skelete = new Skeleton("skelete", bindPose); skelete.saveToFile(_filenameSkeleton); } } } return(true); }
public static void BuildLJoint(IINode _node, int _parentId, Pose _pose, int _frame, ROD_ExportG r) { DualQuaternion WDQ = GetBoneWorldDQ(_node, _frame, r); DualQuaternion LDQ = GetBoneLocalDQ(_node, _frame, r); Joint _joint = new Joint(_pose.joints.Count, _node.Name, _parentId, WDQ, LDQ); _pose.joints.Add(_joint); int childrensNb = _node.NumberOfChildren; for (int i = 0; i < childrensNb; i++) { if (!_node.GetChildNode(i).Name.EndsWith("Nub")) { BuildLJoint(_node.GetChildNode(i), _joint.id, _pose, _frame, r); } } }
public static void BuildBind(IINode _node, int _parentId, Pose _pose, ROD_ExportG r) { DualQuaternion DQ = GetBoneBindDQ(_node, r); Joint _joint = new Joint(_pose.joints.Count, _node.Name, _parentId, DQ, DualQuaternion.Identity); _pose.joints.Add(_joint); int childrensNb = _node.NumberOfChildren; for (int i = 0; i < childrensNb; i++) { if (!_node.GetChildNode(i).Name.EndsWith("Nub")) { BuildBind(_node.GetChildNode(i), _joint.id, _pose, r); } } }
public static bool Bone_To(List<int> _frames, string _filename, string _filenameSkeleton) { ROD_ExportG r = new ROD_ExportG(); foreach (uint _handle in SelectedNodes) { IINode _node = r.maxInterface.GetINodeByHandle(_handle); IIDerivedObject theObj = (IIDerivedObject)_node.ObjectRef; IInterval interval = r.maxGlobal.Interval.Create(); interval.SetInfinite(); r.maxGlobal.IGameInterface.InitialiseIGame(false); for (int m = 0; m < theObj.Modifiers.Count; m++) { IModifier theModifier = theObj.GetModifier(m); if (theModifier.ClassName == "Skin") { IISkin _skin = (IISkin)theModifier.GetInterface((InterfaceID)(0x00010000)); IINode _bone = _skin.GetBone(0); int nbBones = _skin.NumBones; List<string> boneName = new List<string>(); for (int b = 0; b < nbBones; b++) { boneName.Add(_skin.GetBone(b).Name); } #region create bindPose World Pose bindPose = new Pose("bindPose"); BuildBind(_bone, -1, bindPose, r); #endregion #region create bindPose Local off /* Joint BLjoint = BuildBindLocal(_bone, null, r); List<Joint> jointsBL = BLjoint.GetEnumerable().ToList(); for (int i = 0; i < jointsBL.Count; i++) { int Id = boneName.IndexOf(jointsBL[i].name); jointsBL[i].id = Id; } Pose TposeL = new Pose("TPoseL", BLjoint); */ #endregion Skeleton skelete = new Skeleton("skelete", bindPose); skelete.saveToFile(_filenameSkeleton); ROD_core.Graphics.Animation.Clip_Skinning clip = new ROD_core.Graphics.Animation.Clip_Skinning(); clip.sequencesData = new List<Pose>(); clip.sequencesTiming = new List<TimeSpan>(); for (int f = 0; f < _frames.Count; f++) { // create Pose at frame (_frame) Pose _pose = new Pose("frame" + _frames[f].ToString()); BuildLJoint(_bone, -1, _pose, _frames[f], r); clip.sequencesData.Add(_pose); clip.sequencesTiming.Add(TimeSpan.FromSeconds(_frames[f] / 3)); } clip.saveToFile(_filename); } } } return true; }