public void Update(FrameTime frameTime) { if (!IsEnabled) { return; } CheckControllerState(controllerLeftHand, leftController, ref leftSubscribed, ref previousLeftControllerState); CheckControllerState(controllerRightHand, rightController, ref rightSubscribed, ref previousRightControllerState); if (SteamVR_Actions._default.GrabGrip.GetStateDown(SteamVR_Input_Sources.LeftHand)) { LeftButtonPressed?.Invoke(controllerLeftHand.transform); } if (SteamVR_Actions._default.GrabGrip.GetStateUp(SteamVR_Input_Sources.LeftHand)) { LeftButtonReleased?.Invoke(controllerLeftHand.transform); } if (SteamVR_Actions._default.GrabGrip.GetStateDown(SteamVR_Input_Sources.RightHand)) { RightButtonPressed?.Invoke(controllerRightHand.transform); } if (SteamVR_Actions._default.GrabGrip.GetStateUp(SteamVR_Input_Sources.RightHand)) { RightButtonReleased?.Invoke(controllerRightHand.transform); } }
public override void Draw(FrameTime frameTime, BoundingArea viewBoundingArea) { for (var i = 0; i < this._numberOfRenderPasses; i++) { base.Draw(frameTime, viewBoundingArea); } }
public void Update(FrameTime frameTime) { if (!IsEnabled) { return; } if (SteamVR_Actions.default_NavigateNext.GetStateDown(SteamVR_Input_Sources.RightHand)) { inputService.OnInputEvent(new KeyEventArgs { ComplexEventType = KeyEventType.Down, KeyModifyers = KeyModifyers.None, EventKey = Key.Right, HasFocus = true, State = new KeyboardState(NoKeys), Viewport = null }); } if (SteamVR_Actions.default_NavigatePrev.GetStateDown(SteamVR_Input_Sources.RightHand)) { inputService.OnInputEvent(new KeyEventArgs { ComplexEventType = KeyEventType.Down, KeyModifyers = KeyModifyers.None, EventKey = Key.Left, HasFocus = true, State = new KeyboardState(NoKeys), Viewport = null }); } }
/** * Called on every frame, control the state of the buttons. * * @param unusedframeTime */ private void OnFrameUpdate(FrameTime unusedframeTime) { // If the model has not been placed yet, disable the buttons. if (anchorNode == null) { if (animationButton.Enabled) { animationButton.BackgroundTintList = ColorStateList.ValueOf(Android.Graphics.Color.Gray); animationButton.Enabled = false; hatButton.BackgroundTintList = ColorStateList.ValueOf(Android.Graphics.Color.Gray); hatButton.Enabled = false; } } else { if (!animationButton.Enabled) { animationButton.BackgroundTintList = ColorStateList.ValueOf(new Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.colorAccent))); animationButton.Enabled = true; hatButton.Enabled = true; hatButton.BackgroundTintList = ColorStateList.ValueOf(new Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.colorPrimary))); } } }
//NOTE: It is important to note that when we do something for a phase, it keeps being true till the end. // For example, if we disable movement on frame 5, it keeps being disabled until the end. private void DisplayFrameTimes() { for (int i = 0; i < frameTimes.Length; i++) { ref FrameTime frameTime = ref frameTimes[i]; Debug.Log("FrameTime " + i + ": " + frameTime.activated + ", " + frameTime.phase + ", " + frameTime.effect); }
public void Update(FrameTime frameTime) { this._timePassed += frameTime.SecondsPassed; var lastDrop = -10; while (this._timePassed > this._dropTime) { var currentDrop = this._random.Next(0, SpawnWidth * 2); while (currentDrop == lastDrop) { currentDrop = this._random.Next(0, SpawnWidth * 2); } if (this._foodQueue.Any()) { var food = this._foodQueue.Dequeue(); var xPosition = (currentDrop - SpawnWidth) * 0.5f; var yPosition = this._camera.ViewHeight + 1f; food.SetWorldPosition(new Vector2(xPosition, yPosition)); food.HasBeenHit = false; food.Velocity = new Vector2(0f, -this.GetFallSpeed()); food.IsEnabled = true; this.Scene.AddComponent(food); } this._timePassed -= this._dropTime; } }
public FlySpawnSystem(FrameTime time, PondSimState pond, FlyData flyData) { mPond = pond; mFlyData = flyData; mTime = time; mRandom = new Random(); }
public void Update(FrameTime frameTime) { if (this.LivingState == PlayerLivingState.Alive) { this._currentStance.Update(frameTime, this._inputManager); this.State = new PlayerState(this._currentStance.Stance, this.WorldTransform.Position, this.Velocity); this.ChangeAnimation(); this.LocalPosition += this.Velocity * (float)frameTime.SecondsPassed; if (this.IsOutOfBounds()) { this.LivingState = PlayerLivingState.Dead; this._spriteAnimator.Stop(true); } foreach (var creature in this._creatures.Where(x => !x.IsDead)) { if (this.BoundingArea.Overlaps(creature.BoundingArea)) { this._crunchAudioPlayer.Stop(); this.LivingState = PlayerLivingState.SpecialDead; this._crunchAudioPlayer.Play(); break; } } } }
public void EndFrame() { float realtimeSinceStartup = Time.realtimeSinceStartup; float num = realtimeSinceStartup - lastAssetUpdate; if (num >= 10f) { lastAssetUpdate = realtimeSinceStartup; if (AutomaticMemorySampling) { UpdateAssetMemoryUsage(); } } updateMetrics(); num = realtimeSinceStartup - lastTime; lastTime = realtimeSinceStartup; FrameTime.UpdateValue(num * 1000f); frameCount++; num = realtimeSinceStartup - lastFPSUpdate; if (num >= 1f) { lastFPSUpdate = lastTime; FramesPerSecond.UpdateValue((int)Math.Round((float)frameCount / num)); frameCount = 0uL; } }
/// <inheritdoc /> public override void Update(FrameTime frameTime, InputState inputState) { foreach (var entity in this.Scene.UpdateableEntities) { entity.Update(frameTime, inputState); } }
private void SetupLoop(IEventSender eventSender) { var renderLoopDispatcher = di.Get <IRenderLoopDispatcher>(); var inputProviders = di.GetMulti <IUcInputProvider>(); eventSender.OnGUIEvent += () => { foreach (var inputProvider in inputProviders) { inputProvider.OnGui(); } }; eventSender.UpdateEvent += () => { renderControl.OnUpdate(); foreach (var inputProvider in inputProviders) { inputProvider.OnUpdate(); } var frameTime = new FrameTime(Time.realtimeSinceStartup, Time.deltaTime); eventRoutingService.FireEvent <INewFrameEvent>(new NewFrameEvent(frameTime)); // todo: remove this renderLoopDispatcher.OnLoop(frameTime); }; eventSender.LateUpdateEvent += () => { var frameTime = new FrameTime(Time.realtimeSinceStartup, Time.deltaTime); eventRoutingService.FireEvent <ILateUpdateEvent>(new LateUpdateEvent(frameTime)); }; eventSender.FixedUpdateEvent += () => { eventRoutingService.FireEvent <IFixedUpdateEvent>(new FixedUpdateEvent()); }; }
protected override void OnPaint(PaintEventArgs e) { if (DesignView.Context == null || GameEngine.IsInError) { e.Graphics.Clear(DesignView.BackColor); if (GameEngine.IsInError) { e.Graphics.DrawString(GameEngine.CriticalError, Font, Brushes.Red, 1, 1); } return; } FrameTime ft = DesignView.GetFrameTime(); GameEngine.SetGameLevel(DesignView.Context.Cast <NativeObjectAdapter>()); GameEngine.Update(ft.TotalTime, ft.ElapsedTime, false); Render(); // draw selection if (IsPicking) { Rectangle rect = MakeRect(FirstMousePoint, CurrentMousePoint); if (rect.Width > 0 && rect.Height > 0) { e.Graphics.DrawRectangle(s_marqueePen, rect); } } }
public void Update() { double lag = (Timing.GetHiResCurrentTime() - m_lastUpdateTime) + m_updateLagRemainder; if (lag < UpdateStep) { return; // ealy return } if (UpdateType == UpdateType.Paused) { m_lastUpdateTime = Timing.GetHiResCurrentTime(); FrameTime fr = new FrameTime(m_simulationTime, 0.0f); m_gameEngine.Update(fr, UpdateType); m_updateLagRemainder = 0.0; } else { // set upper limit of update calls const int MaxUpdates = 3; int updateCount = 0; while (lag >= UpdateStep && updateCount < MaxUpdates) { m_lastUpdateTime = Timing.GetHiResCurrentTime(); FrameTime fr = new FrameTime(m_simulationTime, (float)UpdateStep); m_gameEngine.Update(fr, UpdateType); m_simulationTime += UpdateStep; lag -= UpdateStep; updateCount++; } } }
public void Update(FrameTime frameTime) { var viewFrame = realProps.GetFrame(); var distanceDelta = Math.Min(realProps.GetDistance(), Math.Abs(viewFrame.Eye.Z)) * frameTime.DeltaSeconds; if (keyboardInputProvider.IsKeyPressed(Key.W)) { realProps.Eye += viewFrame.Forward * distanceDelta; } if (keyboardInputProvider.IsKeyPressed(Key.S)) { realProps.Eye -= viewFrame.Forward * distanceDelta; } if (keyboardInputProvider.IsKeyPressed(Key.D)) { realProps.Eye += viewFrame.Right * distanceDelta; } if (keyboardInputProvider.IsKeyPressed(Key.A)) { realProps.Eye -= viewFrame.Right * distanceDelta; } if (keyboardInputProvider.IsKeyPressed(Key.Space)) { realProps.Eye += Vector3.UnitZ * distanceDelta; } if (keyboardInputProvider.IsKeyPressed(Key.C)) { realProps.Eye -= Vector3.UnitZ * distanceDelta; } var amount = Math.Min(20f * distanceDelta, 1f); visibleProps = Props.Lerp(visibleProps, realProps, amount); }
public void Update(FrameTime frameTime) { if (teleport.activeInHierarchy != IsEnabled) { teleport.SetActive(IsEnabled); } }
private void UpdateHandJoints(HandTracker handTracker, FrameTime frameTime) { if (handTracker.TryLocateHandJoints(frameTime, handJointLocations)) { ApplyWrist(handProxy.Wrist, HandJoint.Wrist); Apply(handProxy.ThumbMetacarpal, HandJoint.ThumbMetacarpal); Apply(handProxy.ThumbProximal, HandJoint.ThumbProximal); Apply(handProxy.ThumbDistal, HandJoint.ThumbDistal); Apply(handProxy.ThumbTip, HandJoint.ThumbTip); Apply(handProxy.IndexMetacarpal, HandJoint.IndexMetacarpal); Apply(handProxy.IndexProximal, HandJoint.IndexProximal); Apply(handProxy.IndexIntermediate, HandJoint.IndexIntermediate); Apply(handProxy.IndexDistal, HandJoint.IndexDistal); Apply(handProxy.IndexTip, HandJoint.IndexTip); Apply(handProxy.MiddleMetacarpal, HandJoint.MiddleMetacarpal); Apply(handProxy.MiddleProximal, HandJoint.MiddleProximal); Apply(handProxy.MiddleIntermediate, HandJoint.MiddleIntermediate); Apply(handProxy.MiddleDistal, HandJoint.MiddleDistal); Apply(handProxy.MiddleTip, HandJoint.MiddleTip); Apply(handProxy.RingMetacarpal, HandJoint.RingMetacarpal); Apply(handProxy.RingProximal, HandJoint.RingProximal); Apply(handProxy.RingIntermediate, HandJoint.RingIntermediate); Apply(handProxy.RingDistal, HandJoint.RingDistal); Apply(handProxy.RingTip, HandJoint.RingTip); Apply(handProxy.LittleMetacarpal, HandJoint.LittleMetacarpal); Apply(handProxy.LittleProximal, HandJoint.LittleProximal); Apply(handProxy.LittleIntermediate, HandJoint.LittleIntermediate); Apply(handProxy.LittleDistal, HandJoint.LittleDistal); Apply(handProxy.LittleTip, HandJoint.LittleTip); } else { // Disable the hand } }
public void Update(FrameTime frameTime) { foreach (var scene in Scenes) { scene.Update(frameTime); } }
public FrameTimeEvent(FrameTime frameTime) { this.FrameTime = frameTime; this.DeltaTime = frameTime.DeltaTime; this.DeltaTimeOver1Second = frameTime.DeltaTime1Second; this.DeltaTimeOver10Seconds = frameTime.DeltaTime10Seconds; }
/// <summary> /// Move this instance. May be overriden in inheriting classes. /// </summary> public virtual Vec3 Move() { // HAndle null? if (!Exists) { return(Vec3.Zero); } // Empty jetPosition means x, y and z are all 0. if (this is ProjectileBase) { if (!_isVelocitySet) { if (PhysicalEntity != null) { var peASV = new pe_action_set_velocity(); peASV.v = Speed; PhysicalEntity.Action(peASV); } _isVelocitySet = true; } return(Position); } Vec3 newPosition = Position + FrameTime.Normalize(Speed); Position = newPosition; return(newPosition); }
public void Update(FrameTime frameTime) { if (!IsEnabled) { return; } var camera = globalObjectService.MainCamera; var projectedForward = new Plane(ca.Vector3.UnitY, ca.Vector3.Zero).Project(camera.transform.forward.ToClarity()); if (projectedForward.LengthSquared() < MathHelper.Eps8) { return; } var dpadOffset = SteamVR_Actions.default_DpadOrientation.GetAxis(SteamVR_Input_Sources.RightHand); var forward = projectedForward.Normalize(); var right = ca.Vector3.Cross(forward, ca.Vector3.UnitY); var controllerMovement = forward * dpadOffset.y + right * dpadOffset.x; var cameraHeightOffset = 1f; var startingPoint = globalObjectService.VrPlayerCarrier.transform.position.ToClarity() + cameraHeightOffset * ca.Vector3.UnitY; var offset = controllerMovement * Speed * frameTime.DeltaSeconds; var unrestrictedNewPosition = startingPoint + offset; var restrictedNewPosition = collisionMesh.RestrictMovement(0.5f, startingPoint, offset); restrictedNewPosition.Y = unrestrictedNewPosition.Y - cameraHeightOffset; globalObjectService.VrPlayerCarrier.transform.position = restrictedNewPosition.ToUnity(); }
private const float kGoldenRatio = 1.61803398874989484820458683436f; //Esoteric factor used to decouple horizontal and vertical frequencies public FlyNoiseSystem(FrameTime time, FlyData flyData, FlyNoiseData noiseData) { mFlyNoiseData = noiseData; mRandom = new Random(); mTime = time; mNoiseStateBuffer = new FlyNoiseState[flyData.MaxActiveFlies]; mPositionBuffer = new Position[flyData.MaxActiveFlies]; }
public FlyDirectionSystem(FrameTime time, PondSimState pond, FlyData flyData, FlyDirectionChangeData changeData) { mTime = time; mPond = pond; mFlyData = flyData; mChangeData = changeData; mRandom = new Random(); }
public void Update(FrameTime frameTime) { currentSeconds += frameTime.DeltaSeconds; if (currentSeconds >= targetSeconds) { onFinish(); } }
public void Update(FrameTime frameTime) { var camera = globalObjectService.MainCamera; var frame = new CameraFrame(camera.transform.position.ToClarity(), camera.transform.rotation.ToClarity()); var proj = new CameraProjection(CameraProjectionType.Perspective, camera.nearClipPlane, camera.farClipPlane, camera.fieldOfView); props = new CameraProps(frame.Eye + frame.Forward, frame, proj); }
public override void Tick(FrameTime ft) { GameEngine.SetGameLevel(Context.Cast <NativeObjectAdapter>()); GameEngine.Update(ft.TotalTime, ft.ElapsedTime, false); foreach (NativeDesignControl view in Views) { view.Render(); } }
public override void Update(FrameTime frameTime, InputManager inputManager) { var horizontalVelocity = this.CalculateHorizontalVelocity(frameTime, inputManager); if (horizontalVelocity != 0f) { this.PlayerComponent.ChangeStance(PlayerStance.Walking, frameTime); } }
public void Update(FrameTime frameTime) { currentTimestamp += frameTime.DeltaSeconds; if (currentTimestamp > DefaultDuration) { currentTimestamp = DefaultDuration; HasFinished = true; } }
internal static unsafe void Invoke(IntPtr obj, FrameTime NewPosition) { long *p = stackalloc long[] { 0L, 0L }; byte *b = (byte *)p; *((FrameTime *)(b + 0)) = NewPosition; Main.GetProcessEvent(obj, ScrubToFrame_ptr, new IntPtr(p));; } }
public override void Update(FrameTime time) { if (time.Time - lastParticleTime >= ParticleInterval) { lastParticleTime = time.Time; var particle = GenerateParticle(time.Time); Services.Game.Particles.AddParticle(particle); } }
public void ComputeFPS(double elapsedRealTime) { if (elapsedRealTime < 0.001) { return; } FrameRate.Update(elapsedRealTime, 1.0 / elapsedRealTime); FrameTime.Update(elapsedRealTime, elapsedRealTime); }
private FrameTime GetTimeForFrame(FittingContext context, int frameNumber, int firstVideoFrame, GetFrameStateDataCallback getFrameStateData, DateTime? ocrTime) { var rv = new FrameTime(); rv.RequestedFrameNo = frameNumber; double instrumentalDelayFrames = 0; double instrumentalDelaySeconds = 0; if (context.InstrumentalDelayUnits == InstrumentalDelayUnits.Frames) instrumentalDelayFrames = context.InstrumentalDelay; else if (context.InstrumentalDelayUnits == InstrumentalDelayUnits.Seconds) instrumentalDelaySeconds = context.InstrumentalDelay; int precision = 1000000; double sigma = 0.000005; if (context.FrameTimeType == FrameTimeType.NonIntegratedFrameTime) { if (context.VideoFileFormat == VideoFileFormat.AVI) { // No integration is used, directly derive the time and apply instrumental delay rv.ResolvedFrameNo = frameNumber - firstVideoFrame; rv.UT = context.FirstFrameUtcTime.AddSeconds( ((frameNumber - context.FirstFrameIdInIntegrationPeroid - instrumentalDelayFrames) / context.FrameRate) - instrumentalDelaySeconds); } else if (context.VideoFileFormat == VideoFileFormat.AAV2 && ocrTime.HasValue) { rv.ResolvedFrameNo = frameNumber - firstVideoFrame; var dateTime = context.FirstFrameUtcTime.Date.Add(ocrTime.Value.TimeOfDay); rv.UT = dateTime.AddSeconds(-instrumentalDelayFrames/context.FrameRate-instrumentalDelaySeconds); } else { rv.ResolvedFrameNo = frameNumber; var frameState = getFrameStateData(frameNumber); rv.UT = frameState.CentralExposureTime; // Convert Central time to the timestamp of the end of the first field rv.UT = rv.UT.AddMilliseconds(-0.5 * frameState.ExposureInMilliseconds); if (context.NativeVideoFormat == "PAL") rv.UT = rv.UT.AddMilliseconds(20); else if (context.NativeVideoFormat == "NTSC") rv.UT = rv.UT.AddMilliseconds(16.68); if (context.AavStackedMode) { throw new NotSupportedException("AAV Stacked Mode is not supported!"); } else { // Then apply instrumental delay rv.UT = rv.UT.AddSeconds(-1 * instrumentalDelaySeconds); } } } else { // Integration was used. Find the integrated frame no int integratedFrameNo = frameNumber - firstVideoFrame; double deltaMiddleFrame = 0; if (context.IntegratedFramesCount > 1) deltaMiddleFrame = (context.IntegratedFramesCount / 2) - 0.5 /* This 0.5 frame correction is only used for the 'visual' mapping between where the user clicked and what is the most 'logical' normal frame to where they clicked */; // The instrumental delay is always from the timestamp of the first frame of the integrated interval rv.ResolvedFrameNo = integratedFrameNo; rv.UT = context.FirstFrameUtcTime.AddSeconds( ((integratedFrameNo - deltaMiddleFrame - context.FirstFrameIdInIntegrationPeroid - instrumentalDelayFrames) / context.FrameRate) - instrumentalDelaySeconds); } if (context.MovementExpectation == MovementExpectation.Slow) { precision = 100000; sigma = 0.000005; } else { precision = 1000000; sigma = 0.0000005; } double utTime = (rv.UT.Hour + rv.UT.Minute / 60.0 + (rv.UT.Second + (rv.UT.Millisecond / 1000.0)) / 3600.0) / 24; double roundedTime = Math.Truncate(Math.Round(utTime * precision)) / precision; rv.ClosestNormalFrameTime = new DateTime(rv.UT.Year, rv.UT.Month, rv.UT.Day).AddDays(roundedTime); TimeSpan delta = new TimeSpan(rv.ClosestNormalFrameTime.Ticks - rv.UT.Ticks); rv.ClosestNormalFrameNo = rv.ResolvedFrameNo + (delta.TotalSeconds * context.FrameRate); double framesEachSide = sigma * 24 * 3600 * context.FrameRate; rv.ClosestNormalIntervalFirstFrameNo = (int)Math.Floor(rv.ClosestNormalFrameNo - framesEachSide); rv.ClosestNormalIntervalLastFrameNo = (int)Math.Ceiling(rv.ClosestNormalFrameNo + framesEachSide); //Trace.WriteLine(string.Format("{0} / {1}; {2} / {3}; {4} / {5}", // roundedTime.ToString("0.00000"), utTime, // rv.ClosestNormalFrameNo, rv.ResolvedFrameNo, // rv.UT.ToString("HH:mm:ss.fff"), rv.ClosestNormalFrameTime.ToString("HH:mm:ss.fff"))); return rv; }