예제 #1
0
        private void ExtractAnimation(SCNSceneSource sceneSource)
        {
            // In this scene objects are animated separately using long animations
            // playing 3 successive animations. We will group these long animations
            // and then split the group in 3 different animation groups.
            // We could also have used three DAEs (one per animation).

            var animationIDs = sceneSource.GetIdentifiersOfEntries(new Class("CAAnimation"));

            var animationCount = animationIDs.Length;
            var longAnimations = new CAAnimation [animationCount];

            var maxDuration = 0.0;

            for (var index = 0; index < animationCount; index++)
            {
                var animation = (CAAnimation)sceneSource.GetEntryWithIdentifier(animationIDs [index].ToString(), new Class("CAAnimation"));
                if (animation != null)
                {
                    maxDuration            = Math.Max(maxDuration, animation.Duration);
                    longAnimations [index] = animation;
                }
            }

            var longAnimationsGroup = new CAAnimationGroup();

            longAnimationsGroup.Animations = longAnimations;
            longAnimationsGroup.Duration   = maxDuration;

            var idleAnimationGroup = (CAAnimationGroup)longAnimationsGroup.Copy();

            idleAnimationGroup.TimeOffset   = 6.45833333333333f;
            IdleAnimationGroup              = CAAnimationGroup.CreateAnimation();
            IdleAnimationGroup.Animations   = new CAAnimation[] { idleAnimationGroup };
            IdleAnimationGroup.Duration     = 24.71f - 6.45833333333333f;
            IdleAnimationGroup.RepeatCount  = float.MaxValue;
            IdleAnimationGroup.AutoReverses = true;

            var animationGroup1 = (CAAnimationGroup)longAnimationsGroup.Copy();

            AnimationGroup1                 = CAAnimationGroup.CreateAnimation();
            AnimationGroup1.Animations      = new CAAnimation[] { animationGroup1 };
            AnimationGroup1.Duration        = 1.4f;
            AnimationGroup1.FadeInDuration  = 0.1f;
            AnimationGroup1.FadeOutDuration = 0.5f;

            var animationGroup2 = (CAAnimationGroup)longAnimationsGroup.Copy();

            animationGroup2.TimeOffset      = 3.666666666666667f;
            AnimationGroup2                 = CAAnimationGroup.CreateAnimation();
            AnimationGroup2.Animations      = new CAAnimation[] { animationGroup2 };
            AnimationGroup2.Duration        = 6.416666666666667f - 3.666666666666667f;
            AnimationGroup2.FadeInDuration  = 0.1f;
            AnimationGroup2.FadeOutDuration = 0.5f;
        }
예제 #2
0
		public static CAAnimation LoadAnimationNamed (string animationName, string sceneName)
		{
			NSUrl url = NSBundle.MainBundle.GetUrlForResource (sceneName, "dae");
			var options = new SCNSceneLoadingOptions () {
				ConvertToYUp = true
			};

			var sceneSource = new SCNSceneSource (url, options);
			var animation = (CAAnimation)sceneSource.GetEntryWithIdentifier (animationName, new Class (typeof(CAAnimation)));

			return animation;
		}
예제 #3
0
        public static CAAnimation LoadAnimationNamed(string animationName, string sceneName)
        {
            NSUrl url     = NSBundle.MainBundle.GetUrlForResource(sceneName, "dae");
            var   options = new SCNSceneLoadingOptions()
            {
                ConvertToYUp = true
            };

            var sceneSource = new SCNSceneSource(url, options);
            var animation   = (CAAnimation)sceneSource.GetEntryWithIdentifier(animationName, new Class(typeof(CAAnimation)));

            return(animation);
        }
예제 #4
0
		private void ExtractAnimation (SCNSceneSource sceneSource)
		{
			// In this scene objects are animated separately using long animations
			// playing 3 successive animations. We will group these long animations
			// and then split the group in 3 different animation groups.
			// We could also have used three DAEs (one per animation).

			var animationIDs = sceneSource.GetIdentifiersOfEntries (new Class ("CAAnimation"));

			var animationCount = animationIDs.Length;
			var longAnimations = new CAAnimation [animationCount];

			var maxDuration = 0.0;

			for (var index = 0; index < animationCount; index++) {
				var animation = (CAAnimation)sceneSource.GetEntryWithIdentifier (animationIDs [index].ToString (), new Class ("CAAnimation"));
				if (animation != null) {
					maxDuration = Math.Max (maxDuration, animation.Duration);
					longAnimations [index] = animation;
				}
			}

			var longAnimationsGroup = new CAAnimationGroup ();
			longAnimationsGroup.Animations = longAnimations;
			longAnimationsGroup.Duration = maxDuration;

			var idleAnimationGroup = (CAAnimationGroup)longAnimationsGroup.Copy ();
			idleAnimationGroup.TimeOffset = 6.45833333333333f;
			IdleAnimationGroup = CAAnimationGroup.CreateAnimation ();
			IdleAnimationGroup.Animations = new CAAnimation[] { idleAnimationGroup };
			IdleAnimationGroup.Duration = 24.71f - 6.45833333333333f;
			IdleAnimationGroup.RepeatCount = float.MaxValue;
			IdleAnimationGroup.AutoReverses = true;

			var animationGroup1 = (CAAnimationGroup)longAnimationsGroup.Copy ();
			AnimationGroup1 = CAAnimationGroup.CreateAnimation ();
			AnimationGroup1.Animations = new CAAnimation[] { animationGroup1 };
			AnimationGroup1.Duration = 1.4f;
			animationGroup1.FadeInDuration = 0.1f;
			animationGroup1.FadeOutDuration = 0.5f;

			var animationGroup2 = (CAAnimationGroup)longAnimationsGroup.Copy ();
			animationGroup2.TimeOffset = 3.666666666666667f;
			AnimationGroup2 = CAAnimationGroup.CreateAnimation ();
			AnimationGroup2.Animations = new CAAnimation[] { animationGroup2 };
			AnimationGroup2.Duration = 6.416666666666667f - 3.666666666666667f;
			animationGroup2.FadeInDuration = 0.1f;
			animationGroup2.FadeOutDuration = 0.5f;
		}