Esempio n. 1
0
        private void CacheDerivedData()
        {
            // Abort if cached data is still valid.
            if (!_isDirty)
            {
                return;
            }

            _isDirty = false;

            // Check bone indices.
            if (RootBoneIndexA < 0 || RootBoneIndexA >= SkeletonMapper.SkeletonPoseA.Skeleton.NumberOfBones)
            {
                throw new IndexOutOfRangeException("RootBoneIndexA is out of range.");
            }
            if (TipBoneIndexA < 0 || TipBoneIndexA >= SkeletonMapper.SkeletonPoseA.Skeleton.NumberOfBones)
            {
                throw new IndexOutOfRangeException("TipBoneIndexA is out of range.");
            }

            if (RootBoneIndexB < 0 || RootBoneIndexB >= SkeletonMapper.SkeletonPoseB.Skeleton.NumberOfBones)
            {
                throw new IndexOutOfRangeException("RootBoneIndexB is out of range.");
            }
            if (TipBoneIndexB < 0 || TipBoneIndexB >= SkeletonMapper.SkeletonPoseB.Skeleton.NumberOfBones)
            {
                throw new IndexOutOfRangeException("TipBoneIndexB is out of range.");
            }

            if (!SkeletonMapper.SkeletonPoseA.IsAncestorOrSelf(RootBoneIndexA, TipBoneIndexA))
            {
                throw new AnimationException("RootBoneIndexA and TipBoneIndexA do not form a valid bone chain.");
            }
            if (!SkeletonMapper.SkeletonPoseB.IsAncestorOrSelf(RootBoneIndexB, TipBoneIndexB))
            {
                throw new AnimationException("RootBoneIndexB and TipBoneIndexB do not form a valid bone chain.");
            }

            if (!MapFromBindPose)
            {
                // Create a nested direct bone mapper.
                _directBoneMapper = new DirectBoneMapper(RootBoneIndexA, RootBoneIndexB)
                {
                    MapTranslations = false,

                    // Since the bone mapper is not added to a skeleton mapper, we must set
                    // SkeletonMapper manually.
                    SkeletonMapper = SkeletonMapper,
                };
            }
            else
            {
                _directBoneMapper = null;
            }
        }
Esempio n. 2
0
        private void CacheDerivedData()
        {
            // Abort if cached data is still valid.
              if (!_isDirty)
            return;

              _isDirty = false;

              // Check bone indices.
              if (RootBoneIndexA < 0 || RootBoneIndexA >= SkeletonMapper.SkeletonPoseA.Skeleton.NumberOfBones)
            throw new IndexOutOfRangeException("RootBoneIndexA is out of range.");
              if (TipBoneIndexA < 0 || TipBoneIndexA >= SkeletonMapper.SkeletonPoseA.Skeleton.NumberOfBones)
            throw new IndexOutOfRangeException("TipBoneIndexA is out of range.");

              if (RootBoneIndexB < 0 || RootBoneIndexB >= SkeletonMapper.SkeletonPoseB.Skeleton.NumberOfBones)
            throw new IndexOutOfRangeException("RootBoneIndexB is out of range.");
              if (TipBoneIndexB < 0 || TipBoneIndexB >= SkeletonMapper.SkeletonPoseB.Skeleton.NumberOfBones)
            throw new IndexOutOfRangeException("TipBoneIndexB is out of range.");

              if (!SkeletonMapper.SkeletonPoseA.IsAncestorOrSelf(RootBoneIndexA, TipBoneIndexA))
            throw new AnimationException("RootBoneIndexA and TipBoneIndexA do not form a valid bone chain.");
              if (!SkeletonMapper.SkeletonPoseB.IsAncestorOrSelf(RootBoneIndexB, TipBoneIndexB))
            throw new AnimationException("RootBoneIndexB and TipBoneIndexB do not form a valid bone chain.");

              if (!MapFromBindPose)
              {
            // Create a nested direct bone mapper.
            _directBoneMapper = new DirectBoneMapper(RootBoneIndexA, RootBoneIndexB)
            {
              MapTranslations = false,

              // Since the bone mapper is not added to a skeleton mapper, we must set
              // SkeletonMapper manually.
              SkeletonMapper = SkeletonMapper,
            };
              }
              else
              {
            _directBoneMapper = null;
              }
        }