//[Export ("renderer:didApplyAnimationsAtTime:")] public void DidApplyAnimations(SCNSceneRenderer renderer, double timeInSeconds) { if (IkActive) { // update the influence factor of the IK constraint based on the animation progress var currProgress = (float)(Attack.Speed * (timeInSeconds - AnimationStartTime) / AnimationDuration); //clamp currProgress = (float)Math.Max(0, currProgress); currProgress = (float)Math.Min(1, currProgress); if (currProgress >= 1) { IkActive = false; } float middle = 0.5f; float f; // smoothly increate from 0% to 50% then smoothly decrease from 50% to 100% if (currProgress > middle) { f = (1.0f - currProgress) / (1.0f - middle); } else { f = currProgress / middle; } Ik.InfluenceFactor = f; LookAt.InfluenceFactor = 1 - f; } }
public void Update(double deltaTime, SCNSceneRenderer aRenderer) { // Based on gamestate: // ingame: Move the character if running. // ingame: prevent movement of the character past our level bounds. // ingame: perform logic for the player character. // any: move the directional light with any player movement. // ingame: update the coconuts kinematically. // ingame: perform logic for each monkey. // ingame: because our camera could have moved, update the transforms needs to fly // collected bananas from the player (world space) to score (screen space) var appDelegate = SharedAppDelegate.AppDelegate; var currentState = GameSimulation.Sim.CurrentGameState; // Move character along path if walking. MoveCharacterAlongPathWith(deltaTime, currentState); // Based on the time along path, rotation the character to face the correct direction. PlayerCharacter.Rotation = GetPlayerDirectionFromCurrentPosition(); if (currentState == GameState.InGame) { PlayerCharacter.Update(deltaTime); } // Move the light UpdateSunLightPosition(); if (currentState == GameState.PreGame || currentState == GameState.PostGame || currentState == GameState.Paused) { return; } foreach (MonkeyCharacter monkey in Monkeys) { monkey.Update(deltaTime); } // Update timer and check for Game Over. SecondsRemaining -= deltaTime; if (SecondsRemaining < 0.0) { DoGameOver(); } // update the player's SP position. SCNVector3 playerPosition = PlayerCharacter.WorldTransform.GetPosition(); screenSpacePlayerPosition = appDelegate.Scene.ProjectPoint(playerPosition); // Update the SP position of the score label CGPoint pt = ScoreLabelLocation; worldSpaceLabelScorePosition = appDelegate.Scene.UnprojectPoint(new SCNVector3(pt.X, pt.Y, screenSpacePlayerPosition.Z)); }
public void RendererUpdateAtTime(SCNSceneRenderer renderer, double updateAtTime) { if (Session?.CurrentFrame == null) { return; } // Vital for memory: Single location to set current frame! (Note: Assignment disposes existing frame -- see `set` ViewController.CurrentFrame = Session.CurrentFrame; UpdateFocusSquare(); // If light estimation is enabled, update the intensity of the model's lights and the environment map var lightEstimate = ViewController.CurrentFrame.LightEstimate; if (lightEstimate != null) { SceneView.Scene.EnableEnvironmentMapWithIntensity((float)(lightEstimate.AmbientIntensity / 40f), serialQueue); } else { SceneView.Scene.EnableEnvironmentMapWithIntensity(40f, serialQueue); } }
public void Update (double deltaTime, SCNSceneRenderer aRenderer) { // Based on gamestate: // ingame: Move the character if running. // ingame: prevent movement of the character past our level bounds. // ingame: perform logic for the player character. // any: move the directional light with any player movement. // ingame: update the coconuts kinematically. // ingame: perform logic for each monkey. // ingame: because our camera could have moved, update the transforms needs to fly // collected bananas from the player (world space) to score (screen space) var appDelegate = SharedAppDelegate.AppDelegate; var currentState = GameSimulation.Sim.CurrentGameState; // Move character along path if walking. MoveCharacterAlongPathWith (deltaTime, currentState); // Based on the time along path, rotation the character to face the correct direction. PlayerCharacter.Rotation = GetPlayerDirectionFromCurrentPosition (); if (currentState == GameState.InGame) PlayerCharacter.Update (deltaTime); // Move the light UpdateSunLightPosition (); if (currentState == GameState.PreGame || currentState == GameState.PostGame || currentState == GameState.Paused) return; foreach (MonkeyCharacter monkey in Monkeys) monkey.Update (deltaTime); // Update timer and check for Game Over. SecondsRemaining -= deltaTime; if (SecondsRemaining < 0.0) DoGameOver (); // update the player's SP position. SCNVector3 playerPosition = PlayerCharacter.WorldTransform.GetPosition (); screenSpacePlayerPosition = appDelegate.Scene.ProjectPoint (playerPosition); // Update the SP position of the score label CGPoint pt = ScoreLabelLocation; worldSpaceLabelScorePosition = appDelegate.Scene.UnprojectPoint (new SCNVector3 (pt.X, pt.Y, screenSpacePlayerPosition.Z)); }
//[Export ("renderer:didApplyAnimationsAtTime:")] public void DidApplyAnimations (SCNSceneRenderer renderer, double timeInSeconds) { if (IkActive) { // update the influence factor of the IK constraint based on the animation progress var currProgress = (nfloat)(Attack.Speed * (timeInSeconds - AnimationStartTime) / AnimationDuration); //clamp currProgress = NMath.Max (0, currProgress); currProgress = NMath.Min (1, currProgress); if (currProgress >= 1) { IkActive = false; } float middle = 0.5f; nfloat f; // smoothly increate from 0% to 50% then smoothly decrease from 50% to 100% if (currProgress > middle) { f = (1.0f - currProgress) / (1.0f - middle); } else { f = currProgress / middle; } Ik.InfluenceFactor = f; LookAt.InfluenceFactor = 1 - f; } }
public void RendererUpdateAtTime(SCNSceneRenderer renderer, double updateAtTime) { gamePlay.Update(); }
public virtual void DidSimulatePhysics(SCNSceneRenderer renderer, double timeInSeconds) { GameLevel.Update(deltaTime, renderer); }
public virtual void DidSimulatePhysics (SCNSceneRenderer renderer, double timeInSeconds) { GameLevel.Update (deltaTime, renderer); }