Beispiel #1
0
        public static DualQuaternion GetBoneWorldDQ(IINode _node, int _frame)
        {
            IInterval interval = maxGlobal.Interval.Create();

            interval.SetInfinite();
            IIGameNode     GNode            = maxGlobal.IGameInterface.GetIGameNode(_node);
            int            _ticks_per_frame = maxGlobal.TicksPerFrame;
            IGMatrix       _node_Gmatrix    = GNode.GetWorldTM(_frame * _ticks_per_frame);
            DualQuaternion DQ = _node_Gmatrix.convertToDQ();

            return(DQ);
        }
Beispiel #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);
        }
Beispiel #3
0
        /// <summary>
        /// This keeps track if it's a placeholder node - that means you won't be able to click it, text is red, ...
        /// </summary>
        //public bool Placeholder{ get; private set; }

        #endregion

        /// <summary>
        /// Creates a real BaseNode
        /// </summary>
        public BaseNode(IINode iNode, bool isPolyObject)
        {
            m_Global = GlobalInterface.Instance;

            //Initialize our mesh Struct
            Mesh = new MeshStruct(m_Global);

            //Initialize our dictionary
            m_ElementNodeDictionary = new Dictionary <ushort, ElementNode>();

            INode  = iNode;
            Name   = iNode.Name;
            Handle = iNode.Handle;

            SetIsPolyObject(isPolyObject);

            m_Forever = m_Global.Interval.Create();
            m_Forever.SetInfinite();
        }
Beispiel #4
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);
        }