Ejemplo n.º 1
0
            void ICommand.Execute(object parameter)
            {
                AnimPoseComponent apc = parameter as AnimPoseComponent;

                apc.ref_object.parentScene.resetPoses();
            }
Ejemplo n.º 2
0
        //TODO: It would be nice if I didn't have to do make the method public, but it needs a lot of work on the
        //AnimPoseComponent class to temporarily store the selected pose frames, while also in the model.update method

        //Locator Animation Stuff

        public Dictionary <string, Matrix4> loadPose()
        {
            if (animPoseComponentID < 0)
            {
                return(new Dictionary <string, Matrix4>());
            }

            AnimPoseComponent            apc          = _components[animPoseComponentID] as AnimPoseComponent;
            Dictionary <string, Matrix4> posematrices = new Dictionary <string, Matrix4>();

            foreach (TkAnimNodeData node in apc._poseFrameData.NodeData)
            {
                List <OpenTK.Quaternion> quats        = new List <OpenTK.Quaternion>();
                List <Vector3>           translations = new List <Vector3>();
                List <Vector3>           scales       = new List <Vector3>();

                //We should interpolate frame shit over all the selected Pose Data

                //Gather all the transformation data for all the pose factors
                for (int i = 0; i < apc._poseData.Count; i++)
                //for (int i = 0; i < 1; i++)
                {
                    //Get Pose Frame
                    int poseFrameIndex = apc._poseData[i].PActivePoseFrame;

                    Vector3           v_t, v_s;
                    OpenTK.Quaternion lq;
                    //Fetch Rotation Quaternion
                    lq  = NMSUtils.fetchRotQuaternion(node, apc._poseFrameData, poseFrameIndex);
                    v_t = NMSUtils.fetchTransVector(node, apc._poseFrameData, poseFrameIndex);
                    v_s = NMSUtils.fetchScaleVector(node, apc._poseFrameData, poseFrameIndex);

                    quats.Add(lq);
                    translations.Add(v_t);
                    scales.Add(v_s);
                }

                float      fact = 1.0f / quats.Count;
                Quaternion fq   = new Quaternion();
                Vector3    f_vt = new Vector3();
                Vector3    f_vs = new Vector3();


                fq   = quats[0];
                f_vt = translations[0];
                f_vs = scales[0];

                //Interpolate all data
                for (int i = 1; i < quats.Count; i++)
                {
                    //Method A: Interpolate
                    //Quaternion.Slerp(fq, quats[i], 0.5f);
                    //Vector3.Lerp(f_vt, translations[i], 0.5f);
                    //Vector3.Lerp(f_vs, scales[i], 0.5f);

                    //Addup
                    f_vs *= scales[i];
                }

                //Generate Transformation Matrix
                //Matrix4 poseMat = Matrix4.CreateScale(f_vs) * Matrix4.CreateFromQuaternion(fq) * Matrix4.CreateTranslation(f_vt);
                //Matrix4 poseMat = Matrix4.CreateScale(f_vs) * Matrix4.CreateFromQuaternion(fq);
                Matrix4 poseMat = Matrix4.CreateScale(f_vs);
                posematrices[node.Node] = poseMat;
            }

            return(posematrices);
        }
Ejemplo n.º 3
0
            void ICommand.Execute(object parameter)
            {
                AnimPoseComponent apc = parameter as AnimPoseComponent;

                apc.ref_object.parentScene.applyPoses(apc.ref_object.loadPose());
            }