Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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;
        }