Example #1
0
        private void SetAnimationsToFrame(int frameNum)
        {
            if (currentAnimation == null)
            {
                return;
            }

            float animFrameNum = frameNum;

            foreach (var drawable in Runtime.abstractGlDrawables)
            {
                if (drawable is STSkeleton)
                {
                    currentAnimation.SetFrame(animFrameNum);
                    currentAnimation.NextFrame((STSkeleton)drawable);
                }
            }
        }
Example #2
0
        private void SetAnimationsToFrame(int frameNum)
        {
            if (currentAnimation == null)
            {
                return;
            }

            var viewport = LibraryGUI.Instance.GetActiveViewport();

            if (viewport == null || viewport.scene == null)
            {
                return;
            }

            var anim = currentAnimation.Tag;

            float animFrameNum = frameNum;


            if (anim is MaterialAnimation)
            {
                ((MaterialAnimation)anim).SetFrame(animFrameNum);
                ((MaterialAnimation)anim).NextFrame(viewport);
            }
            else if (anim is VisibilityAnimation)
            {
                ((VisibilityAnimation)anim).SetFrame(animFrameNum);
                ((VisibilityAnimation)anim).NextFrame(viewport);
            }
            else if (anim is CameraAnimation)
            {
                ((CameraAnimation)anim).SetFrame(animFrameNum);
                ((CameraAnimation)anim).NextFrame(viewport);
            }
            else if (anim is LightAnimation)
            {
                ((LightAnimation)anim).SetFrame(animFrameNum);
                ((LightAnimation)anim).NextFrame(viewport);
            }
            else if (anim is FogAnimation)
            {
                ((FogAnimation)anim).SetFrame(animFrameNum);
                ((FogAnimation)anim).NextFrame(viewport);
            }
            else //Play a skeletal animation if it's not the other types
            {
                foreach (var drawable in viewport.scene.objects)
                {
                    if (drawable is STSkeleton)
                    {
                        currentAnimation.SetFrame(animFrameNum);
                        currentAnimation.NextFrame((STSkeleton)drawable);
                    }
                }
            }


            //Add frames to the playing animation
            currentAnimation.Frame += 1f;

            //Reset it when it reaches the total frame count
            if (currentAnimation.Frame >= currentAnimation.FrameCount)
            {
                currentAnimation.Frame = 0;
            }
        }
Example #3
0
        public static void CreateANIM(string fname, Animation a, STSkeleton vbn)
        {
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@fname))
            {
                file.WriteLine("animVersion 1.1;");
                file.WriteLine("mayaVersion 2014 x64;\ntimeUnit ntscf;\nlinearUnit cm;\nangularUnit deg;\nstartTime 1;\nendTime " + (a.FrameCount + 1) + ";");

                a.SetFrame(a.FrameCount - 1);             //from last frame
                for (int li = 0; li < a.FrameCount; ++li) //go through each frame with nextFrame
                {
                    a.NextFrame(vbn);
                }
                a.NextFrame(vbn);  //go on first frame

                int i = 0;

                // writing node attributes
                foreach (STBone b in vbn.getBoneTreeOrder())
                {
                    i = vbn.boneIndex(b.Text);

                    if (a.HasBone(b.Text))
                    {
                        // write the bone attributes
                        // count the attributes
                        Animation.KeyNode n = a.GetBone(b.Text);
                        int ac = 0;


                        if (n.XPOS.HasAnimation())
                        {
                            file.WriteLine("anim translate.translateX translateX " + b.Text + " 0 0 " + (ac++) + ";");
                            writeKey(file, n.XPOS, n, a.Size(), "translateX");
                            file.WriteLine("}");
                        }
                        if (n.YPOS.HasAnimation())
                        {
                            file.WriteLine("anim translate.translateY translateY " + b.Text + " 0 0 " + (ac++) + ";");
                            writeKey(file, n.YPOS, n, a.Size(), "translateY");
                            file.WriteLine("}");
                        }
                        if (n.ZPOS.HasAnimation())
                        {
                            file.WriteLine("anim translate.translateZ translateZ " + b.Text + " 0 0 " + (ac++) + ";");
                            writeKey(file, n.ZPOS, n, a.Size(), "translateZ");
                            file.WriteLine("}");
                        }
                        if (n.XROT.HasAnimation())
                        {
                            file.WriteLine("anim rotate.rotateX rotateX " + b.Text + " 0 0 " + (ac++) + ";");
                            writeKey(file, n.XROT, n, a.Size(), "rotateX");
                            file.WriteLine("}");
                        }
                        if (n.YROT.HasAnimation())
                        {
                            file.WriteLine("anim rotate.rotateY rotateY " + b.Text + " 0 0 " + (ac++) + ";");
                            writeKey(file, n.YROT, n, a.Size(), "rotateY");
                            file.WriteLine("}");
                        }
                        if (n.ZROT.HasAnimation())
                        {
                            file.WriteLine("anim rotate.rotateZ rotateZ " + b.Text + " 0 0 " + (ac++) + ";");
                            writeKey(file, n.ZROT, n, a.Size(), "rotateZ");
                            file.WriteLine("}");
                        }

                        if (n.XSCA.HasAnimation())
                        {
                            file.WriteLine("anim scale.scaleX scaleX " + b.Text + " 0 0 " + (ac++) + ";");
                            writeKey(file, n.XSCA, n, a.Size(), "scaleX");
                            file.WriteLine("}");
                        }
                        if (n.YSCA.HasAnimation())
                        {
                            file.WriteLine("anim scale.scaleY scaleY " + b.Text + " 0 0 " + (ac++) + ";");
                            writeKey(file, n.YSCA, n, a.Size(), "scaleY");
                            file.WriteLine("}");
                        }
                        if (n.ZSCA.HasAnimation())
                        {
                            file.WriteLine("anim scale.scaleZ scaleZ " + b.Text + " 0 0 " + (ac++) + ";");
                            writeKey(file, n.ZSCA, n, a.Size(), "scaleZ");
                            file.WriteLine("}");
                        }
                    }
                    else
                    {
                        file.WriteLine("anim " + b.Text + " 0 0 0;");
                    }
                }
            }
        }