Пример #1
0
        public static bool Export_To(string _filepath)
        {
            List <IINode> nodes = GetSelection();

            foreach (IINode _node in nodes)
            {
                IIDerivedObject _gObject = (IIDerivedObject)_node.ObjectRef;
                IClass_ID       classID  = maxGlobal.Class_ID.Create((uint)BuiltInClassIDA.TRIOBJ_CLASS_ID, 0);
                ITriObject      _mObject = (ITriObject)_gObject.ObjRef.ConvertToType(0, classID);
                IMesh           _mMesh   = _mObject.Mesh;
                _mMesh.BuildNormals();
                IIDerivedObject theObj = (IIDerivedObject)_node.ObjectRef;
                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));
                        IISkinContextData _skinContext = _skin.GetContextInterface(_node);
                        ComputeVertexData(_mMesh, _skinContext, semantic, _filepath);
                    }
                }
            }
            return(true);
        }
Пример #2
0
        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);
        }
Пример #3
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);
        }