public override void OnNodeAddedForAnchor(ISCNSceneRenderer renderer, SCNNode node, ARAnchor anchor) { base.OnNodeAddedForAnchor(renderer, node, anchor); SoundManager.PlaySound("miss"); var imageAnchor = anchor as ARImageAnchor; var refSize = imageAnchor.ReferenceImage.PhysicalSize; var box = new SCNBox { Width = refSize.Width * 1.75f, Length = refSize.Height * 1.75f, Height = 0.0001f, ChamferRadius = 0 }; box.FirstMaterial.Diffuse.Contents = ShaderScene.Random(); box.TileTexture(3); var pf = Prefabs[i++]; node.AddChildNode(new SCNNode { Geometry = box }); node.AddChildNode(pf); pf.Position = SCNVector3.Zero; pf.RunAction(SCNAction.RotateBy(0, 1.5f, 0, 0.01)); }
SCNNode CreateBanana() { //Create model if (bananaCollectable == null) { bananaCollectable = GameSimulation.LoadNodeWithName("banana", GameSimulation.PathForArtResource("level/banana.dae")); bananaCollectable.Scale = new SCNVector3(0.5f, 0.5f, 0.5f); SCNSphere sphereGeometry = SCNSphere.Create(40); SCNPhysicsShape physicsShape = SCNPhysicsShape.Create(sphereGeometry, new SCNPhysicsShapeOptions()); bananaCollectable.PhysicsBody = SCNPhysicsBody.CreateBody(SCNPhysicsBodyType.Kinematic, physicsShape); // Only collide with player and ground bananaCollectable.PhysicsBody.CollisionBitMask = GameCollisionCategory.Player | GameCollisionCategory.Ground; // Declare self in the banana category bananaCollectable.PhysicsBody.CategoryBitMask = GameCollisionCategory.Banana; // Rotate and Hover forever. bananaCollectable.Rotation = new SCNVector4(0.5f, 1f, 0.5f, -(nfloat)Math.PI / 4); SCNAction idleHoverGroupAction = SCNAction.Group(new SCNAction[] { BananaIdleAction, HoverAction }); SCNAction repeatForeverAction = SCNAction.RepeatActionForever(idleHoverGroupAction); bananaCollectable.RunAction(repeatForeverAction); } return(bananaCollectable.Clone()); }
private void AddPlanet(SCNVector3 sunPosition, float radious, string diffuse, string specular, string emission, string normal, float xPosition, double selfRotation, double sunRotation) { SCNNode parent = new SCNNode(); parent.Position = sunPosition; sceneView.Scene.RootNode.AddChildNode(parent); SCNNode planet = new SCNNode(); planet.Geometry = SCNSphere.Create(radious); planet.Geometry.FirstMaterial.Diffuse.Contents = string.IsNullOrWhiteSpace(diffuse) ? null : new UIImage(diffuse); planet.Geometry.FirstMaterial.Specular.Contents = string.IsNullOrWhiteSpace(specular) ? null : new UIImage(specular); planet.Geometry.FirstMaterial.Emission.Contents = string.IsNullOrWhiteSpace(emission) ? null : new UIImage(emission); planet.Geometry.FirstMaterial.Normal.Contents = string.IsNullOrWhiteSpace(normal) ? null : new UIImage(normal); planet.Position = new SCNVector3(xPosition, 0, 0); //TODO 3.2 Movimientos SCNAction selfAction = SCNAction.RotateBy(0, ConvertDegreesToRadians(360), 0, selfRotation); SCNAction selfForever = SCNAction.RepeatActionForever(selfAction); planet.RunAction(selfForever); SCNAction sunAction = SCNAction.RotateBy(0, ConvertDegreesToRadians(360), 0, sunRotation); SCNAction sunForever = SCNAction.RepeatActionForever(sunAction); parent.RunAction(sunForever); parent.AddChildNode(planet); }
public SCNAction RotationY(double time) { var action = SCNAction.RotateBy(0, 360, 0, time); var forever = SCNAction.RepeatActionForever(action); return(forever); }
void CollectFlower(SCNNode node) { if (node.ParentNode == null) { return; } SCNNode soundEmitter = SCNNode.Create(); soundEmitter.Position = node.Position; node.ParentNode.AddChildNode(soundEmitter); soundEmitter.RunAction(SCNAction.Sequence(new [] { SCNAction.PlayAudioSource(collectFlowerSound, true), SCNAction.RemoveFromParentNode() })); node.RemoveFromParentNode(); // Check if game is complete. bool gameComplete = GameView.DidCollectAFlower(); // Edit some particles. SCNMatrix4 particlePosition = soundEmitter.WorldTransform; particlePosition.M42 += 0.1f; GameView.Scene.AddParticleSystem(collectParticles, particlePosition); if (gameComplete) { ShowEndScreen(); } }
public void Show() { if (Opacity == 0) { RunAction(SCNAction.FadeIn(0.5f)); } }
public override void SetupSlide(PresentationViewController presentationViewController) { // Set the slide's title and subtitle and add some text TextManager.SetTitle("Materials"); TextManager.SetSubtitle("Property contents"); TextManager.AddBulletAtLevel("Color", 0); TextManager.AddBulletAtLevel("CGColorRef / NSColor / UIColor", 0); var node = SCNNode.Create(); node.Name = "material-cube"; node.Geometry = SCNBox.Create(W, W, W, W * 0.02f); Material = node.Geometry.FirstMaterial; Material.Diffuse.Contents = NSColor.Red; Object = node; node.Position = new SCNVector3(8, 11, 0); ContentNode.AddChildNode(node); node.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy((float)Math.PI * 2, new SCNVector3(0.4f, 1, 0), 4))); MaterialLayerSlideReference = this; }
public override void DidBeginContact(SCNPhysicsWorld world, SCNPhysicsContact contact) { var nodeA = contact.NodeA; var nodeB = contact.NodeB; SCNNode target = null; if (nodeA.PhysicsBody.CategoryBitMask == (int)BitMaskCategory.Pokemon) { target = nodeA; } else if (nodeB.PhysicsBody.CategoryBitMask == (int)BitMaskCategory.Pokemon) { target = nodeB; } if (target != null && !animatedNodes.Contains(target)) { var targetScale = target.Scale; animatedNodes.Add(target); target.RunAction(SCNAction.Sequence(new SCNAction[] { SCNAction.ScaleTo(0, 1.0f), SCNAction.ScaleTo(targetScale.X, 2.0f), }), () => { animatedNodes.Remove(target); }); } }
public void Hide() { if (Math.Abs(Opacity - 1.0) < Double.Epsilon) { RunAction(SCNAction.FadeOut(0.5f)); } }
private void ShowPatientDetails(ARReferenceImage detectedImage, SCNNode node) { // Highlight the QR Code? var width = detectedImage.PhysicalSize.Width; var length = detectedImage.PhysicalSize.Height; var planeNode = new PlaneNode(0, width, length, new SCNVector3(0, 0, 0), ""); planeNode.Opacity = 1f; float angle = (float)(-Math.PI / 2); planeNode.EulerAngles = new SCNVector3(angle, 0, 0); //node.AddChildNode(planeNode); // Get and Show information panels foreach (var informationPanelNode in GetPatientInformationPanels()) { var waitAction = SCNAction.Wait(0.1 * informationPanelNode.Number); var fadeInAction = SCNAction.FadeIn(1); var actionSequence = SCNAction.Sequence(new[] { waitAction, fadeInAction }); // Not sure I can run actions before adding. May have to add, then run. informationPanelNode.RunAction(actionSequence); informationPanelNode.EulerAngles = new SCNVector3(angle, 0, 0); node.AddChildNode(informationPanelNode); } }
public void CollideWithLava() { if (HitByLavaReset == true) { return; } PlayerCharacter.InRunAnimation = false; GameSimulation.Sim.PlaySound("ack.caf"); // Blink for a second SCNAction blinkOffAction = SCNAction.FadeOut(0.15f); SCNAction blinkOnAction = SCNAction.FadeIn(0.15f); SCNAction cycle = SCNAction.Sequence(new SCNAction[] { blinkOffAction, blinkOnAction }); SCNAction repeatCycle = SCNAction.RepeatAction(cycle, 17); HitByLavaReset = true; PlayerCharacter.RunAction(repeatCycle, () => { TimeAlongPath = 0; PlayerCharacter.Position = LocationAlongPath(TimeAlongPath); PlayerCharacter.Rotation = GetPlayerDirectionFromCurrentPosition(); HitByLavaReset = false; }); }
private void HandlerLongPress(UILongPressGestureRecognizer sender) { ARSCNView longPressScene = sender.View as ARSCNView; CoreGraphics.CGPoint longPressLocation = sender.LocationInView(longPressScene); SCNHitTestResult[] hitTest = longPressScene.HitTest(longPressLocation, new SCNHitTestOptions()); if (hitTest?.Any() != true) { return; } SCNNode node = hitTest.First().Node; if (sender.State == UIGestureRecognizerState.Began) { SCNAction rotateAction = SCNAction.RotateBy(0, ConvertDegreesToRadians(360f), 0, 1f); SCNAction rotateForever = SCNAction.RepeatActionForever(rotateAction); node.RunAction(rotateForever); } else if (sender.State == UIGestureRecognizerState.Ended) { node.RemoveAllActions(); } }
public override void DidOrderIn(PresentationViewController presentationViewController) { var banana = Utils.SCAddChildNode(ContentNode, "banana", "Scenes.scnassets/banana/banana", 5); banana.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2)); banana.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, NMath.PI * 2, 0, 1.5f))); banana.Position = new SCNVector3(2.5f, 5, 10); var gaussianBlurFilter = new CIGaussianBlur() { Radius = 10 }; gaussianBlurFilter.SetDefaults(); banana.Filters = new CIFilter[] { gaussianBlurFilter }; banana = (SCNNode)banana.Copy(); ContentNode.AddChildNode(banana); banana.Position = new SCNVector3(6, 5, 10); var pixellateFilter = new CIPixellate(); pixellateFilter.SetDefaults(); banana.Filters = new CIFilter[] { pixellateFilter }; banana = (SCNNode)banana.Copy(); ContentNode.AddChildNode(banana); banana.Position = new SCNVector3(9.5f, 5, 10); var filter = CIFilter.FromName("CIEdgeWork"); filter.SetDefaults(); banana.Filters = new CIFilter[] { filter }; }
// Once we create scene we need to position our AR model in it: public void PositionSceneObject(ARSCNView sceneView) { // Each session has to be configured. // We will use ARWorldTrackingConfiguration to have full access to device orientation, // rear camera, device position and to detect real-world flat surfaces: var configuration = new ARWorldTrackingConfiguration { PlaneDetection = ARPlaneDetection.Horizontal, LightEstimationEnabled = true }; // Once we have our configuration we need to run session with it. // ResetTracking will just reset tracking by session to start it again from scratch: sceneView.Session.Run(configuration, ARSessionRunOptions.ResetTracking); // Next we need to find main "node" in the .dae file. In this case it is called "ship": var shipNode = sceneView.Scene.RootNode.FindChildNode("ship", true); // Then we have to set position of AR object - below I would like to display it in front of camera: shipNode.Position = new SCNVector3(0.0f, 0.0f, -20f); // Next we need to add ship object to scene: sceneView.Scene.RootNode.AddChildNode(shipNode); // At the end I configured simple rotating animation to rotate ship object in front of camera: shipNode.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0f, 4f, 0, 5))); }
public void PositionScene(ARSCNView sceneView, string arLaunchType) { var arConfiguration = new ARWorldTrackingConfiguration { PlaneDetection = ARPlaneDetection.Horizontal, LightEstimationEnabled = true }; sceneView.Session.Run(arConfiguration, ARSessionRunOptions.ResetTracking); var sceneShipNode = sceneView.Scene.RootNode.FindChildNode("ship", true); sceneShipNode.Position = new SCNVector3(2f, -2f, -9f); var animationCycle = SCNAction.RepeatActionForever(SCNAction.RotateBy(0f, 6f, 0, 5)); var animationCrash = SCNAction.RepeatActionForever(SCNAction.RotateBy(0, (float)Math.PI, (float)Math.PI, (float)1)); var animationNormal = SCNAction.RepeatActionForever(SCNAction.RotateBy(0, 0, 0, 1)); var animationRotate = SCNAction.RepeatActionForever(SCNAction.RotateBy(0, 0, 2, 1)); var scenePivotNode = new SCNNode { Position = new SCNVector3(0.0f, 2.0f, 0.0f) }; scenePivotNode.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, -2, 0, 10))); sceneShipNode.RemoveFromParentNode(); scenePivotNode.AddChildNode(sceneShipNode); sceneView.Scene.RootNode.AddChildNode(scenePivotNode); sceneShipNode.Scale = new SCNVector3(0.1f, 0.1f, 0.1f); sceneShipNode.Position = new SCNVector3(2f, -2f, -3f); switch (arLaunchType) { case "Rotate Fly": sceneShipNode.RunAction(animationRotate); break; case "Crash Fly": sceneShipNode.RunAction(animationCrash); break; case "Cycle Fly": sceneShipNode.RunAction(animationCycle); break; case "Normal Fly": sceneShipNode.RunAction(animationNormal); break; default: scenePivotNode.RemoveAllActions(); scenePivotNode.RunAction(SCNAction.Unhide()); break; } }
void HandleCollideForCoconut(Coconut coconut) { // Remove coconut from the world after it has time to fall offscreen. coconut.RunAction(SCNAction.Wait(3.0), () => { coconut.RemoveFromParentNode(); GameLevel.Coconuts.Remove(coconut); }); }
/// <summary> /// Unhides the border. /// </summary> public void UnhideBorder() { if (this.borderNode.GetAction("unhide") == null) { this.borderNode.RemoveAction("hide"); this.borderNode.RunAction(SCNAction.FadeIn(0.5), "unhide"); this.borderNode.Hidden = false; } }
void ShowEndScreen() { gameIsComplete = true; // Add confettis SCNMatrix4 particlePosition = SCNMatrix4.CreateTranslation(0f, 8f, 0f); GameView.Scene.AddParticleSystem(confetti, particlePosition); // Congratulation title SKSpriteNode congrat = SKSpriteNode.FromImageNamed("Images/congratulations.png"); congrat.Position = new CGPoint(GameView.Bounds.Width / 2, GameView.Bounds.Height / 2); SKScene overlay = GameView.OverlayScene; congrat.XScale = congrat.YScale = 0; congrat.Alpha = 0; congrat.RunAction(SKAction.Group(new [] { SKAction.FadeInWithDuration(0.25), SKAction.Sequence(new [] { SKAction.ScaleTo(.55f, 0.25), SKAction.ScaleTo(.3f, 0.1), }) })); // Panda Image SKSpriteNode congratPanda = SKSpriteNode.FromImageNamed("Images/congratulations_pandaMax.png"); congratPanda.Position = new CGPoint(GameView.Bounds.Width / 2f, GameView.Bounds.Height / 2f - 90f); congratPanda.AnchorPoint = new CGPoint(.5f, 0f); congratPanda.XScale = congratPanda.YScale = 0f; congratPanda.Alpha = 0; congratPanda.RunAction(SKAction.Sequence(new [] { SKAction.WaitForDuration(.5f), SKAction.Sequence(new [] { SKAction.ScaleTo(.5f, 0.25), SKAction.ScaleTo(.4f, 0.1) }) })); overlay.AddChild(congratPanda); overlay.AddChild(congrat); // Stop music GameView.Scene.RootNode.RemoveAllAudioPlayers(); // Play the congrat sound. GameView.Scene.RootNode.AddAudioPlayer(SCNAudioPlayer.FromSource(victoryMusic)); // Animate the camera forever DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 1 * NanoSecondsPerSeond), () => { cameraYHandle.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0f, -1f, 0f, 3.0))); cameraXHandle.RunAction(SCNAction.RotateTo(-(float)Math.PI / 4f, 0f, 0f, 5.0)); }); }
public static SCNNode RotateForever(this SCNNode node, double duration) { var action = SCNAction.RepeatActionForever( SCNAction.RotateBy(0, .05f, 0, duration)); node.RunAction(action); return(node); }
public void PlayFootStep() { if (CurrentFloorMaterial == FloorMaterial.Air) { return; // We are in the air, no sound to play } int stepSoundIndex = Math.Min(StepsSoundCount - 1, new Random().Next(0, 32767) * StepsSoundCount); Node.RunAction(SCNAction.PlayAudioSource(steps[stepSoundIndex, (int)CurrentFloorMaterial], false)); }
private SCNAction PulseAction() { var pulseOutAction = SCNAction.FadeOpacityTo(0.4f, 0.5f); var pulseInAction = SCNAction.FadeOpacityTo(1.0f, 0.5f); pulseOutAction.TimingMode = SCNActionTimingMode.EaseInEaseOut; pulseInAction.TimingMode = SCNActionTimingMode.EaseInEaseOut; return(SCNAction.RepeatActionForever(SCNAction.Sequence(new SCNAction[] { pulseOutAction, pulseInAction }))); }
private void PlayFootStep() { if (this.groundNode != null && this.IsWalking) { // We are in the air, no sound to play. // Play a random step sound. int randSnd = (new Random().Next(0, 32767) * Character.StepsCount); var stepSoundIndex = Math.Min(Character.StepsCount - 1, randSnd); characterNode.RunAction(SCNAction.PlayAudioSource(this.steps[stepSoundIndex], false)); } }
private void Close(bool flash = false) { if (!IsOpen || IsAnimating) { return; } IsAnimating = true; StopPulsing(FocusSquareNode()); // Close animation SCNTransaction.Begin(); SCNTransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); SCNTransaction.AnimationDuration = AnimationDuration / 2f; FocusSquareNode().Opacity = 0.99f; SCNTransaction.SetCompletionBlock(() => { SCNTransaction.Begin(); SCNTransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); SCNTransaction.AnimationDuration = AnimationDuration / 4f; foreach (var segment in segments) { segment.Close(); } SCNTransaction.SetCompletionBlock(() => { IsAnimating = false; }); SCNTransaction.Commit(); }); SCNTransaction.Commit(); // Scale/bounce animation FocusSquareNode().AddAnimation(ScaleAnimation("transform.scale.x"), "transform.scale.y"); FocusSquareNode().AddAnimation(ScaleAnimation("transform.scale.y"), "transform.scale.y"); FocusSquareNode().AddAnimation(ScaleAnimation("transform.scale.z"), "transform.scale.z"); // Flash? if (flash) { var waitAction = SCNAction.Wait(AnimationDuration * 0.75f); var fadeInAction = SCNAction.FadeOpacityTo(0.25f, AnimationDuration * 0.125f); var fadeOutAction = SCNAction.FadeOpacityTo(0.0f, AnimationDuration * 0.125f); FillPlane.RunAction(SCNAction.Sequence(new SCNAction[] { waitAction, fadeInAction, fadeOutAction })); var flashSquareAction = FlashAnimation(AnimationDuration * 0.25f); foreach (var segment in Segments) { segment.RunAction(SCNAction.Sequence(new[] { waitAction, flashSquareAction })); } } IsOpen = false; }
/// <summary> /// Hides the border. /// </summary> public void HideBorder(double duration = 0.5d) { if (this.borderNode.GetAction("hide") == null) { this.borderNode.RemoveAction("unhide"); this.borderNode.RunAction(SCNAction.FadeOut(duration), "hide", () => { this.borderNode.Hidden = true; }); } }
public void DidHitEnemy() { this.model.RunAction(SCNAction.Group(new SCNAction[] { SCNAction.PlayAudioSource(this.hitEnemySound, false), SCNAction.Sequence(new SCNAction[] { SCNAction.Wait(0.5), SCNAction.PlayAudioSource(explodeEnemySound, false) }) })); }
public void CollideWithCoconut(SCNNode coconut, SCNVector3 contactPoint) { // No more collisions. Let it bounce away and fade out. coconut.PhysicsBody.CollisionBitMask = 0; coconut.RunAction(SCNAction.Sequence(new SCNAction[] { SCNAction.Wait(1.0), SCNAction.FadeOut(1.0), SCNAction.RemoveFromParentNode() }), () => { Coconuts.Remove((Coconut)coconut); }); // Decrement score int amountToDrop = Score / 10; amountToDrop = Math.Max(1, amountToDrop); amountToDrop = Math.Min(10, amountToDrop); if (amountToDrop > Score) { amountToDrop = Score; } Score -= amountToDrop; // Throw bananas float spacing = 40f; for (int x = 0; x < amountToDrop; x++) { SCNNode banana = CreateBanana(); RootNode.AddChildNode(banana); banana.Position = contactPoint; banana.PhysicsBody.CategoryBitMask = GameCollisionCategory.NoCollide; banana.PhysicsBody.CollisionBitMask = GameCollisionCategory.Ground; SCNVector3 endPoint = SCNVector3.Zero; endPoint.X -= (spacing * x) + spacing; SCNAction flyoff = SCNAction.MoveBy(endPoint, MathUtils.RandomPercent() * 0.750f); flyoff.TimingMode = SCNActionTimingMode.EaseInEaseOut; banana.RunAction(flyoff, () => { banana.PhysicsBody.CategoryBitMask = GameCollisionCategory.Banana; banana.PhysicsBody.CollisionBitMask = GameCollisionCategory.Ground | GameCollisionCategory.Player; }); Bananas.Add(banana); } PlayerCharacter.InHitAnimation = true; }
public SCNNode Create3DNode() { SCNScene jellyfishScn = SCNScene.FromFile("art.scnassets/Jellyfish"); SCNNode jellyfishNode = jellyfishScn.RootNode.FindChildNode("Jellyfish", false); jellyfishNode.Scale = new SCNVector3(0.019f, 0.019f, 0.019f); jellyfishNode.Position = new SCNVector3(0, 0, 0); // Animate the opacity to 100% over 0.75 seconds jellyfishNode.Opacity = 0; jellyfishNode.RunAction(SCNAction.FadeIn(0.75)); return(jellyfishNode); }
public void TimingFunction_5058() { var a = new SCNAction(); Assert.Null(a.TimingFunction2, "TimingFunction2"); Assert.Null(a.TimingFunction, "TimingFunction"); a.TimingFunction2 = (float f) => { timeFunctionValue = f; return(timeFunctionValue); }; Assert.That(a.TimingFunction2(Single.NaN), Is.NaN, "value returned"); a.TimingFunction(Single.NaN); Assert.That(timeFunctionValue, Is.NaN, "TimingFunction assigned from TimingFunction2"); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); // Create a session configuration var configuration = new ARWorldTrackingConfiguration { PlaneDetection = ARPlaneDetection.Horizontal, LightEstimationEnabled = true }; // Run the view's session SceneView.Session.Run(configuration, ARSessionRunOptions.ResetTracking); // randomly choose a point to place the Earth var pos = new SCNVector3(-2f, 0f, -2f); // earth r=0.2 var globe = SCNSphere.Create(0.2f); var globeNode = new SCNNode { Position = pos, Geometry = globe }; globeNode.Geometry.Materials = LoadMaterials(); //globeNode.Transform = SCNMatrix4.CreateRotationX(0.4101524f); // 23.5 degrees SceneView.Scene.RootNode.AddChildNode(globeNode); globeNode.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, 1, 0, 3))); //moon r=0.08, orbit=0.6 var pivotNode = new SCNNode { Position = new SCNVector3(0, 0, 0) }; pivotNode.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, 1, 0, 5))); var moon = SCNSphere.Create(0.08f); var moonNode = new SCNNode { Geometry = moon }; //moonNode.Position = new SCNVector3(pos.X - 0.6f, pos.Y + 0.1f, pos.Z); moonNode.Position = new SCNVector3(0.6f, 0.1f, pos.Z); moonNode.Geometry.Materials = LoadMoonMaterials(); pivotNode.AddChildNode(moonNode); globeNode.AddChildNode(pivotNode); }
private SCNAction FlashAnimation(double duration) { var action = SCNAction.CustomAction(duration, (node, elapsedTime) => { // animate color from HSB 48/100/100 to 48/30/100 and back var elapsedTimePercentage = elapsedTime / (float)duration; var saturation = 2.8f * (elapsedTimePercentage - 0.5f) * (elapsedTimePercentage - 0.5f) + 0.3f; var material = node.Geometry.FirstMaterial; if (material != null) { material.Diffuse.Contents = UIColor.FromHSBA(0.1333f, saturation, 1.0f, 1.0f); } }); return(action); }