Esempio n. 1
0
        private void LoadBVHFile(FileInfo file)
        {
            BVHMotionData bvhMotionData;
            BVHNode       bvhRoot = BVHNode.ReadBVH(file, out bvhMotionData);

            MotionData motionData = new MotionData();

            motionData.FPS = 1.0 / bvhMotionData.FrameTime;

            Bone rootBone = BVHNode.ToBones(bvhRoot, null, bvhMotionData, motionData);

            Kinematic = new KinematicVM(new KinematicStructure(rootBone));
            Animator  = new KinematicAnimatorVM(Kinematic, motionData);
        }
Esempio n. 2
0
        public KinematicAnimatorVM(KinematicVM kinematic, MotionData motionData)
        {
            this.Kinematic  = kinematic;
            this.MotionData = motionData;

            PlayCommand  = new RelayCommand(Play, CanPlay);
            PauseCommand = new RelayCommand(Pause, CanPause);
            ClearCommand = new RelayCommand(ClearData, CanClear);

            timer = new DispatcherTimer(DispatcherPriority.Normal);
            TimeSpan interval = TimeSpan.FromSeconds(1.0 / motionData.FPS);

            timer.Interval = interval;
            timer.Tick    += OnTimerTick;
        }
Esempio n. 3
0
        public static Bone ToBones(BVHNode bvhNode, Bone parent, BVHMotionData bvhMotionData, MotionData resultMotionData)
        {
            Bone result = new Bone(parent, name: bvhNode.Name, offset: bvhNode.Offset);

            if (bvhNode.Type != BVHNodeTypes.EndSite)
            {
                resultMotionData.Data.Add(result, bvhMotionData.Data[bvhNode].ToList());
            }

            foreach (BVHNode item in bvhNode.Children)
            {
                result.Children.Add(ToBones(item, result, bvhMotionData, resultMotionData));
            }

            return(result);
        }